From nobody Thu Dec 18 09:26:27 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0FA3C41513 for ; Mon, 14 Aug 2023 15:08:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232702AbjHNPIe (ORCPT ); Mon, 14 Aug 2023 11:08:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232681AbjHNPIN (ORCPT ); Mon, 14 Aug 2023 11:08:13 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EDAA1701; Mon, 14 Aug 2023 08:08:09 -0700 (PDT) Date: Mon, 14 Aug 2023 15:08:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1692025687; 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=TtHT+J68I3rRJzRfHqk10FJonfgbAJ03Mdzrif1b1mU=; b=BltpUni2c9NXtlxUmSn/rU5QLNmNCkCQ+95EzRLKLBxLZqXGR0nO+j/Vt89bgi/KAiAGeI ReCncP2ZJtf5FySBPFmEgwYibwR7QKpFtdnqXHWS31ViJY5Lz7Pu2mTU6XHW51VJ8K7R7k sAAMqxlvmxl/iHWyuMi+MFyWFHYub1rSUtHYp3OoXMA960h02wIMMbQoIAKbXHP+oaVtzT t8j9wJY97xobW0YcTO2909r13XrERwfZRYCOZiae/9TFiVpdufDSVUIqST2Dhe+CoID0jN zNcO+qGgkUXkHAEM6rR9pP5o+2I3p2tSIMWhQyWfAlJ10NGE8JUen7oc1gTaTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1692025687; 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=TtHT+J68I3rRJzRfHqk10FJonfgbAJ03Mdzrif1b1mU=; b=rhCZn1Q39812hLfPld+vRtxYLmkpjGjuEyVfm5EogcT5fYUR1sxSLgyJl/YfIFFcOivAR2 0N71+Jcf71J5h4DQ== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched: Simplify get_nohz_timer_target() Cc: "Peter Zijlstra (Intel)" , "Joel Fernandes (Google)" , Valentin Schneider , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230801211811.828443100@infradead.org> References: <20230801211811.828443100@infradead.org> MIME-Version: 1.0 Message-ID: <169202568709.27769.1200732913266854235.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 7537b90c0036759e0b1b43dfbc6224dc5e900b13 Gitweb: https://git.kernel.org/tip/7537b90c0036759e0b1b43dfbc6224dc5= e900b13 Author: Peter Zijlstra AuthorDate: Tue, 01 Aug 2023 22:41:22 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 14 Aug 2023 17:01:24 +02:00 sched: Simplify get_nohz_timer_target() Use guards to reduce gotos and simplify control flow. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Joel Fernandes (Google) Reviewed-by: Valentin Schneider Link: https://lore.kernel.org/r/20230801211811.828443100@infradead.org --- kernel/sched/core.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a97eab3..6cda296 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1097,25 +1097,22 @@ int get_nohz_timer_target(void) =20 hk_mask =3D housekeeping_cpumask(HK_TYPE_TIMER); =20 - rcu_read_lock(); + guard(rcu)(); + for_each_domain(cpu, sd) { for_each_cpu_and(i, sched_domain_span(sd), hk_mask) { if (cpu =3D=3D i) continue; =20 - if (!idle_cpu(i)) { - cpu =3D i; - goto unlock; - } + if (!idle_cpu(i)) + return i; } } =20 if (default_cpu =3D=3D -1) default_cpu =3D housekeeping_any_cpu(HK_TYPE_TIMER); - cpu =3D default_cpu; -unlock: - rcu_read_unlock(); - return cpu; + + return default_cpu; } =20 /*