From nobody Fri Apr 3 17:32:59 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 07EF83A961B for ; Mon, 23 Mar 2026 19:37:44 +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=1774294669; cv=none; b=pnztwjrQN6ybufTwzrEUIn0gsASESSglH5b1E3PffVs4xvcQ35/rwk+UeinYwpztnaD4TGnfMSXh5pjGaeJPyi/w1ggvaDiZjVoL9frX/tRUhL5xQ8JGi4VI3wxx3LruddeCFkzJn9/1pDkL5hs/Rwo3cpG8+NuEozybV9j36EQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774294669; c=relaxed/simple; bh=93qNSQmwtYsKcYq4sOnWr++2POgpg8x9gI8eeiuXms0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pL6cQV3jJP56rah4CqJPObePvwNpFtYtEPY5cdjXZaR2oAmPjo/DC8ILhpR+IyWVFiL/7QgKPE+4+ReGRMuUqO1645VtKs9zE8ybkCrwu7vHaNsbzNEjcb4Khw/VZDW1IvceBuzfpOo353kSIMaz6mJ2yqexZjefG9jOQvEzoJ4= 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=N/B8tU+H; 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="N/B8tU+H" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62NBDtsG3679602; Mon, 23 Mar 2026 19:37:10 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=uIHdjb/zUE/zJuTP9 x3NXHgG3Hnu4KSptzLWFWnvdkU=; b=N/B8tU+HNSEjlyiptQwoGB1v7tHdkftcL frDfnE2nEbIiWBHDEkL+IHOkus0pY5jRH5yTFRiyStt590U9RT9H1jIbqCP5XACT u6jEkzM8RRei6NF5PVfvJ7g8bK+sWeYkL307Ds3ziMQrpy7ysDjnhlkal570620r q+xrsaSFxGHeonXatBentw66p1UHuRE4GkKuY4CrAFhnTCqUeRmo6qEtvFPEENFN d0AXDRBHWBnz1CoHxq0eIanB/AF/l7yFl4pn/2gozJzDBNZzu97odzfUH30dEb1Y 6wsAA+gGZgmUMmMQ9KBgvlVWZi/qPTe+FmmfWmAUyfpJNtVTVIZfA== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1ktxretu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Mar 2026 19:37:10 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62NI5mq2004398; Mon, 23 Mar 2026 19:37:09 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d28c1xfjf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Mar 2026 19:37:09 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62NJb7La50987286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Mar 2026 19:37:07 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5933C2004B; Mon, 23 Mar 2026 19:37:07 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5FA6320043; Mon, 23 Mar 2026 19:37:04 +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:04 +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 4/4] timers: Get this_cpu once while clearing idle timer Date: Tue, 24 Mar 2026 01:06:30 +0530 Message-ID: <20260323193630.640311-5-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-Authority-Analysis: v=2.4 cv=IqITsb/g c=1 sm=1 tr=0 ts=69c19666 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=BobugZK_ifuu3kB8F8kA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDE0MyBTYWx0ZWRfXzDioJbgbjrgd kpMkZmu0ueFi7we5igkmFBbeQR2nVQBfBEnWPeNbZ2Qe8RMJ93y4TsmZE3caD1Rgxs9enP/RMO1 yPkO4S7+A5eG43QFQ5E1KTdJFbVG2lfSUH0zg0Ch1sLiWpphzG8qbV5SNJ8bVx/+gBdgUcWWLhY vXsHBLlrn5XCVVtH0VVTlgBoHvSb/Pwyf402mx3PyIIFWKCPLyp7KBVVnDr6VqosBI1nTuccRSv 3IYiY1pvkWSeyZ/57WlLYM9jKjlI9qYBNbVMNZ7s+ejLCSPXNABQNkETj1AVhy3KLUFDe5xuszS Li1T8VJr72X15M/dMzDfSs5KJ+l6RGPa3SeknEJ84e9kVk8ktgtlMonHXWsEiOEv0IlkSBCwvV1 dHwM9kQDs88iweMA4X9xj3B9IxLK0d5hNrSXeTsvi+Fm7GNWr96rUi4XxYOFocv/5zvyej2QwiJ SUZ+3XzJYuwAIKADhGA== X-Proofpoint-GUID: 5KnWRMH25XCFhjPRXmidPkngu30zKObH X-Proofpoint-ORIG-GUID: yFnMa2li9e7R0GP7iulTpaeZQj_4PhV- 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 malwarescore=0 clxscore=1015 spamscore=0 impostorscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=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 could add up to a small value. timer_clear_idle is called with interrupts disabled. So cache the value once. Signed-off-by: Shrikanth Hegde Reviewed-by: Mukesh Kumar Chaurasiya (IBM) --- kernel/time/timer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 7e1e3bde6b8b..04d928c21aba 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -2319,6 +2319,7 @@ u64 timer_base_try_to_set_idle(unsigned long basej, u= 64 basem, bool *idle) */ void timer_clear_idle(void) { + int this_cpu =3D smp_processor_id(); /* * We do this unlocked. The worst outcome is a remote pinned timer * enqueue sending a pointless IPI, but taking the lock would just @@ -2327,9 +2328,9 @@ void timer_clear_idle(void) * path. Required for BASE_LOCAL only. */ __this_cpu_write(timer_bases[BASE_LOCAL].is_idle, false); - if (tick_nohz_full_cpu(smp_processor_id())) + if (tick_nohz_full_cpu(this_cpu)) __this_cpu_write(timer_bases[BASE_GLOBAL].is_idle, false); - trace_timer_base_idle(false, smp_processor_id()); + trace_timer_base_idle(false, this_cpu); =20 /* Activate without holding the timer_base->lock */ tmigr_cpu_activate(); --=20 2.47.3