From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 6ABC4288B1 for ; Thu, 5 Feb 2026 03:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770263764; cv=none; b=jtVTbPxfDAUCFtdtlHMdObtvDJkDYJpf+kAfz114YClkrSZDu4YFflPk8+b47Y5ccSqa/6UMq9vLPKlZo3pTk4zjgUqH+bk/lODufnm07+7HQcHcoHXmzrmGhJWp03LJiU+huBTvSj4IFtYKUABI9R9YP88wBBCJr1BOgXrgIvA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770263764; c=relaxed/simple; bh=iwoNULU6NYIG2rv0XcZtCapFVHII9mrQCQEzjMH/7vk=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=SH0dIPFcYzvkOKxjJsn0mQJbGP3IdYBFbQem9aIg9VXtgv3RWhOQkZKmakA4V2/r4ltsF9AYzSFXGI9s8Z0lTdta8WWzb57swVt2pcJGDmz9kc7qOqUIfugmx+uBPw4em0o9VNiB0EHcdecoSL3moVFFBpbHTG4xYmsmWfPyu8E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=g58siJQ+; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="g58siJQ+" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1770263762; 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=V26hv3vsBAh6eJPmp9ZJfhhNlssjKRLfVpAomIxXJLs=; b=g58siJQ+dfqvVsBX1qJh1pajiJoty30PUGz/nHCJfnaKRegYXQcsJAf5K8awduKtlnaDPL aO+2KwryMU9Jaa8iJ/LbnhpJQtOcVz6Yr6d2pKUDtjwYi4MNgpJceXfQipigXGBaXUP0lO B0gldzZXm8ACfPlKgHm7vjCBf/8KlgA= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.300.41.1.7\)) Subject: Re: [PATCH 02/11] smp: Enable preemption early in smp_call_function_single X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20260203112401.3889029-3-zhouchuyi@bytedance.com> Date: Thu, 5 Feb 2026 11:55:23 +0800 Cc: tglx@linutronix.de, mingo@redhat.com, luto@kernel.org, peterz@infradead.org, paulmck@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <98F9F4CE-210A-4270-A172-7B5D59DD64B3@linux.dev> References: <20260203112401.3889029-1-zhouchuyi@bytedance.com> <20260203112401.3889029-3-zhouchuyi@bytedance.com> To: Chuyi Zhou X-Migadu-Flow: FLOW_OUT > On Feb 3, 2026, at 19:23, Chuyi Zhou wrote: >=20 > Now smp_call_function_single() disables preemption mainly for the = following > reasons: >=20 > - 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. >=20 > - 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. >=20 > 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. >=20 > Signed-off-by: Chuyi Zhou > --- > kernel/smp.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) >=20 > 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, >=20 > err =3D generic_exec_single(cpu, csd); >=20 > + /* > + * 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 ^ That looks odd. Why use a dash ('-')? > + * 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. > + * A blank line. Better to remove. Reviewed-by: Muchun Song Thanks. > + */ > + put_cpu(); > + > if (wait) > csd_lock_wait(csd); >=20 > - put_cpu(); > - > return err; > } > EXPORT_SYMBOL(smp_call_function_single); > --=20 > 2.20.1