From nobody Tue Feb 10 04:03:02 2026 Received: from sg-1-103.ptr.blmpb.com (sg-1-103.ptr.blmpb.com [118.26.132.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA2852EBB8C for ; Tue, 3 Feb 2026 11:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.103 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117940; cv=none; b=Qk4gSWEuRPPKOUvMId7+sAz0OwOkeXdOnut6yWkZDD9WjJqM6qBNIasGdcu3/30ThWDli8XwcWs8OR0JAmCqRPrkQS6lAVvhM1Sn8gjtdc97mx+ZJfisC+yMS0iqCn1weNp0v8UaJrbmqZH79KuJt6eTGdMog6DW4mn3vi1zqps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117940; c=relaxed/simple; bh=kCM9zucjuCqSks7fkVhukFz8iheuhxebqX42L1Gy6tw=; h=Mime-Version:To:Cc:From:Subject:Date:Message-Id:In-Reply-To: References:Content-Type; b=P+1rUeL/S8LssXfVv8be675z1QVgU5V+wxeJ+wGFduQrjYhIxxRvKicSQJ+/lYMth7/6VPdE8l0yzaeDj/BzI7ZVDFc8U3lL9Ayoa2bwETassvWZSiZxN1AOzYmKct7mnJQ1Oc2w6cMUQmovLtxE06X3aCK77SBzineNbTVCU+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=FRX7Cj8K; arc=none smtp.client-ip=118.26.132.103 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="FRX7Cj8K" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1770117933; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=LjNvt22VDEvMny3UgZSQXODsa5cYAdKdWzoXfyN2sc4=; b=FRX7Cj8Ktdk6P2tpvurVFEASyHLgvq+KCacRZj5Fm0Sk8KWqqncpxUYPGacLI7HD1ANuHN 1obBUzGGa7z7k2hmRkRhF8cuRhpvfgvfpoIAdG5DrprcLRBwmK9Pingt7Is31FOkdsAjGA F8AxPUeoYCHm2Xfb9Kn/C0EtrlzAKJrbfCyWDswZTs5prpMWGqNV8ZUs97y0m+mnl8b3vQ aG9UOphascfIzsVpljfJrlMRAj3BbVOKsR+soda+rH8h22g6r+Qv/aqTZxgHI22/qAY7oC VfFHDGYV3d28Hhlud1ZSvfwhCiPjIr1lpcj3yvLDYJrvEoxOusYpr8KQOBi+MA== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.20.1 To: , , , , , , , Cc: , "Chuyi Zhou" From: "Chuyi Zhou" Subject: [PATCH 03/11] smp: Remove get_cpu from smp_call_function_any Date: Tue, 3 Feb 2026 19:23:53 +0800 Message-Id: <20260203112401.3889029-4-zhouchuyi@bytedance.com> X-Original-From: Chuyi Zhou Content-Transfer-Encoding: quoted-printable In-Reply-To: <20260203112401.3889029-1-zhouchuyi@bytedance.com> References: <20260203112401.3889029-1-zhouchuyi@bytedance.com> X-Lms-Return-Path: Content-Type: text/plain; charset="utf-8" Now smp_call_function_single() would enable preemption before csd_lock_wait() to reduce the critical section. To allow callers of smp_call_function_any() to also benefit from this optimization, remove get_cpu()/put_cpu() from smp_call_function_any(). Signed-off-by: Chuyi Zhou Reviewed-by: Muchun Song --- kernel/smp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index 0858553f3666..f572716c3c7d 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -772,13 +772,18 @@ int smp_call_function_any(const struct cpumask *mask, unsigned int cpu; int ret; =20 + /* + * Prevent migration to another CPU after selecting the current CPU + * as the target. + */ + guard(migrate)(); + /* Try for same CPU (cheapest) */ - cpu =3D get_cpu(); + cpu =3D smp_processor_id(); if (!cpumask_test_cpu(cpu, mask)) cpu =3D sched_numa_find_nth_cpu(mask, 0, cpu_to_node(cpu)); =20 ret =3D smp_call_function_single(cpu, func, info, wait); - put_cpu(); return ret; } EXPORT_SYMBOL_GPL(smp_call_function_any); --=20 2.20.1