From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C83234CFAE for ; Fri, 22 May 2026 07:22:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779434535; cv=none; b=bWghKt/Cmt1sNTns9DxPJROOWll1lQmwdXpr7xw7IhqRxYyPKJF9Z4XvVq1daxq8V1ukU+C2FrVippfiIkzWdD9fLn65tfrzYQjCBsD6fGiW+ot8wkvI5nVCndkFXqnp//DJHXdMeNqu9r4hBdf02QD8th+CUhcPZT2hOb7kx4I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779434535; c=relaxed/simple; bh=ghw4a1nPeSWqUxUNtwryzBjUAZ1MVBH+RFnFWB3MATY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ehkxV6Tr4EVb1XspTqn79YKXsbxGV4Z8fG7LM6qyc7voW4YX04xYg1oSaTWQo2MNudR3I0O1rUb8efWYSH2oMLQhhUxHRevZIrxrLajEcAQWtZykkW+l5BzCrkLxkyM/L3PV1vrinwBXhTlyQ2ggTbv4WKyLQYQ/CrqZKG0OAms= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gnAflxts; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ETsxJVJl; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gnAflxts"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ETsxJVJl" Date: Fri, 22 May 2026 09:22:11 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779434532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hphtFkymxEs5FRmsXrQMh9pSMo0piTtVWCNKJ5azCKM=; b=gnAflxtsoDAlqtx5C+cB0vAcQQLzXiGAip0wENCJkWYcf+OHa564nVkb6SvEN+Bb+yL90H Hduyhdwe2y01thwLo+Ee2MKW5gO9lyi9Pt8U3PMrTMbXdCiTJYJXYI57UhpR33Zbftj1tk npRn8QQZrZ1lpInX3LwaX2uClzo9GJgurafXoFdwYneLSPqaSY4P9czjfkk79mpdqqc3n2 un7UNWe+vYmBO42J4bOQ9fbxeMvRedBs91+nYSEBohWrGZQpq0A7Udw3sKFiez32yZEIc+ alP9Q+Ry+0lK6kv4vWdv4toArAXN03CYu54PBAomJtaTJoRqzGCDNAtbD/zAqQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779434532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hphtFkymxEs5FRmsXrQMh9pSMo0piTtVWCNKJ5azCKM=; b=ETsxJVJlKN3Yu3Sfg1y6FjnXSXMCFYihQQT7GC9FnrV9wFQ9coEiG/AJiSMVqt/5pqLCF/ 5r3SjjsJZDOhNmDg== From: Sebastian Andrzej Siewior To: Chuyi Zhou Cc: tglx@linutronix.de, mingo@redhat.com, luto@kernel.org, peterz@infradead.org, paulmck@kernel.org, muchun.song@linux.dev, bp@alien8.de, dave.hansen@linux.intel.com, pbonzini@redhat.com, clrkwllms@kernel.org, rostedt@goodmis.org, nadav.amit@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [RESEND PATCH v5 04/12] smp: Use task-local IPI cpumask in smp_call_function_many_cond() Message-ID: <20260522072211.0Vc7V0UB@linutronix.de> References: <20260513124524.2569867-1-zhouchuyi@bytedance.com> <20260513124524.2569867-5-zhouchuyi@bytedance.com> <20260521152658.voQhpA6g@linutronix.de> <6b4ff464-8109-4565-859b-f51d70dced51@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <6b4ff464-8109-4565-859b-f51d70dced51@bytedance.com> On 2026-05-22 00:00:25 [+0800], Chuyi Zhou wrote: > On 2026-05-21 11:26 p.m., Sebastian Andrzej Siewior wrote: > > On 2026-05-13 20:45:16 [+0800], Chuyi Zhou wrote: > >> diff --git a/kernel/smp.c b/kernel/smp.c > >> index 9e9dab3b0d51..630c8e5a635d 100644 > >> --- a/kernel/smp.c > >> +++ b/kernel/smp.c > >> @@ -811,11 +849,18 @@ static void smp_call_function_many_cond(const st= ruct cpumask *mask, > >> int cpu, last_cpu, this_cpu =3D smp_processor_id(); > >> struct call_function_data *cfd; > >> bool wait =3D scf_flags & SCF_WAIT; > >> + struct cpumask *cpumask, *task_mask; > >> + bool preemptible_wait; > >> int nr_cpus =3D 0; > >> bool run_remote =3D false; > >> =20 > >> lockdep_assert_preemption_disabled(); > >> =20 > >> + task_mask =3D smp_task_ipi_mask(current); > >> + preemptible_wait =3D task_mask; > >> + cfd =3D this_cpu_ptr(&cfd_data); > >> + cpumask =3D preemptible_wait ? task_mask : cfd->cpumask; > >=20 > > Is this a porting artifact? preemptible_wait is a bool while task_mask > > is a pointer which is always !=3D NULL. > >=20 >=20 > Not exactly. The NULL fallback is intentional: smp_task_ipi_mask() > returns NULL for !CONFIG_PREEMPTION, and init_task may also not have an > allocated ipi_mask_ptr in the non-inlined case. Okay, but please don't assign a cpumask to a bool and having one to guess all that behind it. Something like cfd =3D this_cpu_ptr(&cfd_data); task_mask =3D smp_task_ipi_mask(current); if (task_mask) cpumask =3D task_mask; else cpumask =3D cfd->cpumask; would make it probably obvious. You probably need a bool later on to check if you use task's mask and can open preemption while waiting. Hmm. Let me continue=E2=80=A6 > But you are right that the name is confusing in this preparatory patch. > Here it only means "task-local cpumask is available", not that the wait is > actually preemptible. I will drop this bool in this patch, and keep > the real preemptible wait condition in the later patch as: >=20 > preemptible_wait =3D task_mask && preemptible(); There is a lockdep_assert_preemption_disabled() so that preemptible() must evaluate false. Sebastian