Re: [PATCH V6 1/2] percpu_ref: reduce memory footprint of percpu_ref in fast path

From: Tejun Heo
Date: Wed Sep 30 2020 - 12:00:20 EST


On Wed, Sep 30, 2020 at 04:26:56PM +0800, Ming Lei wrote:
> diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h
> index 87d8a38bdea1..1d6ed9ca23dd 100644
> --- a/include/linux/percpu-refcount.h
> +++ b/include/linux/percpu-refcount.h
> @@ -92,18 +92,23 @@ enum {
> PERCPU_REF_ALLOW_REINIT = 1 << 2,
> };
>
> -struct percpu_ref {
> +struct percpu_ref_data {
> atomic_long_t count;
> - /*
> - * The low bit of the pointer indicates whether the ref is in percpu
> - * mode; if set, then get/put will manipulate the atomic_t.
> - */
> - unsigned long percpu_count_ptr;
> percpu_ref_func_t *release;
> percpu_ref_func_t *confirm_switch;
> bool force_atomic:1;
> bool allow_reinit:1;
> struct rcu_head rcu;
> + struct percpu_ref *ref;
> +};
> +
> +struct percpu_ref {
> + /*
> + * The low bit of the pointer indicates whether the ref is in percpu
> + * mode; if set, then get/put will manipulate the atomic_t.
> + */
> + unsigned long percpu_count_ptr;
> + struct percpu_ref_data *data;
> };

Can you please add a comment explaining why the two structs are split?

Thanks.

--
tejun