Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp171023rbb; Fri, 23 Feb 2024 16:32:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVM1/3I8nju9X8sySxpdJVAiCX6WPuyyVyV0xlFp3uObYZwbZ3lXRr3MklnG6djjBBpNbxOfocZRny+mPRj122wbxyOA8MeWKVDDhOK8g== X-Google-Smtp-Source: AGHT+IGALgnT/Zv71WjdSTkPiy08ggMlXSDTKZ718DjXsLAggTmcLkz1tWYtYddb+/dtmaMReaRl X-Received: by 2002:aa7:d958:0:b0:565:5924:9d8b with SMTP id l24-20020aa7d958000000b0056559249d8bmr825679eds.35.1708734724906; Fri, 23 Feb 2024 16:32:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708734724; cv=pass; d=google.com; s=arc-20160816; b=uVwd/dC4qBRiYFBTfTuflo4uo7pUOipWQ0M9XQwXQo+OtmCFyG4amLI06J+FfWagA0 yrFoXmu5vJeZTRJs0dwUz2f68TRbqPN/bpwGcOUhuFnOAnzbMXeJ7jaUiQdnNEm43ivL bCv3UDAY1yZoAqzu56CPyX2x54l1+q7qY67Wblj1hySadjFPaVmFWkQdNjv9kJPzFCXG MfwpI7zjqaeu0eQlu5RNbY5uIjzvGVOsdw6VBpIhl6h0laok3iMZAc9i22fK/L+Nf/kB ysEb+vrYw5jtXO6dAvFTBH06cjG6jUtBqfxoe1yJK+x7X8dX8oaq6wuBsGVABBiP3BbJ CLQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=Y6kGkySh1qlErGWiBdbQ/k/VEt4wl7XqWtFzuAbBZ9k=; fh=nxQaXDE7VPGc97jTp4I+bnv7lBy3z3qhj4bpZif58DM=; b=fRZD+IWCaJ5P9SxCiY4AS31iUTv5CHfeL6eyATgOFueAvBhtYckTxraKRfUFLn7b2L kVOvvHZSNZmSxpZ3W1gBDIy8M+JpkqVnI6Vlrt/hE0XqQ4C2D986BivPfmv985HD/5RC qobRFDUjE6gKTdkUvizrAqKIwm3Y+2jK4h07NsWd/ST9h0xumSzKxHHAFq8TRJDKq6ZO wNxxuJvDCJ4OKdGXRLetYKhh0gXjdXyzTvzlexPYRBF52NvZCgHL860cADtozj2nycYD FNzRixA7IFQPAsohMPK+6AILPrChk9ykWbjKwC+LOqqNSof8YwMdYm7xXcKaE8pMUnXb xzHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AenSVfPd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79358-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79358-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b7-20020aa7cd07000000b00563cf3114d0si51081edw.426.2024.02.23.16.32.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 16:32:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79358-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AenSVfPd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79358-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79358-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C114F1F2786D for ; Sat, 24 Feb 2024 00:23:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 216C217C8; Sat, 24 Feb 2024 00:23:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AenSVfPd" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BBDD64A; Sat, 24 Feb 2024 00:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708734211; cv=none; b=E7/h8EklqhyiGbwq7OUCh1RyhiTFGDyJh78sAd7DjFikEMMEzk3s50VHm6A4viBse8V78MHPAZTAYQqlGns1uVoFVSSxSF5xB3GpCv31cK2Qdn9y5/w93b/sTFltu566Ixb/q0xXM4lEg2SDOY3gmjEZMcny6BbB/8taZb1EG7M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708734211; c=relaxed/simple; bh=PSIjkioZV1XuZZmMdkSlReJ4zGEasuPJXjKQZZQaDp0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EmNnxNa6+7UNXDKM3LVPsn3z7gXvV/7bbO2upTIZbADFZK6QtrH1I6F/xw8mR9+yRWlgOACLqDAbMItCbC78/mjCBrV/A7goTw+BOhuUqg9iMR084jx8uJrm88/B2Xbh2GFSnbCqfw4sdwuzebbewbyFWP4wPRyUi65L2IF8D+o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AenSVfPd; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F04BC433F1; Sat, 24 Feb 2024 00:23:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708734210; bh=PSIjkioZV1XuZZmMdkSlReJ4zGEasuPJXjKQZZQaDp0=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=AenSVfPdBJqMSgmAINEhFiTWpP8PJMsi4E7o3cfmhEn0aLupM8N1hOzNx3uZAEOrJ ma7+b3yoqyW0+hLocVPVJqXKg4rlZDgE04LMk5eKIf/CjYih/pU90dP02yPGzQONyq hk8M2WM15wNw8joXbyRltfO3AFbRov8aBufj+caf+gJo+zLDIYQzCmqUdM7tTQ/Hiv wE+KYFdI2ESRuW7QuNXenCbgxM6zRwiXFPwyuYCS06qfl0E8UEVxhIqO8qI+9dpS+j D460uXA7woSJfx3oBfn2xA4tInb/Aj90ZMk427PRO2JrM0G6OMnivnYWg5ytWCrTpb r+7lGfA0f/S3Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 26D75CE1113; Fri, 23 Feb 2024 16:23:30 -0800 (PST) Date: Fri, 23 Feb 2024 16:23:30 -0800 From: "Paul E. McKenney" To: Frederic Weisbecker Cc: Boqun Feng , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, Neeraj Upadhyay , Thomas Gleixner , Sebastian Siewior , Anna-Maria Behnsen , Steven Rostedt , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan , Zqiang Subject: Re: [PATCH v2 6/6] rcu-tasks: Maintain real-time response in rcu_tasks_postscan() Message-ID: <4741400a-b8e9-452c-a9a9-3a539868f1ef@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240217012745.3446231-1-boqun.feng@gmail.com> <20240217012745.3446231-7-boqun.feng@gmail.com> <9a27f638-4eb0-42b3-b8a3-201d6ed9406b@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Feb 23, 2024 at 04:14:49PM +0100, Frederic Weisbecker wrote: > On Fri, Feb 23, 2024 at 01:17:14PM +0100, Frederic Weisbecker wrote: > > diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h > > index 866743e0796f..0ff2b554f5b5 100644 > > --- a/kernel/rcu/tasks.h > > +++ b/kernel/rcu/tasks.h > > @@ -973,12 +973,13 @@ static void rcu_tasks_postscan(struct list_head *hop) > > for_each_possible_cpu(cpu) { > > unsigned long j = jiffies + 1; > > struct rcu_tasks_percpu *rtpcp = per_cpu_ptr(rcu_tasks.rtpcpu, cpu); > > - struct task_struct *t; > > - struct task_struct *t1; > > - struct list_head tmp; > > > > raw_spin_lock_irq_rcu_node(rtpcp); > > - list_for_each_entry_safe(t, t1, &rtpcp->rtp_exit_list, rcu_tasks_exit_list) { > > + while (!list_empty(&rtpcp->rtp_exit_list)) { > > + struct task_struct *t; > > + t = list_first_entry(&rtpcp->rtp_exit_list, typeof(*t), rcu_tasks_exit_list); > > + list_del_init(&t->rcu_tasks_exit_list); > > Oh no! The task has to stay in the list for subsequent grace periods! Please > forget that suggestion... Yours looks good! You had me going for a bit, and I do know that feeling! ;-) Thanx, Paul > Thanks. > > > + > > if (list_empty(&t->rcu_tasks_holdout_list)) > > rcu_tasks_pertask(t, hop); > > > > @@ -987,14 +988,9 @@ static void rcu_tasks_postscan(struct list_head *hop) > > if (!IS_ENABLED(CONFIG_PREEMPT_RT) && time_before(jiffies, j)) > > continue; > > > > - // Keep our place in the list while pausing. > > - // Nothing else traverses this list, so adding a > > - // bare list_head is OK. > > - list_add(&tmp, &t->rcu_tasks_exit_list); > > raw_spin_unlock_irq_rcu_node(rtpcp); > > cond_resched(); // For CONFIG_PREEMPT=n kernels > > raw_spin_lock_irq_rcu_node(rtpcp); > > - list_del(&tmp); > > j = jiffies + 1; > > } > > raw_spin_unlock_irq_rcu_node(rtpcp); > > @@ -1219,7 +1215,6 @@ void exit_tasks_rcu_stop(void) > > struct rcu_tasks_percpu *rtpcp; > > struct task_struct *t = current; > > > > - WARN_ON_ONCE(list_empty(&t->rcu_tasks_exit_list)); > > rtpcp = per_cpu_ptr(rcu_tasks.rtpcpu, t->rcu_tasks_exit_cpu); > > raw_spin_lock_irqsave_rcu_node(rtpcp, flags); > > list_del_init(&t->rcu_tasks_exit_list); > >