diff options
author | Tejun Heo <tj@kernel.org> | 2014-09-07 20:51:30 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-09-07 20:51:30 -0400 |
commit | a34375ef9e65340a138fc0be287de5c940d260fc (patch) | |
tree | 2e21b63d7c9240620a59090aa97e1d7c6df95b8c /lib/percpu-refcount.c | |
parent | 20ae00792c6f1f18fc4fc5965445a145df92827e (diff) |
percpu-refcount: add @gfp to percpu_ref_init()
Percpu allocator now supports allocation mask. Add @gfp to
percpu_ref_init() so that !GFP_KERNEL allocation masks can be used
with percpu_refs too.
This patch doesn't make any functional difference.
v2: blk-mq conversion was missing. Updated.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Kent Overstreet <koverstreet@google.com>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Nicholas A. Bellinger <nab@linux-iscsi.org>
Cc: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'lib/percpu-refcount.c')
-rw-r--r-- | lib/percpu-refcount.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c index fe5a3342e960..ff9903264a91 100644 --- a/lib/percpu-refcount.c +++ b/lib/percpu-refcount.c | |||
@@ -40,6 +40,7 @@ static unsigned __percpu *pcpu_count_ptr(struct percpu_ref *ref) | |||
40 | * percpu_ref_init - initialize a percpu refcount | 40 | * percpu_ref_init - initialize a percpu refcount |
41 | * @ref: percpu_ref to initialize | 41 | * @ref: percpu_ref to initialize |
42 | * @release: function which will be called when refcount hits 0 | 42 | * @release: function which will be called when refcount hits 0 |
43 | * @gfp: allocation mask to use | ||
43 | * | 44 | * |
44 | * Initializes the refcount in single atomic counter mode with a refcount of 1; | 45 | * Initializes the refcount in single atomic counter mode with a refcount of 1; |
45 | * analagous to atomic_set(ref, 1). | 46 | * analagous to atomic_set(ref, 1). |
@@ -47,11 +48,12 @@ static unsigned __percpu *pcpu_count_ptr(struct percpu_ref *ref) | |||
47 | * Note that @release must not sleep - it may potentially be called from RCU | 48 | * Note that @release must not sleep - it may potentially be called from RCU |
48 | * callback context by percpu_ref_kill(). | 49 | * callback context by percpu_ref_kill(). |
49 | */ | 50 | */ |
50 | int percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release) | 51 | int percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release, |
52 | gfp_t gfp) | ||
51 | { | 53 | { |
52 | atomic_set(&ref->count, 1 + PCPU_COUNT_BIAS); | 54 | atomic_set(&ref->count, 1 + PCPU_COUNT_BIAS); |
53 | 55 | ||
54 | ref->pcpu_count_ptr = (unsigned long)alloc_percpu(unsigned); | 56 | ref->pcpu_count_ptr = (unsigned long)alloc_percpu_gfp(unsigned, gfp); |
55 | if (!ref->pcpu_count_ptr) | 57 | if (!ref->pcpu_count_ptr) |
56 | return -ENOMEM; | 58 | return -ENOMEM; |
57 | 59 | ||