Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp484288rdh; Thu, 26 Oct 2023 07:34:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmyHas7tODlOBasIoa32mkpD0u9DKrBIu1nco3lINevJZx6Kl9YG5O7IbqbjZG6sQo82Fu X-Received: by 2002:a81:9147:0:b0:5ad:a3f9:1b10 with SMTP id i68-20020a819147000000b005ada3f91b10mr7059878ywg.10.1698330890700; Thu, 26 Oct 2023 07:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698330890; cv=none; d=google.com; s=arc-20160816; b=Ys3jKjpKsBMoMMoZ1wZAlSIl2+DDtGB+LAbzQyv5BhWWTG5m2BhVMG93yNuo6Rbwrf GrXGQU4l9z2KLAakhEJ5RulU27mPVEuxSJwFxIPixTrEnc3z587YkZu/BmX6S0wDjs9P L8BkZlRwd1DVY6Oy9IwbmA4Np4KM80uV4eMoE6Mwz9RbsYdtqWN257H9dYsj0IBIQeLe gsGOfQLTEjXgV+mIduUGOiT7Ku66q57PLXEz1M3r1aIO+villlcfXRAlnw0WDYWH2R78 pjq3ROlPRP9zWGev8vxuoFijtkC8d7/css+D54kKlNsU2PdrJYTTGNcqQV7M1MYSo2Pk bLOg== 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=hYwymlFgbsClF5YuKcgEPgf/n1gioY1ygPQ2SJt/hBg=; fh=DbOjY+0IRfsEuofCwqorz9L1C36s6LfJ/MA08862oRM=; b=yq9u591liFCqPTBBehQpTba2+QolaPohuqSjEX86WQUrOzmtAn/AmyaGKmI+qB4G1J 8EycvmTRJBEJhxZjw1XPCc+QB73WQB/EMxaasrhaKpfXG5+5k4uOsilffJx4gND0YiF+ Xd3Wzf5+UL8KDnhcbvHZYnBWKMgXzvEdYwgBN4aF6homYe6rkxO6End9o+M1n7OTX7CP hRwuXkf3CJJ1DL+8wWXg5PM2LtsCrqZNMLzDE/OOf3bdKq1bftpNWKuimvOS6lDH46bD ZfWIVDdN7BMukYj2s68ygDJxOSFjlkKFIEirvOm1Uvu5yg7XvdnN/9f8ZQkj2ycyieS0 8ymg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IiZqL9Le; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id i186-20020a8154c3000000b005a7c5a12f4asi15286771ywb.111.2023.10.26.07.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 07:34:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IiZqL9Le; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 342598242983; Thu, 26 Oct 2023 07:34:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345255AbjJZOef (ORCPT + 99 others); Thu, 26 Oct 2023 10:34:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230507AbjJZOee (ORCPT ); Thu, 26 Oct 2023 10:34:34 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33C3B1A2; Thu, 26 Oct 2023 07:34:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58E81C433C7; Thu, 26 Oct 2023 14:34:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698330871; bh=rKDtDZQL7IF9MPNckBpYcUD5NDFOua3I/T1b8Be9sxU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IiZqL9LeNrTScCl6FAaz9v8ysyES8KP4YtIPM7CSNn90UciwCG0q+ticfFl6GV24b FqFLTSHUjaf8luzv56MNL541GlmMLsfNzrHGDXS1Z9yB6APSdrVN0kNv67HKkZEKB+ Mroz1RcEYusxO65SMoY+bvXOpFXw4zEOcqWlYuWMCPII71bd2qFHfBqJPqT8se415k T55W72cY4WdWX5iySJhqy+jBrDNTSSyLfP/A7TGDcdJ9BNRVCHyJnHwYMZUJVTXnCc eMdzivwdlNa/X8XE7MOTzgn3MqgbmSYneDUUuYGHPEeLN+USmK8uG/k8JWLH1rEF1Q NVDiqzxxd6BhA== Date: Thu, 26 Oct 2023 16:34:28 +0200 From: Frederic Weisbecker To: Z qiang Cc: Peter Zijlstra , LKML , Boqun Feng , Joel Fernandes , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , Neeraj Upadhyay , "Paul E . McKenney" , Steven Rostedt , Uladzislau Rezki , rcu , "Liam R . Howlett" Subject: Re: [PATCH 2/4] rcu/tasks: Handle new PF_IDLE semantics Message-ID: References: <20231024214625.6483-1-frederic@kernel.org> <20231024214625.6483-3-frederic@kernel.org> <20231025084008.GD37471@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: 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 26 Oct 2023 07:34:44 -0700 (PDT) On Thu, Oct 26, 2023 at 08:15:33PM +0800, Z qiang wrote: > > > > Le Wed, Oct 25, 2023 at 10:40:08AM +0200, Peter Zijlstra a ?crit : > > > On Tue, Oct 24, 2023 at 11:46:23PM +0200, Frederic Weisbecker wrote: > > > > > > > +/* Check for quiescent states since the pregp's synchronize_rcu() */ > > > > +static bool rcu_tasks_is_holdout(struct task_struct *t) > > > > +{ > > > > + int cpu; > > > > + > > > > + /* Has the task been seen voluntarily sleeping? */ > > > > + if (!READ_ONCE(t->on_rq)) > > > > + return false; > > > > + > > > > + cpu = task_cpu(t); > > > > + > > > > + /* > > > > + * Idle tasks within the idle loop or offline CPUs are RCU-tasks > > > > + * quiescent states. But CPU boot code performed by the idle task > > > > + * isn't a quiescent state. > > > > + */ > > > > + if (t == idle_task(cpu)) { > > > > + if (is_idle_task(t)) > > > > + return false; > > > > + > > > > + if (!rcu_cpu_online(cpu)) > > > > + return false; > > > > + } > > > > > > Hmm, why is this guarded by t == idle_task() ? > > > > > > Notably, there is the idle-injection thing that uses FIFO tasks to run > > > 'idle', see play_idle_precise(). This will (temporarily) get PF_IDLE on > > > tasks that are not idle_task(). > > > > Ah good point. So indeed the is_idle_task() test doesn't musn't be > > guarded by t == idle_task(cpu). But rcu_cpu_online() has to, otherwise > > if it's not an idle task, there is a risk that the task gets migrated out > > by the time we observe the old CPU offline. > > > > If a fifo-tasks use play_idle_precise() to run idle and invoke > do_idle(), may cause > rcu-tasks to falsely report a rcu-tasks QS Well, there can be a debate here: should we consider an idle injector as a real task that we must wait for a voluntary schedule or should we treat it just like an idle task? Having that whole idle task quiescent state in RCU-tasks is quite a strange semantic anyway. And in the long run, the purpose is to unify RCU-tasks and RCU-tasks-RUDE with relying on ct_dynticks for idle quiescent states. > , when rcu_is_cpu_rrupt_from_idle() > return true in rcu_sched_clock_irq(), so should we also add a check for > "current == idle_task(task_cpu(current))" in the rcu_is_cpu_rrupt_from_idle() > ? That looks fine OTOH. Whether idle injection or real idle, rcu_is_cpu_rrupt_from_idle() is always a quiescent state in real RCU. Because we know we have no RCU reader between ct_idle_enter() and ct_idle_exit(). Thanks.