[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140722005005.GH12921@htj.dyndns.org>
Date: Mon, 21 Jul 2014 20:50:05 -0400
From: Tejun Heo <tj@...nel.org>
To: Vivek Goyal <vgoyal@...hat.com>
Cc: linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Jens Axboe <axboe@...nel.dk>
Subject: Re: [PATCH percpu/for-3.17 2/2] blk-throttle: replace custom async
percpu alloc mechanism with percpu_pool
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 majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists