Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2487933rda; Wed, 25 Oct 2023 04:26:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IET/ajEytVD2pQqIMGI8r91Om/UPZgaIqjzwK48eXbOzJ7pWIryH4Xv5wmTSKo/e1NkGqPP X-Received: by 2002:a05:6830:4407:b0:6ce:30ce:3c94 with SMTP id q7-20020a056830440700b006ce30ce3c94mr18972200otv.4.1698233164082; Wed, 25 Oct 2023 04:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698233164; cv=none; d=google.com; s=arc-20160816; b=pnm7E0VTFGWZQQ2QldlSdfs6NyXY7V/DdCeh1aI1n9eICJXdYkBcBuXOI1N8q7mb1+ d0CkC4Q+sjPfEjY2WolH6j9XNbSsTBoKUZFlhfh4hzA3xgaFO5u/tWMt5B/xTBUTKylB TABSm+wNReG4aMwRXavD+duoN+fdIytW37+5sx9qx/+G8grtCY5vTTLLWneMXscN/BnR PnGNR0JZaT1U+3F8KxMPDIdrqFX60IrQSNWoKLQLAaSbZHdETHl/NBMhvjGFzK2cFph5 jBqjVzCGssy2SEWpKk57yYm8jADIZlgJ+3vS3Equg8d+LpFysGUuWUz6pMJWMiSSZkgz J4gA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DZf3dHOoBhVs69Vo6IWZyOFS/Oza8gLR08XNv9kpeJg=; fh=I1pZsWGY/i1Gip8gktoKxOix+63hj3PPqvmC3YtcKcU=; b=eKCwn3KtP6/jxg9oyKRiknCdwid5kQhn7G9JmMzgQfoF+1EFCNv6CqHmXOCZG1Y4GH ud4pfHjdifUiLmnzij+/xh+rYt9w/ltw68ItQZPewi6DMJl9fzz/r7UQ9DgZi7HJj223 4ZNPC2JkLY6I0hE+BfUTe6mNGUpb2L372t6clIMBD6LpNa9xIwovN7bXRfRlgC8sDuLz DQqw0Za5dxIxhHBivdr5T2o5UyPgCt2NqjFTph6Aut9TeqN4Vl3qJPxoByX1llir6L+g h2BtRoxM7sEK7HNa50uj9Gt7zA0G2mbdksAlKrB7I5ZuPgxKXcQLWMxm6jSpjq7xXrS0 /thw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZGt+g5V3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k63-20020a0dfa42000000b005a23fed78dfsi10575019ywf.454.2023.10.25.04.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 04:26:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZGt+g5V3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D3A198078616; Wed, 25 Oct 2023 04:25:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234582AbjJYLZU (ORCPT + 99 others); Wed, 25 Oct 2023 07:25:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230217AbjJYLZS (ORCPT ); Wed, 25 Oct 2023 07:25:18 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00C7FE8; Wed, 25 Oct 2023 04:25:16 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00141C433C8; Wed, 25 Oct 2023 11:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698233116; bh=5uusWVbXG7Uj0EgQfGTXqjuq5lmrkasn/FKrRVX44Xg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZGt+g5V3Zl8EzuEQB/2XMI1bQKtETncmWYWEUQ0FEpbBG6M2SijVhsO2PvAkKhwlh C9u2aW5XQdYwdOAeTVnpZKWV2b+HQlyB8z6ZD42jahfYo9+5KniKu7rW8+0XaetlRK y/b7ioD3YA+om5644/nJ3XRucMPIdgFrvJJ5FFRtrkoQjDRIFsD7n1HBEntjfACtVS Ns5lgeoxDXnBaJWEAiFZsihJr4Y1hkTrmfJasFa1UK85QLYk5hANmnW1E/TbC3o4nR vZGjtttm66STNLOb9yhA6eVArcSoSFwhsUCTC/WDgirZDEWPBEGW/YqwjTOO+k47F2 3YBp932cghCCA== Date: Wed, 25 Oct 2023 13:25:13 +0200 From: Frederic Weisbecker To: Peter Zijlstra Cc: LKML , Boqun Feng , Joel Fernandes , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , Neeraj Upadhyay , "Paul E . McKenney" , Steven Rostedt , Uladzislau Rezki , Zqiang , rcu , "Liam R . Howlett" Subject: Re: [PATCH 4/4] sched: Exclude CPU boot code from PF_IDLE area Message-ID: References: <20231024214625.6483-1-frederic@kernel.org> <20231024214625.6483-5-frederic@kernel.org> <20231025084833.GE37471@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231025084833.GE37471@noisy.programming.kicks-ass.net> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 25 Oct 2023 04:25:29 -0700 (PDT) Le Wed, Oct 25, 2023 at 10:48:33AM +0200, Peter Zijlstra a ?crit : > On Tue, Oct 24, 2023 at 11:46:25PM +0200, Frederic Weisbecker wrote: > > > diff --git a/include/linux/sched.h b/include/linux/sched.h > > index 8885be2c143e..ad18962b921d 100644 > > --- a/include/linux/sched.h > > +++ b/include/linux/sched.h > > @@ -1945,7 +1945,7 @@ extern struct task_struct *idle_task(int cpu); > > */ > > static __always_inline bool is_idle_task(const struct task_struct *p) > > { > > - return !!(p->flags & PF_IDLE); > > + return !!(READ_ONCE(p->flags) & PF_IDLE); > > } > > > > extern struct task_struct *curr_task(int cpu); > > diff --git a/kernel/cpu.c b/kernel/cpu.c > > index 3b9d5c7eb4a2..3a1991010f4e 100644 > > --- a/kernel/cpu.c > > +++ b/kernel/cpu.c > > @@ -1394,7 +1394,9 @@ void cpuhp_report_idle_dead(void) > > { > > struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state); > > > > + WRITE_ONCE(current->flags, current->flags & ~PF_IDLE); > > BUG_ON(st->state != CPUHP_AP_OFFLINE); > > + > > rcutree_report_cpu_dead(); > > st->state = CPUHP_AP_IDLE_DEAD; > > /* > > @@ -1642,6 +1644,8 @@ void cpuhp_online_idle(enum cpuhp_state state) > > { > > struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state); > > > > + WRITE_ONCE(current->flags, current->flags | PF_IDLE); > > + > > /* Happens for the boot cpu */ > > if (state != CPUHP_AP_ONLINE_IDLE) > > return; > > Without changing *ALL* ->flags stores to WRITE_ONCE() I don't see the > point of this. Also, since we only care about a single bit, how does > store tearing affect things? > > Not to mention if we're really paranoid, what are the SMP ordering > considerations :-) > > [ also, PF_ is used for Protocol Family, Page Flag and Process Flag, > grepping is a pain in the arse :-( ] Indeed. Also cpuhp_online_idle() is called with preemption disabled and cpuhp_report_idle_dead() with interrupts disabled. As for idle injection in play_idle_precise(), the flag is set and cleared with preemption disabled. This means that all writes are in an RCU read side critical section that RCU-tasks pre-gp's synchronize_rcu() waits for. So I don't think we need those WRITE_ONCE/READ_ONCE. Paul are you ok with that? Thanks.