All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Ran Xiaokai <ranxiaokai627@163.com>
Cc: juri.lelli@redhat.com, vincent.guittot@linaro.org,
	mingo@redhat.com, pshelar@ovn.org, davem@davemloft.net,
	linux-kernel@vger.kernel.org, ran.xiaokai@zte.com.cn,
	linux-perf-users@vger.kernel.org, netdev@vger.kernel.org,
	dev@openvswitch.org
Subject: Re: [PATCH 2/4] perf/core: convert call_rcu(free_ctx) to kfree_rcu()
Date: Wed, 20 Nov 2024 10:12:15 +0100	[thread overview]
Message-ID: <20241120091215.GK39245@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20241120064716.3361211-3-ranxiaokai627@163.com>

On Wed, Nov 20, 2024 at 06:47:14AM +0000, Ran Xiaokai wrote:
> From: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> 
> The rcu callback free_ctx() simply calls kfree().
> It's better to directly call kfree_rcu().

Why is it better? 

> Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> ---
>  kernel/events/core.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 065f9188b44a..7f4cc9c41bbe 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -1210,14 +1210,6 @@ static void free_task_ctx_data(struct pmu *pmu, void *task_ctx_data)
>  		kmem_cache_free(pmu->task_ctx_cache, task_ctx_data);
>  }
>  
> -static void free_ctx(struct rcu_head *head)
> -{
> -	struct perf_event_context *ctx;
> -
> -	ctx = container_of(head, struct perf_event_context, rcu_head);
> -	kfree(ctx);
> -}
> -
>  static void put_ctx(struct perf_event_context *ctx)
>  {
>  	if (refcount_dec_and_test(&ctx->refcount)) {
> @@ -1225,7 +1217,7 @@ static void put_ctx(struct perf_event_context *ctx)
>  			put_ctx(ctx->parent_ctx);
>  		if (ctx->task && ctx->task != TASK_TOMBSTONE)
>  			put_task_struct(ctx->task);
> -		call_rcu(&ctx->rcu_head, free_ctx);
> +		kfree_rcu(ctx, rcu_head);
>  	}
>  }
>  
> -- 
> 2.17.1
> 
> 

  reply	other threads:[~2024-11-20  9:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-20  6:47 [PATCH 0/4] Convert some simple call_rcu() to kfree_rcu()/kvfree_rcu() Ran Xiaokai
2024-11-20  6:47 ` [PATCH 1/4] sched/topology: convert call_rcu(free_ctx) to kfree_rcu() Ran Xiaokai
2024-11-20  6:47 ` [PATCH 2/4] perf/core: " Ran Xiaokai
2024-11-20  9:12   ` Peter Zijlstra [this message]
2024-11-20  9:16     ` Peter Zijlstra
2024-11-21  6:54       ` Ran Xiaokai
2024-11-20  6:47 ` [PATCH 3/4] net: openvswitch: convert call_rcu(dp_meter_instance_free_rcu) to kvfree_rcu() Ran Xiaokai
2024-11-21  8:37   ` Paolo Abeni
2024-11-20  6:47 ` [PATCH 4/4] net: sysfs: convert call_rcu() " Ran Xiaokai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241120091215.GK39245@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pshelar@ovn.org \
    --cc=ran.xiaokai@zte.com.cn \
    --cc=ranxiaokai627@163.com \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.