Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2460334rda; Wed, 25 Oct 2023 03:31:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjQi5kOkrntLBgKITgdvnwIayjuNmwXgD9G9D4/hBglJbn6Fha4dJmbh5hgFy2B7Ldx3sK X-Received: by 2002:a05:6808:138e:b0:3a7:5557:16ba with SMTP id c14-20020a056808138e00b003a7555716bamr18692887oiw.27.1698229899437; Wed, 25 Oct 2023 03:31:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698229899; cv=none; d=google.com; s=arc-20160816; b=lqhov06MZRmlpYY72Tw67WR741l4tavUaaJ5lMHVOUVAGUcnxhDR5Ld2EKQLfF3oEq AxSUCIIFm9efRhiV+SECYgT9MTGJEeitAMaWCbERVAJNKv25yjdPz6U3KccyzptYWuB6 IiVIK4U2fRgnvHz1OtwR2yyQseRlHpY55xCWeKYyrOuCmp48T9hvDOHz/vVqkEgU+Bfi rQdviG6sArv6IohNjTbXC8VKDxNrOEshcDu/20PhKMKbaikQ+623SvlVRhhbxBLtzXb6 Bg8yc77LxcclUZZRXkfYdGt4JhJC5v5wr1C+38ceFZOlOjpiXv/1/pb5CIKDz5q13Rpj dUhQ== 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=rHVYtXLRkgHNfmOf3fqJRMPl7g44Xz6YHig3iQQYyes=; fh=I1pZsWGY/i1Gip8gktoKxOix+63hj3PPqvmC3YtcKcU=; b=U0toe7MFqkJ0Vt/u/cBEnKcFiJD9T4xWTPEqCaSD5h+ztENdFC5/qMAgQTNm2T+z8w fUVlciDcZkwugNVc5xoh484ZfBn5vtoyEbcMGTblkGzoCxfh8geWf3RZxvdJLkL6eo7C pZTw/1BpGmb8OQurWK3NkOkoyI5Udhgd0EkM0Mo6oiGPS/8j+Pb5HKqaFSydWHznYx65 ndMxpPG2tmFN98TBgARI3Pt1laoYchEBiOu/6s1XSRKYsNC5zO4gr29KnCQGFL9/2U6r mEwlL0Q+6QTP9Rb9E6GuIb/sdFqLfg63Em7QV1ExnAIXnrcdADxuTnAEZ+5ZUbWJSEZD vzEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HZO4TWTk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id t7-20020a056902124700b00d9abff6f6fdsi12782175ybu.734.2023.10.25.03.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 03:31:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HZO4TWTk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id C4BB6802EE46; Wed, 25 Oct 2023 03:31:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231794AbjJYKb2 (ORCPT + 99 others); Wed, 25 Oct 2023 06:31:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232584AbjJYKb1 (ORCPT ); Wed, 25 Oct 2023 06:31:27 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31D48DD; Wed, 25 Oct 2023 03:31:25 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D9DAC433C7; Wed, 25 Oct 2023 10:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698229884; bh=ktyjSOfOy84unE9g8h9qhxF+s92i7rfaj74PUcCQn+U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HZO4TWTkEfsZWrQQqCe8G1cDNhWa8MLeNEEXXleaM6vunTr1kyPJQyUio08XSsp6U YwRs7DSimAj297a/fa6tuqv2EEEES1224I8292TPYQpluDViR/zd5G49SthvRLE+Jb tqWovsGRTgdSx18x4rM65jjuVUrrKmbNfaLg1buKIcdAq61WlLvrcG6sDJvXVAW4X+ HanuYOJynCWYaNTkXDTZVSNGREgzUteY4AcNpH3kyvBfy7oIKkHa5ytZCgiuABCYXA Re5OWdwpycNVWxgWb7kJ5J9geWy82cYPTV2ZTpMY772O6muPwY82X9KcxiORd0BnAO /kEfHWprkLSoA== Date: Wed, 25 Oct 2023 12:31:18 +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 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: <20231025084008.GD37471@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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 25 Oct 2023 03:31:33 -0700 (PDT) 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. Thanks. > > > + > > + return true; > > +} > > + > > /* Per-task initial processing. */ > > static void rcu_tasks_pertask(struct task_struct *t, struct list_head *hop) > > { > > - if (t != current && READ_ONCE(t->on_rq) && !is_idle_task(t)) { > > + if (t != current && rcu_tasks_is_holdout(t)) { > >