[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <f2adb710-dd8a-4b41-8511-0466e68d3635@bytedance.com>
Date: Fri, 6 Feb 2026 17:07:05 +0800
From: "Chuyi Zhou" <zhouchuyi@...edance.com>
To: "Peter Zijlstra" <peterz@...radead.org>
Cc: <tglx@...utronix.de>, <mingo@...hat.com>, <luto@...nel.org>,
<paulmck@...nel.org>, <muchun.song@...ux.dev>, <bp@...en8.de>,
<dave.hansen@...ux.intel.com>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 04/11] smp: Use on-stack cpumask in smp_call_function_many_cond
在 2026/2/5 17:44, Peter Zijlstra 写道:
> On Tue, Feb 03, 2026 at 07:23:54PM +0800, Chuyi Zhou wrote:
>> This patch use on-stack cpumask to replace percpu cfd cpumask in
>> smp_call_function_many_cond(). alloc_cpumask_var() may fail when
>> CONFIG_CPUMASK_OFFSTACK is enabled. In such extreme case, fall back to
>> cfd->cpumask. This is a preparation for the next patch.
>>
>> Signed-off-by: Chuyi Zhou <zhouchuyi@...edance.com>
>> ---
>> kernel/smp.c | 22 +++++++++++++++++-----
>> 1 file changed, 17 insertions(+), 5 deletions(-)
>>
>> diff --git a/kernel/smp.c b/kernel/smp.c
>> index f572716c3c7d..35948afced2e 100644
>> --- a/kernel/smp.c
>> +++ b/kernel/smp.c
>> @@ -805,11 +805,17 @@ static void smp_call_function_many_cond(const struct cpumask *mask,
>> int cpu, last_cpu, this_cpu = smp_processor_id();
>> struct call_function_data *cfd;
>> bool wait = scf_flags & SCF_WAIT;
>> + bool preemptible_wait = true;
>> + cpumask_var_t cpumask_stack;
>> + struct cpumask *cpumask;
>> int nr_cpus = 0;
>> bool run_remote = false;
>>
>> lockdep_assert_preemption_disabled();
>>
>> + if (!alloc_cpumask_var(&cpumask_stack, GFP_ATOMIC))
>> + preemptible_wait = false;
>
> IIRC this breaks RT, must not allocate with preemption disabled.
Thank you for the reminder.
Perhaps another feasible approach is only consider
CONFIG_CPUMASK_OFFSTACK=n.
Of course, if we use cpus_read_lock and ensure that the caller’s context
is sleepable, this issue would also be eliminated.
Powered by blists - more mailing lists