From nobody Fri Apr 3 10:19:24 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 4C7F43D6CB3; Tue, 24 Mar 2026 09:10:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774343405; cv=none; b=CsqPh3wypZhA+mxM+3/w+YClyXAPp4ONlzerY4K1SFtBqJLPYEU6Q8WXDLRZrH/MwTujx8ng6LzAkDThkNIMkSZQjB+m94JvMoouNf3zgf48rvwO4Srb1UM4XiJS252u+Jem5GqN6wMQHC1wkBtGi+5Ii+8dhGPascVaiuSz1zU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774343405; c=relaxed/simple; bh=Zegj080Q2ljdmjlKOX+1eJkix9YIptDL/Fnu/2Gfzxc=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=T+IocpKbmnxy5gRa1j45oY8PuTk7Q5+b3YUUPcOBog6CouHIWlNV6HHKAFSJEwdOnHxN+7Dcle/amqVxWeV94IIt80T50Jqrp5pkGJVEReJXmmLl1ZnwLkdKHAHtECiFZtrL+8EHcKKrjrTpmmqT2AGBQmhHDjlMN8AUNOiyzSo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Yp27kvap; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=LJv1jBl6; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Yp27kvap"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="LJv1jBl6" Date: Tue, 24 Mar 2026 09:09:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774343399; h=from:from:sender:sender:reply-to: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=CIdCbPVtyl6+8ds3nFygp3VNvJrPWIcb2UE9Lq0OJos=; b=Yp27kvapzBqFNqWkOas+SH92TVnWwCtmjGXlgVvte4idAf+/yKFxcR4HjTMNYzI6lYBqTa sX6cUI0kFq3F1onOy4CwCY4wfE8hMveKvs43o4en2QNnoAjNt0/idJ13YVVFH9SFankhgE urMYymSqLHBNkTh9CPkKPZq+na+XeXv0XxZao4y1KJid5T+hMOFWUuKXXXkFkowHLTen/Q PdlXXxpxafgJoICUUivIbzGDc7ogNbmVzko1n6ew3AMBHg8+lUr5NjZDA2/+lINZX+KOb+ T3AjrF61rbF5ad3VDG9EEYCRwc0vRhGmIp0twvfD7g7OfXXFM7jqxXQDxEq8DA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774343399; h=from:from:sender:sender:reply-to: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=CIdCbPVtyl6+8ds3nFygp3VNvJrPWIcb2UE9Lq0OJos=; b=LJv1jBl6+vi8IlUoptL+hLyAmvAVMq/Wo4J7xJ/TG9NlCLQjuKNNNwzBCUISlGTcv1VBzK Iwo62vikU9ZQVQAw== From: "tip-bot2 for Shrikanth Hegde" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/core: Get this cpu once in ttwu_queue_cond() Cc: Shrikanth Hegde , "Peter Zijlstra (Intel)" , "Mukesh Kumar Chaurasiya (IBM)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260323193630.640311-3-sshegde@linux.ibm.com> References: <20260323193630.640311-3-sshegde@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177434339777.1647592.8734197736725256406.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/core branch of tip: Commit-ID: 0e81fe79fec5a639700f09f39c8ab680c3312ba2 Gitweb: https://git.kernel.org/tip/0e81fe79fec5a639700f09f39c8ab680c= 3312ba2 Author: Shrikanth Hegde AuthorDate: Tue, 24 Mar 2026 01:06:28 +05:30 Committer: Peter Zijlstra CommitterDate: Tue, 24 Mar 2026 10:07:05 +01:00 sched/core: Get this cpu once in ttwu_queue_cond() 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 Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Mukesh Kumar Chaurasiya (IBM) Link: https://patch.msgid.link/20260323193630.640311-3-sshegde@linux.ibm.com --- 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 64b467c..7c7d4bf 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3842,6 +3842,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; @@ -3866,10 +3868,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 /*