Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2678196rwd; Fri, 26 May 2023 09:36:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4aPJbjfcWI7kKD2m/0izGX8n/BBm+9BPpttdxu/ZpE06oAPrVmYb//52C1z2+jpBzyFNVy X-Received: by 2002:a05:6a00:2d84:b0:64f:52b1:a890 with SMTP id fb4-20020a056a002d8400b0064f52b1a890mr4227032pfb.34.1685118980831; Fri, 26 May 2023 09:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685118980; cv=none; d=google.com; s=arc-20160816; b=GfHLXi0gzvuYByMeeVB4r+5qcpzDLFN3cTyvH2D4gpgmJ8zv212ZqSzMRJRZ6nJZm1 OfNEEZR6E+f+E2xIUhGO3/wkhE7jhp/LCaL3tqDvTV0pW5ro/GKFYxhiuGQg1gvVF9Mv rSqKuVHiXjHrkORCrFBXwS3bu+dnhYk76DKRc8OkYD3FUTsUvuFKH1MP3hElMn8WxSdC K9EgY7UOOuupOrAgjXcLb4aUL4T+t5BJs6LvckPhk5JEZjnHC0ETlM8PICscpbYPVyx3 tF2N7TRpBHUpIUNJbPgLKpLOsFEP1cWNNh9kpMRfgH78ofr4MYUGlSuVqkOzfcg5L2uh oJiw== 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=fArHqZBRbAQ1CjgbRR/PDAdkqOTZF74/59ymwrkWP+U=; b=nbUPuaZJP5vxAUBRdODbtzkh+O0JH1Jd2RKGsEav01vnGM3DQ05miHbFdlHH/QyrWR 0eQWZppNxE8Cp4A6T975nmj/lNRzZljir5ahXZY+IkEqchRv5Eb88V8SyDRFulvznFB5 VGHwqECj8lLp5YuK9KL4qvbasSVbCVl7/E37Di+x0gSGXfuNhNcKdRSv2r5D46Dhrk9S klYr9YRYrhSSGiTrbPNU0+M2JOImCMN3NEpqo21zr+RLliFBHXHPK/fTtKMjWci6LlQj ur8KfoBwTHo+rjY7K5AaIlOPxBgIbK1HaNL6tzGvQJx+MawsfBz7mIGPlrufrlI7YOPk Q54Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u2zNb4Vy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i11-20020a633c4b000000b0053872f6398fsi128665pgn.472.2023.05.26.09.36.05; Fri, 26 May 2023 09:36:20 -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=@linuxfoundation.org header.s=korg header.b=u2zNb4Vy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229910AbjEZQ0E (ORCPT + 99 others); Fri, 26 May 2023 12:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbjEZQ0D (ORCPT ); Fri, 26 May 2023 12:26:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D509D3; Fri, 26 May 2023 09:26:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D783E60FA7; Fri, 26 May 2023 16:26:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D48C4C433D2; Fri, 26 May 2023 16:26:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1685118361; bh=LpCoyio+IAqUmLQDw7X6qQ4rC44Pv8G4ckdSGQizVQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=u2zNb4VyCo++/CYxbXwsjr9J0jCeZxwNfTKGgVmr5PrInZjwP16JlNuBPQBiLC1zm P6dqHdAoCnS8eD9VJzGryIs6LvBZAzUQyb1WWvj0jO7DOyoMpoFCmkx4QdOK7+nHER smhkniuJipNp91ka79qfEf4T7qtNnpkDFIddGjyk= Date: Fri, 26 May 2023 17:25:58 +0100 From: Greg KH To: Peter Zijlstra Cc: torvalds@linux-foundation.org, keescook@chromium.org, pbonzini@redhat.com, linux-kernel@vger.kernel.org, ojeda@kernel.org, ndesaulniers@google.com, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.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, vschneid@redhat.com, paulmck@kernel.org, frederic@kernel.org, quic_neeraju@quicinc.com, joel@joelfernandes.org, josh@joshtriplett.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, qiang1.zhang@intel.com, rcu@vger.kernel.org, tj@kernel.org, tglx@linutronix.de Subject: Re: [RFC][PATCH 2/2] sched: Use fancy new guards Message-ID: <2023052626-blunderer-delegator-4b82@gregkh> References: <20230526150549.250372621@infradead.org> <20230526151947.027972233@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230526151947.027972233@infradead.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 On Fri, May 26, 2023 at 05:05:51PM +0200, Peter Zijlstra wrote: > Convert kernel/sched/core.c to use the fancy new guards to simplify > the error paths. That's slightly crazy... I like the idea, but is this really correct: > > Signed-off-by: Peter Zijlstra (Intel) > --- > kernel/sched/core.c | 1223 +++++++++++++++++++++++---------------------------- > kernel/sched/sched.h | 39 + > 2 files changed, 595 insertions(+), 667 deletions(-) > > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -1097,24 +1097,21 @@ int get_nohz_timer_target(void) > > hk_mask = housekeeping_cpumask(HK_TYPE_TIMER); > > - rcu_read_lock(); > - for_each_domain(cpu, sd) { > - for_each_cpu_and(i, sched_domain_span(sd), hk_mask) { > - if (cpu == i) > - continue; > + void_scope(rcu) { > + for_each_domain(cpu, sd) { > + for_each_cpu_and(i, sched_domain_span(sd), hk_mask) { > + if (cpu == i) > + continue; > > - if (!idle_cpu(i)) { > - cpu = i; > - goto unlock; > + if (!idle_cpu(i)) > + return i; You can call return from within a "scope" and it will clean up properly? I tried to read the cpp "mess" but couldn't figure out how to validate this at all, have a set of tests for this somewhere? Anyway, the naming is whack, but I don't have a proposed better name, except you might want to put "scope_" as the prefix not the suffix, but then that might look odd to, so who knows. But again, the idea is good, it might save us lots of "you forgot to clean this up on the error path" mess that we are getting constant churn for these days... thanks, greg k-h