Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp174310rbb; Fri, 23 Feb 2024 16:43:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUj34T56I0Sl8WjvUz+I5x7lxPEJnTvKSU0u4MmN5jXe1/T96IPWGGU1RQh5Ox6EHI2g2Fi6z7Xfdul6sjDQGqkv6VOFUkTJp2aMh6KsQ== X-Google-Smtp-Source: AGHT+IG2QAQV9ZXIwv8qkCR2cV1yNybEMmPKclEURRvpbFRrtGdgx3B69Hr7zFKjR2drGK6T4Ojl X-Received: by 2002:a05:6a00:228e:b0:6e4:625a:f09 with SMTP id f14-20020a056a00228e00b006e4625a0f09mr1730961pfe.10.1708735400089; Fri, 23 Feb 2024 16:43:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708735400; cv=pass; d=google.com; s=arc-20160816; b=iiPRA+2kOdQ9ZpEgQr5gro5RetnlANqJ6bTjU4E8vIqZJWVciwSq3vbc7b3gQlMwOB PNRyp4e+xJFLxqX6Hu32yfymMUvCU3TqfCrsx+UPSFt/oVds5DvqvzRg3pytvOJFbWd1 wNBTGyNMr5vJVkLWWQ06JbJJVjwoE6FuKtreHWn8ztXMqYnzHWzZCO7ekL/cEHK8eOG6 o/3idDMsAhXpbbFbJkZ2R/59Po3UVqI0GUkef9BfHJX1HRKi0MLKpYaVZUJdacB3KnuI 1wdXebukDFvCSaBOSX+Cn7cKdBmOeNC/NSzuzRK7a+4LQ6OiwSHCSSo9lMmEEJw9X7Ua 3cbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=haOiD9mMvHd53b0Q+fMpH+VCB3qsJ5K6aM80tG1ims8=; fh=ILg6AD6U+1JoHd7eChNgwXWYGXz9I9KjU8T9p9yS+X0=; b=kHVURrEgGvSSMy/JKMr2fbaQulzMsnmSuI1g1MiOZYgtlI4apzOP3MHDBY3BE1Kmjx sjT7u4/s1Ns4sMXzVddWo86drY9AUIZdDUlu49ERD2I8NhcoCFX6AjALIlAZL23FgM/x a1qPYoZ9x6wB5eR9x1lbab2+Dycp7gWA9PEu45p/gmnGhmri8ArPVzf0aCJFFbeFdqMf NNfNQDEVV8Gd2ffnEUjkk41p8cMaFOIa1lD+Zg6Yrmi2RIvDnJm1vmmk4hMdu8Aao5Ly 5Xsiquo4gt79t8dqRqBJX6BARrscLKMFyPksKfQ/meAs28O8BOrGpXn3QPnRFr3IoQ11 jDSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rZKecjUV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79371-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e7-20020a636907000000b005dc9b236b70si111588pgc.808.2024.02.23.16.43.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 16:43:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rZKecjUV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79371-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id EC06DB24B42 for ; Sat, 24 Feb 2024 00:43:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F72EEDF; Sat, 24 Feb 2024 00:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rZKecjUV" 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 5BC5263D9; Sat, 24 Feb 2024 00:43:05 +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=1708735386; cv=none; b=tsuGMjJ7fVMcvbkOOeC/oZOWjV9p1SIdOtldRyszeVgT24seCzkJVa7WVWNnmjPs0ARebkzPbuv9+f8YBLIrB38EMMq/3TxvJ4B5jTDYbH8B8DDDsUJZiwgX2yXNUca/8S9YM7VZ0ZX1uIm5gdLDukRl0/iUmFfIHxND0kiqdbI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708735386; c=relaxed/simple; bh=m73mINAcBZK7KFtefy5Xad/poSVabUB+gIm8dOx4+qo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sxQsWy3esTQpJg9klmxdI68uvzlH34vp72u+OeBgwlNAbytaWDRq4rqq2Qraz3pKNjMzBsNVZ9vKY2V5NcNII4gvi0/qPRzsffANuCq7q0B23NJmOiaszuz/jj0crPORPk3o3+Z2+m2rkyJ4ipmJ0k0uns4ORp6/LzYN2DPdKPc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rZKecjUV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CC19C433F1; Sat, 24 Feb 2024 00:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708735385; bh=m73mINAcBZK7KFtefy5Xad/poSVabUB+gIm8dOx4+qo=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=rZKecjUV+6koNQRARM3ZkeptSR9GT33A4dL2+HzQZH7eTwLEudSRt+U3iVIL3bp3w gLd02m/ckOh8eZecdrA5RaHmkar+gAoUF0eLM6v2dv7z+XpW7RrA34F0Z0g4hdBFg/ VL4YMYvzKtAT9+F5mcyH9trNoKXkmaJeiFksDZcY1G+WfAgC1AxE+9Y3fFfBVpZuH0 d89dcNpLWwIVk5odteqqALf3YEwdrn/dS9TcBcaN2w3oX8c+kFGUgn7Li6X1841F0s THBlFs6W30YFWwfBI0IWIXA9I2wuvYSl9lAu7z9DKayUT3XM9EHzgVYgJa/bSj3Wi1 VkrKPbYAUZnoQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id EC45CCE1113; Fri, 23 Feb 2024 16:43:04 -0800 (PST) Date: Fri, 23 Feb 2024 16:43:04 -0800 From: "Paul E. McKenney" To: Frederic Weisbecker Cc: Boqun Feng , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, Neeraj Upadhyay Subject: Re: [PATCH v2 0/6] RCU tasks fixes for v6.9 Message-ID: <8f992601-153e-4cc1-8e7e-6684823cd590@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240217012745.3446231-1-boqun.feng@gmail.com> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Feb 23, 2024 at 01:25:06PM +0100, Frederic Weisbecker wrote: > On Thu, Feb 22, 2024 at 02:09:17PM -0800, Paul E. McKenney wrote: > > On Thu, Feb 22, 2024 at 05:52:23PM +0100, Frederic Weisbecker wrote: > > > Le Fri, Feb 16, 2024 at 05:27:35PM -0800, Boqun Feng a ?crit : > > > > Hi, > > > > > > > > This series contains the fixes of RCU tasks for v6.9. You can also find > > > > the series at: > > > > > > > > git://git.kernel.org/pub/scm/linux/kernel/git/boqun/linux.git rcu-tasks.2024.02.14a > > > > > > > > Changes since v1: > > > > > > > > * Update with Paul's rework on "Eliminate deadlocks involving > > > > do_exit() and RCU task" > > > > > > > > The detailed list of changes: > > > > > > > > Paul E. McKenney (6): > > > > rcu-tasks: Repair RCU Tasks Trace quiescence check > > > > rcu-tasks: Add data to eliminate RCU-tasks/do_exit() deadlocks > > > > rcu-tasks: Initialize data to eliminate RCU-tasks/do_exit() deadlocks > > > > rcu-tasks: Maintain lists to eliminate RCU-tasks/do_exit() deadlocks > > > > rcu-tasks: Eliminate deadlocks involving do_exit() and RCU tasks > > > > > > Food for later thoughts and further improvements: would it make sense to > > > call exit_rcu_tasks_start() on fork() instead and rely solely on > > > each CPUs' rtp_exit_list instead of the tasklist? > > > > It might well. > > > > One big advantage of doing that is the ability to incrementally traverse > > the tasks. But is there some good way of doing that to the full task > > lists? If so, everyone could benefit. > > What do you mean by incrementally? You mean being able to cond_resched() > in the middle of the tasks iteration? Yeah not sure that's possible... I do indeed mean doing cond_resched() mid-stream. One way to make this happen would be to do something like this: struct task_struct_anchor { struct list_head tsa_list; struct list_head tsa_adjust_list; atomic_t tsa_ref; // Or use an appropriate API. bool tsa_is_anchor; } Each task structure would contain one of these, though there are a number of ways to conserve space if needed. These anchors would be placed perhaps every 1,000 tasks or so. When a traversal encountered one, it could atomic_inc_not_zero() the reference count, and if that succeeded, exit the RCU read-side critical section and do a cond_resched(). It could then enter a new RCU read-side critical section, drop the reference, and continue. A traveral might container_of() its way from ->tsa_list to the task_struct_anchor structure, then if ->tsa_is_anchor is false, container_of() its way to the enclosing task structure. How to maintain proper spacing of the anchors? One way is to make the traversals do the checking. If the space between a pair of anchors was to large or too small, it could add the first of the pair to a list to be adjusted. This list could periodically be processed, perhaps with more urgency if a huge gap had opened up. Freeing an anchor requires decrementing the reference count, waiting for it to go to zero, removing the anchor, waiting for a grace period (perhaps asynchronously), and only then freeing the anchor. Anchors cannot be moved, only added or removed. So it is possible. But is it reasonable? ;-) Thanx, Paul > > > Thanks. > > > > > > > rcu-tasks: Maintain real-time response in rcu_tasks_postscan() > > > > > > > > include/linux/rcupdate.h | 4 +- > > > > include/linux/sched.h | 2 + > > > > init/init_task.c | 1 + > > > > kernel/fork.c | 1 + > > > > kernel/rcu/tasks.h | 110 ++++++++++++++++++++++++++++++--------- > > > > 5 files changed, 90 insertions(+), 28 deletions(-) > > > > > > > > -- > > > > 2.43.0 > > > > > > > > > > >