From nobody Fri Apr 3 17:33:00 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 EC8F2317173 for ; Mon, 23 Mar 2026 19:37:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774294661; cv=none; b=M41hSgacV+NDtZmatuyG3Oh+4RA7qWO27R2F4y2QBj2+6A526YMpMcxMwp7x0G1hvMNvJEX23df5ErUKeM4jkU3WRU3X3w80mrJfFdBBST7ayIYErWsq+wRzbjzMArjLxNJ4+w8GMS5VWTFMsRW2sxKFPzwpX+/OfAIJ0pMYTzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774294661; c=relaxed/simple; bh=cOJ7Upq5ppEcCvR/VEdbHhF1LNKqRMxlhNaoeRRZuMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m4gdC1yU9ghjoIeSM/xl9i6x4opH9ZqVAPxFmIj1UjO25mJtHYNdg/CVaIMCW0oUuRMbo1XEAOYlN6cVMmA+uLRKD0xsvwkWcf8qOvN5wjMzbPxXa4Cxn+HDvHsnMi/iiNahl5TL++fjzwZAJPcb8BkkvsoeYIEbBEdoJopFmxg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=q2n8r9hV; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="q2n8r9hV" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62NDcosO092005; Mon, 23 Mar 2026 19:37:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=OeES18pEuNtpa7xN7 ShvPbG8O42+9pV/4FyefHehD+c=; b=q2n8r9hVun/s0A7HprfbYYtn4gI2sRuMU rqLLa43O5AKp7ife8Zy0tbEvz+rdHZ3pNi+p6PghxEs6Y1j5WhLFEbkvIlS3huur zqC8cLEN1R7MvBBwDYC+9nUWFpcPBnurVGqv8PlF1u1O62EgMSzWs47sNT8bHFRY 8yMo/rEoHSGjgYpW3pOCSMqpIeH64G7VEMcZ6IgqIDMAgptqWbYKIEMnVG3OHLBL UB5/uikSWqI8PqV0sX8LC/Lze9AhXqAAzLQzu6BOim3O9r8mYpXm6kPS97YDTs5b +TLxB8mja3zOt30Vw7xFKvLKQL4yDk9ao+zipbUBKlS/bX7leIFhg== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kw9reva-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Mar 2026 19:37:06 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62NGcJYJ005991; Mon, 23 Mar 2026 19:37:05 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d261yeucn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Mar 2026 19:37:04 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62NJb38m49217860 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Mar 2026 19:37:03 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB34B2004B; Mon, 23 Mar 2026 19:37:02 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 482C220043; Mon, 23 Mar 2026 19:37:00 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.24.217]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 23 Mar 2026 19:37:00 +0000 (GMT) From: Shrikanth Hegde To: mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org, tglx@kernel.org, frederic@kernel.org, anna-maria@linutronix.de, linux-kernel@vger.kernel.org Cc: sshegde@linux.ibm.com, kprateek.nayak@amd.com, juri.lelli@redhat.com, vschneid@redhat.com, rostedt@goodmis.org, dietmar.eggemann@arm.com, mkchauras@gmail.com Subject: [PATCH 3/4] smp: get this_cpu once in smp_call_function Date: Tue, 24 Mar 2026 01:06:29 +0530 Message-ID: <20260323193630.640311-4-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260323193630.640311-1-sshegde@linux.ibm.com> References: <20260323193630.640311-1-sshegde@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-ORIG-GUID: b3IKlQZjDTQkyBVXNzhhGV9PpttrSGHp X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDE0MyBTYWx0ZWRfXwey9TYiHH04w 7CNgIPuMZ+ouZqhqV64334cF6BcIF3hZdhESe2tBxrmEzk7UV+SRJmIHP8P2NUyux8W6UIYGX06 ThXFswfudhWiINeR2Za/Mn9jR7E/3rBWiTGF1fzDGBEF9VcQP69gjGvTKMKiwEElUb2t5Rbg6Sk RQStPAGJtrAH7EPMyE48Ji32gywAvMz6QLwrj9avAcoLrzvbMkvD3o6g5ihDmd6jmKKaEyYM+wD uqzR4ReO6ExtOB9iPzfuM8x/0lmTfdD7UWeewGM9mw6FXhiLjlgvFgzTGxukjvwfJ8Rm3Q7n9Cf y1E52VCTXSgmy73zyG0fu+Y1kuxf2LQyArvgEX2KazV2gHucNzJed2p6ys5mKmc4SR9UxN31hfx HGcyGiuNFLb8iKx0w1R2xCR64+3TxXqRE+lstcD5ST+kD3x9tS49JZthjnVqyO2Hnb921rBVEtj 4Emzb5R4sVXBkRRZYRw== X-Proofpoint-GUID: 9A7p2RRVwEQ5tQum5yMXKWtI3o_vts8O X-Authority-Analysis: v=2.4 cv=OsZCCi/t c=1 sm=1 tr=0 ts=69c19662 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=BobugZK_ifuu3kB8F8kA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-23_04,2026-03-23_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 clxscore=1015 phishscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603230143 Content-Type: text/plain; charset="utf-8" Calling smp_processor_id() on: - In CONFIG_DEBUG_PREEMPT=3Dy, if preemption/irq is disabled, then it does not print any warning. - In CONFIG_DEBUG_PREEMPT=3Dn, it doesn't do anything apart from getting __smp_processor_id So with both CONFIG_DEBUG_PREEMPT=3Dy/n, in preemption disabled section it is better to cache the value. It could save a few cycles. Though tiny, repeated in loop could add up to a small value. smp_call_function_single/smp_call_function_many_cond is called with preemption disabled. So cache the values once. Signed-off-by: Shrikanth Hegde Reviewed-by: Mukesh Kumar Chaurasiya (IBM) --- kernel/smp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index f349960f79ca..4c57104d1cd3 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -677,7 +677,7 @@ int smp_call_function_single(int cpu, smp_call_func_t f= unc, void *info, csd->func =3D func; csd->info =3D info; #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG - csd->node.src =3D smp_processor_id(); + csd->node.src =3D this_cpu; csd->node.dst =3D cpu; #endif =20 @@ -832,7 +832,7 @@ static void smp_call_function_many_cond(const struct cp= umask *mask, csd->func =3D func; csd->info =3D info; #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG - csd->node.src =3D smp_processor_id(); + csd->node.src =3D this_cpu; csd->node.dst =3D cpu; #endif trace_csd_queue_cpu(cpu, _RET_IP_, func, csd); --=20 2.47.3