From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 1AF6E39B490 for ; Thu, 5 Feb 2026 09:35:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770284103; cv=none; b=WdzvsR9MMiQ//iO1DZ60kSySEuwzN44AkbiFq40U0WHjFu5cQqtlo+JkEbep6bMJ7C2yAJ+7gFAyZuAS4ipIP4E0iFabEMc1EY3dQyRpCO89+znpcILUVgHX2AXi8KOrk9qTQM1DzDcsQdFPlNGUmzh/+qvhblC3EPhtVMSGh0E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770284103; c=relaxed/simple; bh=4FKdKetIUUmPrJ+auiXbKZkmYiAW6H2sEkgB/P5SwNM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=icPmkMXIt9lShTx2kMmY+w7FckkMCnF+xIsmuT5PDogZxRah6w6pXypPt2finU6zS58hnZBtoC6CDebEMdw8UT++J1Rxnes/aKfvyvWrUnH5JiXrwE2dQDbVtK13W+mZs/CP8E9KNF5mzs8iUPDUSQNGFxRBFttIGmRuAJcqkCM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=vIYTiQHE; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="vIYTiQHE" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=sFyuuRR9nSLkyEk1CXJyrC5+VhjZefc/3dMeD/tNCHM=; b=vIYTiQHER//D5oHgVJzWpn0D7/ TKIhtdoHK9A4COpPZILrp1FQSvPsjcQaSzgrpfy13Rm5hjbC9KL+W8tQp4J1IPX1mb6fqyNeI/xHx xP+yXoZeBzeQ4CEBiYNEmnBmR0UWe++CoOghJnqTaRuwtXZHVVrODRuMXIfUEaCKanUl9EUnRuIV5 H+02UeEZNPXkudDtejdATptA+zqxQwqsihTwSq0bztIwGp1KzpEnquX5veHmlKAuJ1HgpkipeBP4c aCC7NsC630nNCOBB457GpL+TTdIMmsID0jH+WT6ihKm8VVT2ZBATc+0XYC2OfDWp4oX0+xlzkXFkt 2BPa2K+w==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vnvlC-00000003Pyf-2c9a; Thu, 05 Feb 2026 09:34:50 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 582EC300BD2; Thu, 05 Feb 2026 10:34:49 +0100 (CET) Date: Thu, 5 Feb 2026 10:34:49 +0100 From: Peter Zijlstra To: Chuyi Zhou Cc: tglx@linutronix.de, mingo@redhat.com, luto@kernel.org, paulmck@kernel.org, muchun.song@linux.dev, bp@alien8.de, dave.hansen@linux.intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 02/11] smp: Enable preemption early in smp_call_function_single Message-ID: <20260205093449.GE232055@noisy.programming.kicks-ass.net> References: <20260203112401.3889029-1-zhouchuyi@bytedance.com> <20260203112401.3889029-3-zhouchuyi@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=us-ascii Content-Disposition: inline In-Reply-To: <20260203112401.3889029-3-zhouchuyi@bytedance.com> On Tue, Feb 03, 2026 at 07:23:52PM +0800, Chuyi Zhou wrote: > Now smp_call_function_single() disables preemption mainly for the following > reasons: > > - To protect the per-cpu csd_data from concurrent modification by other > tasks on the current CPU in the !wait case. For the wait case, > synchronization is not a concern as on-stack csd is used. > > - To prevent the remote online CPU from being offlined. Specifically, we > want to ensure that no new IPIs are queued after smpcfd_dying_cpu() has > finished. > > Disabling preemption for the entire execution is unnecessary, especially > csd_lock_wait() part does not require preemption protection. This patch > enables preemption before csd_lock_wait() to reduce the preemption-disabled > critical section. > > Signed-off-by: Chuyi Zhou > --- > kernel/smp.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/kernel/smp.c b/kernel/smp.c > index fc1f7a964616..0858553f3666 100644 > --- a/kernel/smp.c > +++ b/kernel/smp.c > @@ -685,11 +685,24 @@ int smp_call_function_single(int cpu, smp_call_func_t func, void *info, > > err = generic_exec_single(cpu, csd); > > + /* > + * We may block in csd_lock_wait() for a significant amount of time (e.g., if the > + * remote CPU has interrupts disabled). Disabling preemption throughout the entire > + * smp_call_function_single() impacts the scheduling latency and is unnecessary. > + * > + * - Preemption must be disabled before sending the IPI to ensure no new IPIs are > + * queued after smpcfd_dying_cpu() finishes. > + * > + * @csd is stack-allocated when @wait is true. No concurrent access except > + * from the IPI completion path, so we can re-enable preemption early > + * to reduce latency. > + * > + */ Those lines are too long for no reason, please reflow at 78 or so.