lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241120091215.GK39245@noisy.programming.kicks-ass.net>
Date: Wed, 20 Nov 2024 10:12:15 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Ran Xiaokai <ranxiaokai627@....com>
Cc: juri.lelli@...hat.com, vincent.guittot@...aro.org, mingo@...hat.com,
	pshelar@....org, davem@...emloft.net, linux-kernel@...r.kernel.org,
	ran.xiaokai@....com.cn, linux-perf-users@...r.kernel.org,
	netdev@...r.kernel.org, dev@...nvswitch.org
Subject: Re: [PATCH 2/4] perf/core: convert call_rcu(free_ctx) to kfree_rcu()

On Wed, Nov 20, 2024 at 06:47:14AM +0000, Ran Xiaokai wrote:
> From: Ran Xiaokai <ran.xiaokai@....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@....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
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ