Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp249166rwl; Wed, 9 Aug 2023 14:02:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGg1P0IpNO/a+Uz51Uhl5y2kDmpPxUNxJHRAg5olzL48QC3BMsvG/yUH4L6u45q9sC3ZF0G X-Received: by 2002:a9d:6c90:0:b0:6b9:a926:4a12 with SMTP id c16-20020a9d6c90000000b006b9a9264a12mr191810otr.28.1691614937543; Wed, 09 Aug 2023 14:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691614937; cv=none; d=google.com; s=arc-20160816; b=V1GUDu3cm1WgPZiRSZZNEvxTbOpDsiQUiEX/w/6EVnwk36oGJeOunU88/MWLTclMf3 3eGDSMBEO+3SRu/rDxOlytKVhIEsKkNLFVV9BUks9l4REGbw2sTSJsuELzK0iSdrrNnI u2sce8rdSPTQZBhU2NZ8xDKouBwFckUq6G8E4rInM2DFQDjkTEX8DnJREunlJmGoCKyr PtBvnm+sE+Y4Ls1ium5WovJmw5c/3d4eAOVxM4/qiA41yWWGJwhAxKYzVJCMC5EWj+PD YRmfHT2OLC4P9jNxQHE6/+w6INN9P0BYgAc8lca2wP+sqiKJAySFmhBMkJZ3p4xtbQbY nLVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MYkVGxmZ/pANXkTEfnBsfoFOl4UNWaG54/QZoH4GA6w=; fh=U4C6wsYvEhXTtp5p31foIwVO34zYIhW5J5HjKN5TgJo=; b=uB6sbHpCFFpykEi2aPRHPR8eHmzZsPU4Y4rQq/Pkim4fKTxJml5nVGGBPT73foPsmw /k11VaK7Z2oqVnLZ2FbgHZ67jOEDTjWzRNH/gBowhN76qU+IyVpQcvrFIP2mRbJVVSFO Zu88x4MpPdVefzJkepTki2VJ1s+937JsEhOqm7+d1XRAGeXEHQmKXp4eKoo0SKIg/FBS qK1OdA2GShkJH3kRsqj0vzWo6kHCdMHEkvOcYjiFdpFKcgMq/J9QfV94MdTWBPRge/kg Bmw2cgEWlydfdVGQJNw9WN4CtDCAjPm3xrZJKn2ZY0UxrknS0Y2Bxt9peVyi18Uu0iT0 sigw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=OLnm7Snf; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r32-20020a632060000000b005652a295669si51668pgm.490.2023.08.09.14.02.03; Wed, 09 Aug 2023 14:02:17 -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=casper.20170209 header.b=OLnm7Snf; 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 S234007AbjHITdE (ORCPT + 99 others); Wed, 9 Aug 2023 15:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233896AbjHITdC (ORCPT ); Wed, 9 Aug 2023 15:33:02 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18C6E2D6A for ; Wed, 9 Aug 2023 12:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=MYkVGxmZ/pANXkTEfnBsfoFOl4UNWaG54/QZoH4GA6w=; b=OLnm7SnfIZTITV+gk7hzegclmH YRrBXfNWJGlVwQ2JC+B8gR5aChtF748Ks72C5c9gsyFhR/o7GdD/G1DWAwa4lBf8xmLFoGxQ9+Dds q8xxi6b8ZesefUUd3JrEZqZNdzEyxyzW70UBUHDp4KVbhEBTxmCfVBrnugrg+snoquntIVj+lENzC ZTSnnT61HPWjpHCtyCrtjebvsDFTIX+gyOPOxKyfWsd2XcVE7FN2w4wYhUc74dbmtCZjk+xa8bnWk VIr1/0Tbka749fYH1XZi9rNUUxrlyo6K9ZDm6umDNqoCrf83hCVqV32CupLf/QQhE1ZqNvpO1xDia irDZUoww==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qTopY-007zcv-VT; Wed, 09 Aug 2023 19:26:53 +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) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 2BD8330026C; Wed, 9 Aug 2023 21:26:52 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 11FEF2023C23F; Wed, 9 Aug 2023 21:26:52 +0200 (CEST) Date: Wed, 9 Aug 2023 21:26:51 +0200 From: Peter Zijlstra To: Valentin Schneider Cc: mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/9] sched: Simplify ttwu() Message-ID: <20230809192651.GU212435@hirez.programming.kicks-ass.net> References: <20230801204121.929256934@infradead.org> <20230801211812.101069260@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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,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 On Wed, Aug 09, 2023 at 04:21:36PM +0100, Valentin Schneider wrote: > On 01/08/23 22:41, Peter Zijlstra wrote: > > Use guards to reduce gotos and simplify control flow. > > > > Signed-off-by: Peter Zijlstra (Intel) > > --- > > kernel/sched/core.c | 221 +++++++++++++++++++++++++--------------------------- > > 1 file changed, 109 insertions(+), 112 deletions(-) > > > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -3706,14 +3706,14 @@ ttwu_stat(struct task_struct *p, int cpu > > struct sched_domain *sd; > > > > __schedstat_inc(p->stats.nr_wakeups_remote); > > - rcu_read_lock(); > > + > > + guard(rcu)(); > > This isn't strictly equivalent, right? AFAICT that pushes the > rcu_read_unlock() further down than it currently is - not a big deal, but > indentation aside scoped_guard() would preserve that. The full hunk: | @@ -3706,14 +3706,14 @@ ttwu_stat(struct task_struct *p, int cpu | struct sched_domain *sd; | | __schedstat_inc(p->stats.nr_wakeups_remote); | - rcu_read_lock(); | + | + guard(rcu)(); | for_each_domain(rq->cpu, sd) { | if (cpumask_test_cpu(cpu, sched_domain_span(sd))) { | __schedstat_inc(sd->ttwu_wake_remote); | break; | } | } | - rcu_read_unlock(); | } And you'll see the guard goes out of scope here ^ Which is the exact place rcu_read_unlock() was at, no? | | if (wake_flags & WF_MIGRATED)