Messages in this thread | | | Date | Tue, 24 Sep 2013 23:02:21 +0200 | From | Peter Zijlstra <> | Subject | Re: [PATCH] hotplug: Optimize {get,put}_online_cpus() |
| |
On Tue, Sep 24, 2013 at 10:24:23PM +0200, Peter Zijlstra wrote: > +void __get_online_cpus(void) > +{ > + if (__cpuhp_writer == 1) { take_ref: > + /* See __srcu_read_lock() */ > + __this_cpu_inc(__cpuhp_refcount); > + smp_mb(); > + __this_cpu_inc(cpuhp_seq); > + return; > + } > + > + atomic_inc(&cpuhp_waitcount); > + > /* > + * We either call schedule() in the wait, or we'll fall through > + * and reschedule on the preempt_enable() in get_online_cpus(). > */ > + preempt_enable_no_resched(); > + wait_event(cpuhp_readers, !__cpuhp_writer); > + preempt_disable(); > > + /* > + * XXX list_empty_careful(&cpuhp_readers.task_list) ? > + */ > + if (atomic_dec_and_test(&cpuhp_waitcount)) > + wake_up_all(&cpuhp_writer); goto take_ref; > +} > +EXPORT_SYMBOL_GPL(__get_online_cpus);
It would probably be a good idea to increment __cpuhp_refcount after the wait_event.
| |