Hello, On Mon, Jul 21, 2014 at 01:27:34PM -0400, Vivek Goyal wrote: > > +static bool tg_ensure_stats_cpu(struct throtl_grp *tg) ... > > + if (cmpxchg(&tg->stats_cpu, (struct tg_stats_cpu __percpu *)NULL, > > + stats_cpu)) > > + free_percpu(stats_cpu); > > + > > > So we are using atomic cmpxchg() so that we don't ask callers to hold queue > lock during this call? One of the callers is throtl_update_dispatch_stats() > and we don't want to grab queue lock while updating per cpu stat. In fact > stats were made per cpu so that we don't have to grab the lock.
Yeah, pretty much. We can grab queuelock in the cold path for installation only but the original code already had cmpxchg, so I thought why not. It could be simpler to do the following tho. if (already populated) return; lock_queue; if (populated inbetween) unlock and return; alloc; install; unlock_queue; I don't know. I don't think it really matters. Thanks. -- tejun -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/