Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp387869rdh; Thu, 26 Oct 2023 05:16:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUuTnf/JeM7Bqru2SrtcGOiYvP7igOn4VzdYvyBao1WNVhNcufXiyL7GQtklsXIwgbhYz7 X-Received: by 2002:a25:2405:0:b0:d9a:c503:976e with SMTP id k5-20020a252405000000b00d9ac503976emr18027412ybk.58.1698322570778; Thu, 26 Oct 2023 05:16:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698322570; cv=none; d=google.com; s=arc-20160816; b=t5hv2wcJ0TSMp0VySZTp3hi7FeN+pubdGS9/C/CO2zN/DqxKWJdSOHax4KmESsg+U2 L2CUvP8nlEoPfsOlEx/wPaf87YLSS7LrLsymoXpJivVBrgo/JhJcpVl02/jNyCP3Nz63 yNvvn3dUZ5DCwCnok1c7xIinOGFrTuZjtGWu9hTbcq/xED+6RvrDL0sTNkzhoZKHHdTr OFRrT4mwfKuEuEY7aC3tr0qLKGBpYwgwGQQLv9UgOX5GpihwT5On0UWtYm5vomHPh3Qg UPKuzB81sPut6lRcPbhC1Edg05aBq9+gSUlwD75tX9xYFXRtCpJV8XUwxv7WH+sv/d1t U0lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=tXTt+TBzmX3Sm+AergVCPro5no45uF28IOJmLAgrl2Y=; fh=UEqScoGNM5hna9b+dLip2YOyPp2rpk+Uf5j0BBxcfis=; b=W7fy8N1KoyWCZK139nbZlJa3yI7QV6DXhi7CCcJIewio94OYYNAWai//lH1+szyvzJ eGcS6huAKv/MINMhuB/AdgqnjUIMeL+iDQZb1MX8Mq7JjO0ERzS1CWfwTyfPmOsJPY4A UMYrgGOsAE7S8PAB3tkwmSBxI7C1xZt23CbSv4loo/0IB44N1S9jpdknmg1Mz9UqxXhN 8yqrkWiexJTZ03awKmeO5jntoZlCOqErdcJnqrT8+0RoAkd3dm6PrYXiqI1hKoZjucGU tZUBmDGdaJLbtgXMx7P1QrteInhktLujaWL45yU4IdleUoOCCvNnQQmiPxkcFF0b/7a4 k3tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="QyYyI/aq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id j202-20020a25d2d3000000b00d7ae0a59258si14197174ybg.228.2023.10.26.05.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 05:16:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="QyYyI/aq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 303A68245A58; Thu, 26 Oct 2023 05:16:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230309AbjJZMPu (ORCPT + 99 others); Thu, 26 Oct 2023 08:15:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjJZMPs (ORCPT ); Thu, 26 Oct 2023 08:15:48 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25095B9; Thu, 26 Oct 2023 05:15:45 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c87a85332bso6860255ad.2; Thu, 26 Oct 2023 05:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698322544; x=1698927344; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tXTt+TBzmX3Sm+AergVCPro5no45uF28IOJmLAgrl2Y=; b=QyYyI/aq7To7Dl6mE92Oiyu21ljttE6cvzMRDChnrOgtap+F2rn75H9ICu86BV+aAr +dHsyYmwnoBRS+Oje6p5iOPJn19hPpFkYQBg80yIzdzuseGCt/6zC/iwWaeayxTYKat2 O8d9PCJLhmx6t6Ty87Bj5kMJRWXzw4dz7Ltb9sPD+IvmOVr0+EbNa4O0egZvFXt2FeLS Pq1dgpLa2wpcTi0nMzCilvmEZRKeNGgGGDwNPwSYTqlzsyxQIcX/t/PsE2/hhj1fFyiq A6kAQne1OUp1eR2IG2AoCYNJklw3FK2GQ3hvm2vM/E531cQMqwrpPGk3EtPmL4RYHXHb tLGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698322544; x=1698927344; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tXTt+TBzmX3Sm+AergVCPro5no45uF28IOJmLAgrl2Y=; b=XDvlAplOKQlFDuXgiDp5KnK+vUlBd1iLVUUarN9tUs9IUXoPQAJC7UjUulknqVi7Bn xc2L+Ji8kubND5x9VCl2j5azmDnF84KMPLpzEmfelHsSjJq1riBTFKCceyVtRm25LG0y QXXZM+vP4zCTeVpdNl72yZATblneb1jaQT48cfdkzMqZVCLr5A7HpHWAL1JAuwwWWytR JM3Jfx0PKb+sKBSVxtLgbwu0KCJH/F4fouetNGnCLTJp6kGc4H2wHCGuUjtgS0n6SX3m SxCRbbEz1ItzFiLO3XOtdDP71b16FYystsiPR7ly1DlwewTTuKlbHMGWgrIqRK1/d0q2 7v+Q== X-Gm-Message-State: AOJu0YwJYHDLKFWgYSEHS5A8t1+nakPfSXI4Zpk5ESU7hh+p8dDfVHkZ nZd2pFKPBZfl5qJAR8Yom1TlURREfLaUizHtQE4= X-Received: by 2002:a17:90b:4b47:b0:27d:298e:ec4f with SMTP id mi7-20020a17090b4b4700b0027d298eec4fmr17343076pjb.4.1698322544571; Thu, 26 Oct 2023 05:15:44 -0700 (PDT) MIME-Version: 1.0 References: <20231024214625.6483-1-frederic@kernel.org> <20231024214625.6483-3-frederic@kernel.org> <20231025084008.GD37471@noisy.programming.kicks-ass.net> In-Reply-To: From: Z qiang Date: Thu, 26 Oct 2023 20:15:33 +0800 Message-ID: Subject: Re: [PATCH 2/4] rcu/tasks: Handle new PF_IDLE semantics To: Frederic Weisbecker 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" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 05:16:07 -0700 (PDT) > > Le Wed, Oct 25, 2023 at 10:40:08AM +0200, Peter Zijlstra a =C3=A9crit : > > 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 =3D 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 =3D=3D idle_task(cpu)) { > > > + if (is_idle_task(t)) > > > + return false; > > > + > > > + if (!rcu_cpu_online(cpu)) > > > + return false; > > > + } > > > > Hmm, why is this guarded by t =3D=3D 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 =3D=3D idle_task(cpu). But rcu_cpu_online() has to, otherwis= e > 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 , when rcu_is_cpu_rrupt_from_idl= e() return true in rcu_sched_clock_irq(), so should we also add a check for "current =3D=3D idle_task(task_cpu(current))" in the rcu_is_cpu_rrupt_from_= idle() ? Thanks Zqiang > Thanks. > > > > > > + > > > + return true; > > > +} > > > + > > > /* Per-task initial processing. */ > > > static void rcu_tasks_pertask(struct task_struct *t, struct list_hea= d *hop) > > > { > > > - if (t !=3D current && READ_ONCE(t->on_rq) && !is_idle_task(t)) { > > > + if (t !=3D current && rcu_tasks_is_holdout(t)) { > > > >