- struct channel *chan = container_of(nb, struct channel,
- tick_nohz_notifier);
- const struct lib_ring_buffer_config *config = chan->backend.config;
- struct lib_ring_buffer *buf;
- int cpu = smp_processor_id();
-
- if (config->alloc != RING_BUFFER_ALLOC_PER_CPU) {
- /*
- * We don't support keeping the system idle with global buffers
- * and streaming active. In order to do so, we would need to
- * sample a non-nohz-cpumask racelessly with the nohz updates
- * without adding synchronization overhead to nohz. Leave this
- * use-case out for now.
- */
- return 0;
- }
-
- buf = channel_get_ring_buffer(config, chan, cpu);
- switch (val) {
- case TICK_NOHZ_FLUSH:
- raw_spin_lock(&buf->raw_tick_nohz_spinlock);
- if (config->wakeup == RING_BUFFER_WAKEUP_BY_TIMER
- && chan->read_timer_interval
- && atomic_long_read(&buf->active_readers)
- && (lib_ring_buffer_poll_deliver(config, buf, chan)
- || lib_ring_buffer_pending_data(config, buf, chan))) {
- wake_up_interruptible(&buf->read_wait);
- wake_up_interruptible(&chan->read_wait);
- }
- if (chan->switch_timer_interval)
- lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
- raw_spin_unlock(&buf->raw_tick_nohz_spinlock);
- break;
- case TICK_NOHZ_STOP:
- spin_lock(&__get_cpu_var(ring_buffer_nohz_lock));
- lib_ring_buffer_stop_switch_timer(buf);
- lib_ring_buffer_stop_read_timer(buf);
- spin_unlock(&__get_cpu_var(ring_buffer_nohz_lock));
- break;
- case TICK_NOHZ_RESTART:
- spin_lock(&__get_cpu_var(ring_buffer_nohz_lock));
- lib_ring_buffer_start_read_timer(buf);
- lib_ring_buffer_start_switch_timer(buf);
- spin_unlock(&__get_cpu_var(ring_buffer_nohz_lock));
- break;
- }
-
- return 0;
-}
-
-void notrace lib_ring_buffer_tick_nohz_flush(void)
-{
- atomic_notifier_call_chain(&tick_nohz_notifier, TICK_NOHZ_FLUSH,
- NULL);
-}
-
-void notrace lib_ring_buffer_tick_nohz_stop(void)
-{
- atomic_notifier_call_chain(&tick_nohz_notifier, TICK_NOHZ_STOP,
- NULL);
-}
-
-void notrace lib_ring_buffer_tick_nohz_restart(void)
-{
- atomic_notifier_call_chain(&tick_nohz_notifier, TICK_NOHZ_RESTART,
- NULL);
-}
-#endif /* defined(CONFIG_NO_HZ) && defined(CONFIG_LIB_RING_BUFFER) */
-
-/*
- * Holds CPU hotplug.
- */
-static void channel_unregister_notifiers(struct channel *chan)
-{
- const struct lib_ring_buffer_config *config = chan->backend.config;