Re: [PATCH] hotplug: Optimize {get,put}_online_cpus()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 23, 2013 at 10:50:17AM -0400, Steven Rostedt wrote:
> On Thu, 19 Sep 2013 16:32:41 +0200
> Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> 
> 
> > +extern void __get_online_cpus(void);
> > +
> > +static inline void get_online_cpus(void)
> > +{
> > +	might_sleep();
> > +
> > +	preempt_disable();
> > +	if (likely(!__cpuhp_writer || __cpuhp_writer == current))
> > +		this_cpu_inc(__cpuhp_refcount);
> > +	else
> > +		__get_online_cpus();
> > +	preempt_enable();
> > +}
> 
> 
> This isn't much different than srcu_read_lock(). What about doing
> something like this:
> 
> static inline void get_online_cpus(void)
> {
> 	might_sleep();
> 
> 	srcu_read_lock(&cpuhp_srcu);
> 	if (unlikely(__cpuhp_writer || __cpuhp_writer != current)) {
> 		srcu_read_unlock(&cpuhp_srcu);
> 		__get_online_cpus();
> 		current->online_cpus_held++;
> 	}
> }

There's a full memory barrier in srcu_read_lock(), while there was no
such thing in the previous fast path.

Also, why current->online_cpus_held()? That would make the write side
O(nr_tasks) instead of O(nr_cpus).

> static inline void put_online_cpus(void)
> {
> 	if (unlikely(current->online_cpus_held)) {
> 		current->online_cpus_held--;
> 		__put_online_cpus();
> 		return;
> 	}
> 
> 	srcu_read_unlock(&cpuhp_srcu);
> }

Also, you might not have noticed but, srcu_read_{,un}lock() have an
extra idx thing to pass about. That doesn't fit with the hotplug api.

> 
> Then have the writer simply do:
> 
> 	__cpuhp_write = current;
> 	synchronize_srcu(&cpuhp_srcu);
> 
> 	<grab the mutex here>

How does that do reader preference?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]