From patchwork Tue Aug 1 20:41:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 129508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp50608vqx; Tue, 1 Aug 2023 15:25:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlEc8rFaY9D+48VWiZ9XLP9TIZ62i7hh6OSGWlbHWqDkntFEVSP5m6WS7nZWfseITyGp7Atg X-Received: by 2002:a17:907:78c2:b0:99c:3b4:940f with SMTP id kv2-20020a17090778c200b0099c03b4940fmr3867276ejc.27.1690928746282; Tue, 01 Aug 2023 15:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690928746; cv=none; d=google.com; s=arc-20160816; b=oP3cbFVcnPly/Nlb/pWqZ/ZivW6XQeFRkpYpndb+PBMRLmstVE8vIZ/WCBWAOAzx0H Okv2xYgzWWzuxbSQP37YWHOXSt38JpLsXreKQ3xr79OEmZ2HOzfWMIoPKY/UvrglJu21 gL8whyt1ORoADuBwpv8flpqAO0oKve8U1vrfQaAgq67O0M0R2qjWmA0GD5EPsjgwk5O+ 5M9dJIDftbOczxuIhcl1+K56FXica1heUylqUFK3gk1PQNodhldruhX8V3bkSiqFyryj uDuhwsiL+KoiWbKS/7fSW1t5xj1qiXZQ9CFd31+54fd0AOQLhxHPuy9vhKYBDlQtE+XU aMQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=4+/Q1nIn7pjeaoOkqiN8ZoN9dOzRXj0Qx8pmucBG9KU=; fh=YNEt5Rwl98wFdDlZq5mCbJr8YZE8zeewTDacAVth8MY=; b=cAOTL7QFrhHN8TsPERUJY/kU4tUbDXbenmq42lVA8CF0tDUA38g69XN0mrlw98RvEI budXr+eVuIe177c0Gz0n/2krvA/JHtleBMrFdJaL49ElDOVNteib7xz7kltIGT9HqmkT WHrz6mYwQNc3ad23FmzDTHuUJDDrnYsXSuWxZc/j0ZGy4wqoolg1Rry9cxTGiEg6Gm6n rM+Lbyy3l+v7ArGNjpRmrsGpQWHe4m3EptKLW+W6ZQVC5L5rgd/yR13GXFpbJLwsXOk4 NlD51lt+iYELCeqp3/61nE0GSiyXXo2M9ScJhU/hcFzCXZBY4W88mAxFmCrkKuYAOEre O0mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=J8IHK9Ue; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n9-20020a170906688900b0099bcfd32960si6607263ejr.161.2023.08.01.15.25.21; Tue, 01 Aug 2023 15:25:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=J8IHK9Ue; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232565AbjHAVZb (ORCPT + 99 others); Tue, 1 Aug 2023 17:25:31 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773067301081785167 X-GMAIL-MSGID: 1773067301081785167 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 = false; - local_irq_disable(); - double_rq_lock(dst, src); + guard(irq)(); + guard(double_rq_lock)(dst, src); cookie = dst->core->core_cookie; if (!cookie) - goto unlock; + return false; if (dst->curr != dst->idle) - goto unlock; + return false; p = sched_core_find(src, cookie); if (!p) - goto unlock; + return false; do { if (p == src->core_pick || p == 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 = sched_core_next(p, cookie); } while (p); -unlock: - double_rq_unlock(dst, src); - local_irq_enable(); - return success; }