On Thu, Jan 23, 2014 at 05:22:54PM +0100, Peter Zijlstra wrote: > On Thu, Jan 23, 2014 at 05:28:29AM -0800, Kent Overstreet wrote: > > pool->lock is also going to be fairly badly contended in the worst case, > > and that can get real bad real fast... now that I think about it we > > probably want to avoid the __alloc_global_tag() double call just because > > of that, pool->lock is going to be quite a bit more contended than the > > waitlist lock just because fo the amount of work done under it. > Now everything modifying percpu_ida_cpu state holds > percpu_ida_cpu::lock Almost that. --- --- a/lib/percpu_ida.c +++ b/lib/percpu_ida.c @@ -51,6 +51,15 @@ static inline void move_tags(unsigned *d *dst_nr += nr; } +static inline void double_lock(spinlock_t *l1, spinlock_t *l2) +{ + if (l1 > l2) + swap(l1, l2); + + spin_lock(l1); + spin_lock_nested(l2, SINGLE_DEPTH_NESTING); +} + /* * Try to steal tags from a remote cpu's percpu freelist. * @@ -87,7 +96,7 @@ static inline void steal_tags(struct per if (remote == tags) continue; - spin_lock(&remote->lock); + double_lock(&tags->lock, &remote->lock); if (remote->nr_free) { memcpy(tags->freelist, @@ -99,6 +108,7 @@ static inline void steal_tags(struct per } spin_unlock(&remote->lock); + spin_unlock(&tags->lock); if (tags->nr_free) break; -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html