Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2688470rwd; Fri, 26 May 2023 09:45:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ZhxWAFyTib1aFl3+ui5Mn856q6B4fWzpCJ+PNFKRhPQhzbGGXrmr2f2xBGxHYUU00QQ/F X-Received: by 2002:a17:902:7443:b0:1ac:9ab5:9d77 with SMTP id e3-20020a170902744300b001ac9ab59d77mr2904738plt.12.1685119525697; Fri, 26 May 2023 09:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685119525; cv=none; d=google.com; s=arc-20160816; b=RM3v8BldFVlpqYQnogXrbIuWjwwm/jOZOW1gdSm1/dIa0yOTXmpdURRrVVJvHNCF3A wIswZqHjFOQJYNx4aZzfq3kf/6AGc4Y5ZPjx8Z17UfgiE5QN2saS7OudYJU1RTynUGU6 9AnlCtVrr7ppkmbm/cm5UPU89Sg1ecsQXnza8TZiP6PpMEMeRnN45dUdT6trLnYttw+m pTGU1cSN24V8qh9E6J/dnJyO1ixT+r9v1W3njkU9TzKGZ508FwTV+0EwN62JzJxL41x/ hC6xoufCOrGtCNKZeZy6luY99xYe/YJpqdoB6zwKEX/NAkVLfZFtjS6+i9CqNYmPJrPE THOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=nmacQ5eqmQD7Vggo8ZFLe3QEXSXjxoqjQok6B/zXJek=; b=p/phVaUoMd1KYducSc0wQuGdkgpwhWfUxBvf2HWnKnkqaJXNqNU5FNVR/aSvQ+Z6D1 2hiL2Fg3L5eYnY9X3jnNNIxeKCDUY8gqvLaQOuCGyv4JrH1Dzatg2M25XU8vM9BHHHgE E4imZdNRSjCgS+7xu2537yhcXUERjjYDphJB8iBzzFHW7ysv6dqqzooDwCRgxRDh8vAb JlaShrudolf0pRPtUY8cpYnLDiMBVX/n6iTQFm2+iXmUimAPCPOZEsbLknS+pNRMaa7U +j3MebdX1SfvjfqSeEL3TIhc1nK0hWrv1FnMFcogNutB3Fd3k4vAp7UhHaYChDfw5rO4 45bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=WH+9Dt9I; 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=efficios.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 200-20020a6302d1000000b0053489d58e12si1870165pgc.772.2023.05.26.09.45.09; Fri, 26 May 2023 09:45:25 -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=@efficios.com header.s=smtpout1 header.b=WH+9Dt9I; 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=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229981AbjEZQ1z (ORCPT + 99 others); Fri, 26 May 2023 12:27:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbjEZQ1y (ORCPT ); Fri, 26 May 2023 12:27:54 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2BA5BC; Fri, 26 May 2023 09:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1685118470; bh=53Ui1FacFGLMIwxIRV2cMJLHjiRqHs6B8HmABbhs+ok=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=WH+9Dt9InAm2ndwOMg6kV+/mrTfRoUe1yE4vvSuYItQNeK0QnIfP5TT3mblSN5BK3 d2DpBf8Epv0tZyrlbNet456RlhOhwVIM0LGsRdfcZd8Fz790NTHtjFGRkdy3O0ax1R OU2QgzJncJ+jXDLlh1U5V05uTEWwRObdEcAkbr+p+7iwMu/fBKEqNc0LqwRMNpcXfi C7yJ6yXPVVkizuOeQuXtM8u56xFAYA1mDZaO8Hmp9nxqPq104iSKRYpbQTlDMnpQV2 3Y5/k5zmn74yt3PvWIIz6G7HDOs4PK6FLr4I9tuCdxPbKraaHzFyqzI8PlaZGzFaql 3xGLWcxGDmZNw== Received: from [172.16.0.134] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QSVhP75bxz13hj; Fri, 26 May 2023 12:27:49 -0400 (EDT) Message-ID: Date: Fri, 26 May 2023 12:27:51 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [RFC][PATCH 2/2] sched: Use fancy new guards Content-Language: en-US To: Greg KH , 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, jiangshanlai@gmail.com, qiang1.zhang@intel.com, rcu@vger.kernel.org, tj@kernel.org, tglx@linutronix.de References: <20230526150549.250372621@infradead.org> <20230526151947.027972233@infradead.org> <2023052626-blunderer-delegator-4b82@gregkh> From: Mathieu Desnoyers In-Reply-To: <2023052626-blunderer-delegator-4b82@gregkh> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RDNS_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 5/26/23 12:25, Greg KH wrote: > 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. FWIW C++ has std::scoped_lock. So perhaps using a similar wording may help ? Thanks, Mathieu > > 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 -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com