percpu-refcount: add @gfp to percpu_ref_init()
[firefly-linux-kernel-4.4.55.git] / lib / percpu-refcount.c
index fe5a3342e9607d8ee9bd11678ef31d070a81ccf5..ff9903264a91f09386028d914f492fea7b2fad35 100644 (file)
@@ -40,6 +40,7 @@ static unsigned __percpu *pcpu_count_ptr(struct percpu_ref *ref)
  * percpu_ref_init - initialize a percpu refcount
  * @ref: percpu_ref to initialize
  * @release: function which will be called when refcount hits 0
+ * @gfp: allocation mask to use
  *
  * Initializes the refcount in single atomic counter mode with a refcount of 1;
  * analagous to atomic_set(ref, 1).
@@ -47,11 +48,12 @@ static unsigned __percpu *pcpu_count_ptr(struct percpu_ref *ref)
  * Note that @release must not sleep - it may potentially be called from RCU
  * callback context by percpu_ref_kill().
  */
-int percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release)
+int percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release,
+                   gfp_t gfp)
 {
        atomic_set(&ref->count, 1 + PCPU_COUNT_BIAS);
 
-       ref->pcpu_count_ptr = (unsigned long)alloc_percpu(unsigned);
+       ref->pcpu_count_ptr = (unsigned long)alloc_percpu_gfp(unsigned, gfp);
        if (!ref->pcpu_count_ptr)
                return -ENOMEM;