From nobody Wed Sep 10 09:25:00 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 91530C04A6A for ; Tue, 1 Aug 2023 21:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229725AbjHAVZc (ORCPT ); Tue, 1 Aug 2023 17:25:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232078AbjHAVY6 (ORCPT ); Tue, 1 Aug 2023 17:24:58 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C77F2707 for ; Tue, 1 Aug 2023 14:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=4+/Q1nIn7pjeaoOkqiN8ZoN9dOzRXj0Qx8pmucBG9KU=; b=J8IHK9UeVvDpDEqjIjdyb+ueyD MZu72D5VRlzK2tgFk6E2Q19XNTvN6w4R97+txCz5/kQUErEhc2yg8x/4L9rokdCMEfx4NHRRpIjhh BmupbnZfuzBBcOzvXYkmurDDQkqYJVR+7bqQqWfeszzL94RmSahcvlCY0sz71Hu3ShBcJmRn4HVIW oGqKaY55edDIPUaXUF0TKedyjgYdxXvApczceNkZD6d2Nlc7uS47doikWbWyqjHJnIhPCUlIvhs5b JHQUnCDYksFwdhUdRC8afFXVARdY0EHUsRoFgfPKWRw6tgUQMNnYUYoByV+O2zkAEZavOIg2Ys3Xh FHwmGJMg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qQwqn-00EvTt-1a; Tue, 01 Aug 2023 21:24:18 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id BEDEB302781; Tue, 1 Aug 2023 23:24:15 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 5713220286FBA; Tue, 1 Aug 2023 23:24:15 +0200 (CEST) Message-ID: <20230801211812.304154828@infradead.org> User-Agent: quilt/0.66 Date: Tue, 01 Aug 2023 22:41:29 +0200 From: Peter Zijlstra To: mingo@redhat.com Cc: peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH 8/9] sched: Simplify try_steal_cookie() References: <20230801204121.929256934@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use guards to reduce gotos and simplify control flow. Signed-off-by: Peter Zijlstra (Intel) --- kernel/sched/core.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6229,19 +6229,19 @@ static bool try_steal_cookie(int this, i unsigned long cookie; bool success =3D false; =20 - local_irq_disable(); - double_rq_lock(dst, src); + guard(irq)(); + guard(double_rq_lock)(dst, src); =20 cookie =3D dst->core->core_cookie; if (!cookie) - goto unlock; + return false; =20 if (dst->curr !=3D dst->idle) - goto unlock; + return false; =20 p =3D sched_core_find(src, cookie); if (!p) - goto unlock; + return false; =20 do { if (p =3D=3D src->core_pick || p =3D=3D src->curr) @@ -6253,9 +6253,10 @@ static bool try_steal_cookie(int this, i if (p->core_occupation > dst->idle->core_occupation) goto next; /* - * sched_core_find() and sched_core_next() will ensure that task @p - * is not throttled now, we also need to check whether the runqueue - * of the destination CPU is being throttled. + * sched_core_find() and sched_core_next() will ensure + * that task @p is not throttled now, we also need to + * check whether the runqueue of the destination CPU is + * being throttled. */ if (sched_task_is_throttled(p, this)) goto next; @@ -6273,10 +6274,6 @@ static bool try_steal_cookie(int this, i p =3D sched_core_next(p, cookie); } while (p); =20 -unlock: - double_rq_unlock(dst, src); - local_irq_enable(); - return success; }