Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp984198rdb; Fri, 20 Oct 2023 05:31:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7q8gVaIaRSlTam6EomD+s3JolvwGDMwOQSWJUREtA7pPG0AWxKyclxEhRpjjRDwpMVNHv X-Received: by 2002:a05:6a21:4843:b0:15d:d73e:e398 with SMTP id au3-20020a056a21484300b0015dd73ee398mr1373775pzc.16.1697805089776; Fri, 20 Oct 2023 05:31:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697805089; cv=none; d=google.com; s=arc-20160816; b=XRxZHh1hwYsfWG9gl9xeRKe7hb7AFUH+ce4o1dTrBCnLt7XUp/mZPNNTVdpOrhOSQf XaqenhfJyRbrqhqZRNK4R4JvO+yzXzYigqGDckVH88ImdTUnt78s+Ba+FIrQFKhRBAeh /eqOHABOxE/n37nP3XFGagnlNj5A9yaOl9lvRdYWYkKCOFs8M6boSLUauA7+RpQWw1pP yCiyVh4WdZnyObky+yo4Ncu8D3bQkq+t7Goxkjj/Yct9RhIjKIGgN/YeBNzXADDgmzmq eCkp/sdPQzh7yYU+CNHMi0wnlfmNE7oQl1a5RhV8jU8ZUiha6Qz52nGio3xfHN9bdIsO Nlhg== 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=GAnVga9Uh8B1RHowRMGxTOcd96GsTA5IX6TQZ2KCcFU=; fh=PrMnVg6GPEJbj37GlGngePC7Udz0yBuLVYFFKr61S6I=; b=LDla/Q/wLqXkQws0Cz6/zrHA6ocKGMZi/TXQKSvlAFy4iGMmP/vLRvnkbMJypVswcD 2chAYZoJRGGepXqhhuO9Lwl58QI6zW1cYjHdm7KhKhCgGBHHQ6+zX1dl+VMjjN2/POyd KESvJXuOTDVWnPUO8qdRT5hme8AEowwFYT5UayxRd8zxw4exziZq7Syl3DHYCZaJgas1 64uYRAqPERdbRKa4DXuvE7juhpn+M60vYocGROR6n5LmTgWJcIV169r5BirQWGAfuMhS OqgbzWEolR81sGCDIHzFjwToTbRqCx1RGbhpUmHzIoGp1p4z59+K6+qXYFosnWC4M8xp Hw+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N23TIUJ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id cb12-20020a056a02070c00b005855e5e2f98si1945882pgb.75.2023.10.20.05.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 05:31:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N23TIUJ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 C7F5983AEFFD; Fri, 20 Oct 2023 05:31:26 -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 S1377284AbjJTMbU (ORCPT + 99 others); Fri, 20 Oct 2023 08:31:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377175AbjJTMbT (ORCPT ); Fri, 20 Oct 2023 08:31:19 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E37FD49; Fri, 20 Oct 2023 05:31:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3265FC433C8; Fri, 20 Oct 2023 12:31:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697805076; bh=TnUgXdqyGtzm8E1Kiu/VhELFbSOgtUP7stBuM+IFdbM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=N23TIUJ50sdcWqGuvqgGgxOoWMcPoC5Pq+hCwlWiyIVRvsS8bioPRqK8R8+KbmmHj gNldSrh5NACFIiv34hQjzNoAowwu3qZbggcJS1A9N2/ylAG2emIzf+biLPqX3AcPrx vAB8bzguJ3uOdElGCHnHuLqLwTMAXtZ5JNhqhbtD4VgYvZ2m4P3IX5KBsHtL6sj1cR wNA1qggl//7dWMWzkJAncnI/6kjl7hZ+2dGySIWbKEczuNc2x6CRmAv/1dPsIYNMvP fv+T4KIq6qsv0i3ipnvRstP70fZiBfEHbA6NgKGV3fvsigZldyKPFGYFuiiAVhWgsD 1KSHNgLEBQC8g== Date: Fri, 20 Oct 2023 14:31:13 +0200 From: Frederic Weisbecker To: Peter Zijlstra Cc: LKML , Boqun Feng , Joel Fernandes , Josh Triplett , Mathieu Desnoyers , Neeraj Upadhyay , "Paul E . McKenney" , Steven Rostedt , Uladzislau Rezki , rcu , Zqiang , Lai Jiangshan , "Liam R . Howlett" , Sebastian Siewior , Thomas Gleixner Subject: Re: [PATCH 4/4] Revert "kernel/sched: Modify initial boot task idle setup" Message-ID: References: <20231019233543.1243121-1-frederic@kernel.org> <20231019233543.1243121-5-frederic@kernel.org> <20231020082531.GS33217@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231020082531.GS33217@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]); Fri, 20 Oct 2023 05:31:27 -0700 (PDT) On Fri, Oct 20, 2023 at 10:25:31AM +0200, Peter Zijlstra wrote: > On Fri, Oct 20, 2023 at 01:35:43AM +0200, Frederic Weisbecker wrote: > > Now that rcutiny can deal with early boot PF_IDLE setting, revert > > commit cff9b2332ab762b7e0586c793c431a8f2ea4db04. > > > > This fixes several subtle issues introduced on RCU-tasks(-trace): > > > > 1) RCU-tasks stalls when: > > > > 1.1 Grace period is started before init/0 had a chance to set PF_IDLE, > > keeping it stuck in the holdout list until idle ever schedules. > > > > 1.2 Grace period is started when some possible CPUs have never been > > online, keeping their idle tasks stuck in the holdout list until > > the CPU ever boots up. > > > > 1.3 Similar to 1.1 but with secondary CPUs: Grace period is started > > concurrently with secondary CPU booting, putting its idle task in > > the holdout list because PF_IDLE isn't yet observed on it. It > > stays then stuck in the holdout list until that CPU ever > > schedules. The effect is mitigated here by all the smpboot > > kthreads and the hotplug AP thread that must run to bring the > > CPU up. > > > > 2) Spurious warning on RCU task trace that assumes offline CPU's idle > > task is always PF_IDLE. > > > > More issues have been found in RCU-tasks related to PF_IDLE which should > > be fixed with later changes as those are not regressions: > > > > 3) The RCU-Tasks semantics consider the idle loop as a quiescent state, > > however: > > > > 3.1 The boot code preceding the idle entry is included in this > > quiescent state. Especially after the completion of kthreadd_done > > after which init/1 can launch userspace concurrently. The window > > is tiny before PF_IDLE is set but it exists. > > > > 3.2 Similarly, the boot code preceding the idle entry on secondary > > CPUs is wrongly accounted as RCU tasks quiescent state. > > > > Urgh... so the plan is to fix RCU-tasks for all of the above to not rely > on PF_IDLE ? Because I rather like the more strict PF_IDLE and > subsequently don't much like this revert. Yeah I can't say I really like the old coverage of PF_IDLE either. The new one (after Liam's patch) is only halfway better defined though: it makes the boot CPU's idle behave quite well: PF_IDLE is set on idle entry. And secondary CPU's idle behave quite well also except when they go offline and then online again. And then the secondary boot code becomes PF_IDLE. We probably need something like this: diff --git a/kernel/cpu.c b/kernel/cpu.c index 3b9d5c7eb4a2..b24d7937b989 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); + 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); + current->flags |= PF_IDLE; + /* Happens for the boot cpu */ if (state != CPUHP_AP_ONLINE_IDLE) return; diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 5007b25c5bc6..342f58a329f5 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -373,7 +373,6 @@ EXPORT_SYMBOL_GPL(play_idle_precise); void cpu_startup_entry(enum cpuhp_state state) { - current->flags |= PF_IDLE; arch_cpu_idle_prepare(); cpuhp_online_idle(state); while (1) And then RCU-tasks can better rely on it as it really draws correctly the idle coverage. As for working on top of that, we have thought about solutions, lemme try to make them proper. Thanks.