[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241121065440.3391001-1-ranxiaokai627@163.com>
Date: Thu, 21 Nov 2024 06:54:40 +0000
From: Ran Xiaokai <ranxiaokai627@....com>
To: peterz@...radead.org
Cc: linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org,
mingo@...hat.com,
ran.xiaokai@....com.cn,
ranxiaokai627@....com
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?
Too many of these simple rcu callbacks increase in the kernel size,
and there have been several rounds of cleanups to replace these simple
call_rcu(). So this one is a straggler ?
Besides, no real-world problem was observed.
>> 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