Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2413077rda; Wed, 25 Oct 2023 01:49:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGO+ECxETwswsZMTwJYAG9tEVN5pBOs8NfjvkX8MDtfGhXB12o3SnMIahRx6lOZSJXd+3u X-Received: by 2002:a05:620a:190d:b0:773:af20:43f7 with SMTP id bj13-20020a05620a190d00b00773af2043f7mr18189946qkb.54.1698223757768; Wed, 25 Oct 2023 01:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698223757; cv=none; d=google.com; s=arc-20160816; b=MV8MZzBJIV/7OsByXJK1FGPYWtVlNW5H4lQc5asi9Zv4iRRVpT2GJ9tNnMRAj+Hmkg 92A5YxAVbAUL5dJXrrVWzdEjZA+XhBhsECY/OcSjT3cS5gjYbZVAWon7LfWr1jeJsa3h AE1TEUiZn8foGARLyJpqamEyIrtNcMbZb2xFg/B/+dAfF8LmwdanK6a3/nY/BURUZKD3 vuJR1acI3J4wzxPahBHIznQqLpl76exveirhFz2RqFC/yGOrvy3vyxztzHe1iZL8arEq 8Cuqji38gt+9Fl4t5YuqLaOzMQWaa5PWZ6AK6Wi3UzD98O/pRDViLAc9TCx6ghuEyvNf ySIg== 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=F0PnvleoCLYlsWDIAZ9QRM9jwjwZHpt5kAYggTq8dSo=; fh=86R/B5V1ffp7aQTFiuDXK+N3IccKiOjkE1XjmUDAtCs=; b=oh8zqcYIEhfB+ILs3o6MInNIX/YjEjBiCieWVwX0MzdbsPKm3odq1gKJ1YX6fzwsT8 NJpTyGLbtS/s8XqIDjeyjIvBVmpd4k2Q1TTuyBRLKTDbBQQO6F8Ay54OjY/MIxxMBk92 1ewO0vG1MIXRffYciNb6xpnTwng0qdeRXfIjddu1Bg0yeBC6pl599bcBzCU1rv+f6mNN 3tGr8YEc9VdYuXeAXw5Su/pjJYyuCViABTGv5vtJXzgAuQ2dhN/UlECHPCrAQw8c/04Y 76hFmQxB0somAYHh3SuYk/hA9O0n28HzbrAuf5ca2q9prXgPTeZitFCou9SzykvGNKza 8K/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Wexg2ZNP; 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 Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id a8-20020a25ca08000000b00d818c131863si10255574ybg.605.2023.10.25.01.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 01:49:17 -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=@infradead.org header.s=casper.20170209 header.b=Wexg2ZNP; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id CC57E80F7F09; Wed, 25 Oct 2023 01:49:14 -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 S233904AbjJYItD (ORCPT + 99 others); Wed, 25 Oct 2023 04:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234582AbjJYIsy (ORCPT ); Wed, 25 Oct 2023 04:48:54 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B88EE1BB; Wed, 25 Oct 2023 01:48:47 -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=F0PnvleoCLYlsWDIAZ9QRM9jwjwZHpt5kAYggTq8dSo=; b=Wexg2ZNPC1rEOENJ/ysbmrdopg pzAAgfTFVUzYdpOZePb0gUzTz/hnc+XTqzneZpu4tXUs5yLz74QZyXxt4xWUGlkItlb3U3bJPtjxv IQziYYBSoGy++TgHmKwqR0Up98GmdlMwLNTCMsrvRjgcjxjw2VTvqOIbDiDh+KQxgCMjveBe3gRqN ARUDhybDMbWkfKj5e7SpcdN2Sk0Uy6u69rsb6kPL++cVZemf8vO2CaHS6kvXNwHZtdc92U1oAtpBB HaWKOgOtXvybTDjcrVN9Ihwe2TZxZlWSHcIlL0Kn2iqvEA8bFLSW8dgfJ4jxCo0bEI9X61r/cpgKk s3tyyYFA==; 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 1qvZZ4-007krV-8v; Wed, 25 Oct 2023 08:48:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id CF40430047C; Wed, 25 Oct 2023 10:48:33 +0200 (CEST) Date: Wed, 25 Oct 2023 10:48:33 +0200 From: Peter Zijlstra To: Frederic Weisbecker 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: <20231025084833.GE37471@noisy.programming.kicks-ass.net> References: <20231024214625.6483-1-frederic@kernel.org> <20231024214625.6483-5-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231024214625.6483-5-frederic@kernel.org> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 01:49:15 -0700 (PDT) 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 :-( ]