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 F12A33DCDBD 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=1774294662; cv=none; b=F99arbnFIfWi9S22j9l/gD/038En5f76ki+KCc1UOAP2Eyqk4nmQp/pIahHjUja8PaKjAwiO+GCLAiUuvjfwNtD5U658qCQ90uClFFhK02xfJiZgeqlS6rlhTa+/Hfgd/hDtP5IjLWDNOxOVXG1EsDxu34p2vkPLVatUrCeWQLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774294662; c=relaxed/simple; bh=/mV7Ia/OmeolzUt2rk9SQddn6N6riVadAEwTGt4kgWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HToH4fxUHzHb/0aQzxvdWOP5VAZG35qBB4yZkmHk9LxOJpmuj9aSh77+DFwRnDbzXclXqDOeYzPGexrWhyC+Kd/yQfx6X/JHvba6z+6xLfuNsBqYqzgIGA06aD+7fCwFWMKl1OgTlWQ3uFynBRAQQBkCeg4nex55etBFQIARJo8= 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=pYBrSPt4; 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="pYBrSPt4" 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 62NIPg2Z1391689; Mon, 23 Mar 2026 19:37:03 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=pPxSfUCqrS85OgDMh p4pdPH+4XL0G6r2sGkWlxj4M0s=; b=pYBrSPt4VoW/DKQoZ9HefpDzoSJGa72W3 5f6y0jzLg/bfHaiORZDgJuFYxIJaSWIGYRkanm0TFhzEmEiqq1foJRp7YzayneBe 1Ida8sos+b/m49RU/zqPaaklREGhKpeUEilkfqcMgjUaSYE4s/4UQUL3P4Bss4nI KNVcodqD+AxwRSO9eCo2udElAuVYBUjVeItYTEWYxNKbJr9qagUJNMEAz9YdFd9C dFbUoW1HHBiU8npEF5ceBn6WOS7fzu74RoI3cxKy2vAw7l0MxNXMwNDsjTHZfObx sbrs+JsII7lIJBp24M5KGVNVOh6VOi62G6j0/lBrIBNGm6YdFEf8g== 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 4d1kw9rev1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Mar 2026 19:37:02 +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 62NGD3i5005969; Mon, 23 Mar 2026 19:37:01 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d261yeucg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Mar 2026 19:37:01 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62NJaxZl39453154 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Mar 2026 19:36:59 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A1B82004B; Mon, 23 Mar 2026 19:36:59 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 47F8320043; Mon, 23 Mar 2026 19:36:56 +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:36:56 +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 2/4] sched/core: get this cpu once in ttwu_queue_cond Date: Tue, 24 Mar 2026 01:06:28 +0530 Message-ID: <20260323193630.640311-3-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: Wk_CldTOdosdkue9j8qy2SKHZQeAiD8z X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDE0MyBTYWx0ZWRfX+VLellchgULf G0tCvZMOd26hfRxk0yrObKNODOHjbb861zRCmahoH5CyeAnmrLGho1ncKZQQawMEQEzi39JqV4S B6vxpQkTNfERtURVyIlIeIe5ViXq3mO/V8K2g80rmr6EXJSS3lIc9aKO9LbWH8p6l5Wa8ZsaH5f 10LUx1Bl87sKCdE4IJLOeQziJEh7HhI6f2tUDwpOTb6gLVZtURj7GudI/s67LSOSF5cU6SfRvT4 EEcZFwOVPgZnj4khGGrI6PyWYyUrdAE3gkLyk4FFMEx+lU/jrVWGs1102ZDsX0CgL0HLimJF/Ym QzMTLWYn3CP8DMwls+ff5C8UClHeR0gwppLTM3XzvDi9iwDqtwx2sAfAQXMLMhIl7nv2K3jbqin 5iG5JxJVrdug/l5v5IjTCVC7GiLU3n9UxVUA+kAsrJtfTSxGkkvfHq8kCPa+Pso2y9f6/UjQc0i 5cjfv0oL2apSaaPYHKA== X-Proofpoint-GUID: 9FvvVedCx6fW_lSSpdUhj1ZnoID26Ipl X-Authority-Analysis: v=2.4 cv=OsZCCi/t c=1 sm=1 tr=0 ts=69c1965e 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=wFM0gQBc-kvGGd8btegA: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 could add up to a small value. ttwu_queue_cond is called with interrupt disabled. So preemption is disabled. Hence cache the value once instead. Signed-off-by: Shrikanth Hegde Reviewed-by: Mukesh Kumar Chaurasiya (IBM) --- kernel/sched/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 49af425f6a73..14996c7a0a31 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3900,6 +3900,8 @@ bool cpus_share_resources(int this_cpu, int that_cpu) =20 static inline bool ttwu_queue_cond(struct task_struct *p, int cpu) { + int this_cpu =3D smp_processor_id(); + /* See SCX_OPS_ALLOW_QUEUED_WAKEUP. */ if (!scx_allow_ttwu_queue(p)) return false; @@ -3924,10 +3926,10 @@ static inline bool ttwu_queue_cond(struct task_stru= ct *p, int cpu) * If the CPU does not share cache, then queue the task on the * remote rqs wakelist to avoid accessing remote data. */ - if (!cpus_share_cache(smp_processor_id(), cpu)) + if (!cpus_share_cache(this_cpu, cpu)) return true; =20 - if (cpu =3D=3D smp_processor_id()) + if (cpu =3D=3D this_cpu) return false; =20 /* --=20 2.47.3