mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
percpu_ref: add PERCPU_REF_INIT_* flags
With the recent addition of percpu_ref_reinit(), percpu_ref now can be used as a persistent switch which can be turned on and off repeatedly where turning off maps to killing the ref and waiting for it to drain; however, there currently isn't a way to initialize a percpu_ref in its off (killed and drained) state, which can be inconvenient for certain persistent switch use cases. Similarly, percpu_ref_switch_to_atomic/percpu() allow dynamic selection of operation mode; however, currently a newly initialized percpu_ref is always in percpu mode making it impossible to avoid the latency overhead of switching to atomic mode. This patch adds @flags to percpu_ref_init() and implements the following flags. * PERCPU_REF_INIT_ATOMIC : start ref in atomic mode * PERCPU_REF_INIT_DEAD : start ref killed and drained These flags should be able to serve the above two use cases. v2: target_core_tpg.c conversion was missing. Fixed. Signed-off-by: Tejun Heo <[email protected]> Reviewed-by: Kent Overstreet <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Johannes Weiner <[email protected]>
This commit is contained in:
parent
f47ad45784
commit
2aad2a86f6
6 changed files with 43 additions and 13 deletions
4
fs/aio.c
4
fs/aio.c
|
|
@ -661,10 +661,10 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
|
|||
|
||||
INIT_LIST_HEAD(&ctx->active_reqs);
|
||||
|
||||
if (percpu_ref_init(&ctx->users, free_ioctx_users, GFP_KERNEL))
|
||||
if (percpu_ref_init(&ctx->users, free_ioctx_users, 0, GFP_KERNEL))
|
||||
goto err;
|
||||
|
||||
if (percpu_ref_init(&ctx->reqs, free_ioctx_reqs, GFP_KERNEL))
|
||||
if (percpu_ref_init(&ctx->reqs, free_ioctx_reqs, 0, GFP_KERNEL))
|
||||
goto err;
|
||||
|
||||
ctx->cpu = alloc_percpu(struct kioctx_cpu);
|
||||
|
|
|
|||
Loading…
Reference in a new issue