Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1317710rbb; Mon, 26 Feb 2024 05:56:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWR7UwYuj+9Wr0pLvYHqK4Q85Zq3hLrKequdOXhurN3lT/6yl6bYunhHpwmW3M/F3sFnrmLiQC6Yj4GeRF4HF2ZEjG5dhkYh12XQgqrgg== X-Google-Smtp-Source: AGHT+IEdmrT8XfbhFMgfvmRZPsdRykX5nqZTr29bJ+BwroBoje6j1vKAbMRORyMBYCox6FNfm1qT X-Received: by 2002:a05:622a:113:b0:42c:5240:cef8 with SMTP id u19-20020a05622a011300b0042c5240cef8mr8413266qtw.22.1708955775731; Mon, 26 Feb 2024 05:56:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708955775; cv=pass; d=google.com; s=arc-20160816; b=J3M0EvITry+aqXv5dDbAxGqoximva8d06cbCgTC5Or5b01aq2Dv+im4Kw17TcQNd37 aIdipWqCxOrubdb+AIX0AAIOjbBoChRilIGyUKUqMWqeBfha1xHEEg1/m+/lZahdVkTo VWyX+/pd/34ti/ZNcBnns0mBW4TkyFOZQbSNWGqMyxEK2u0QuCm33+746xNUvR1oU4rn VGN7hLd2oMvcZJepT3nUcB11i8JhS2A2hJ+jYy8UStrXBDYQHcriw3lbGKUMBizNqqIu ziRSrbOq9c24cmasm4CYAjjtnc0o10l+yJcuXRMLI6f5LeKUvTpBmjOJDoIXulInVWb1 hqag== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=eRDAZZM3SMyzsLJF5mBrrTcuSrtiEch8evpjURcaou0=; fh=r2rY1/vH+zjrXEhrOkmOoW0Cn5gh420l+AXt35p7A5k=; b=cLn6WlbRD3V921gIwZt89u0IHuCZ/UqvhGMLno2f78b9/nr68G1dtWzk19PWIieZlY dpFtoq4QRbuY+cHFo8JMJhr959gAh8LpAgUQvKaFC2UwfGQxIKL835r+/vy23GSov1Wo D1P26Z//y0xizZH0jMDpbouRMnvIvWpZH6wO61Rx0qjMH2Px7kMwBFC8NKkmLqZnpcsv qKLULUmOnmy6s6VOYpQLG3lNCl0Tc1IVsztqb3Z69DxKUpp2QTWd7JaepWEJpGQN2jJ9 qoVL84bLXY5pZUBMoh08Ndv6cgPcM4yy9qJK/itSnGLi2Euh7UakHRU1BAIDaip4knjo GSdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PLZHVksw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-81543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81543-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h21-20020ac87155000000b0042e58058ce1si5126148qtp.14.2024.02.26.05.56.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:56:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PLZHVksw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-81543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81543-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 78E2D1C2991D for ; Mon, 26 Feb 2024 13:56:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9465B1292E0; Mon, 26 Feb 2024 13:56:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PLZHVksw" 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 BC53E7E570; Mon, 26 Feb 2024 13:56:09 +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=1708955769; cv=none; b=rbSKhmjIUAge9QtiWVRT2oiKl0gK3DUv6xCR5JW/JJUukDJWG43tKJKr7PZGPQGCk0rV6b+1KfFUKiyg4y6LSwDCMPTepqEU7WslklakS662k1pfuhj3US9AXLTuaGUlw6F/RnSqiO0X+1/2ukT58aLgkR3/MnMV8Mur5+sTZkE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708955769; c=relaxed/simple; bh=Z+YufZLQTF3twHN8Tt45XHdmDYZSZIos7wJ19PJBXBo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EIHh6v/cj3RxcavyYmRw20HVZP1Isr3/EbRMNlvRybS9eUMT7rdcOFTqhpPSTkSlt+Uve85hJLDLZBqWpNFUJnFIQHV4m96yVT989qRa3TpAV1Rm7pI7oB1XZlbgq8wmAqH4bJg2JTJa0T5wh6KmX30FoGIRJSk/7u4kVpndA4g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PLZHVksw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E989EC433F1; Mon, 26 Feb 2024 13:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708955769; bh=Z+YufZLQTF3twHN8Tt45XHdmDYZSZIos7wJ19PJBXBo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PLZHVkswvcvglQyfMOc3PRrvH2+yMEJzPecFowmBPlXbnHCpy8Jp4R10HCX2Gsf1t ppcZl86Gz7YnWCDdJkX2ZM2ONHtxeQMjD+krgIrMfYSAqUdcl6/Pr4fE5h4D/cpcdS gUuRZLjYcg0LYPmWNqe32YCUS97v8/QxFzbWAwswJel9gvfeVG+r31BqJ+INrN7+d8 AhrcILGsnTCH3sqZhZAS9xfo8AHl4yTv6EFbYx89nqppq/7b6of5fwD3brVDHNUnfE AF4PxhPWMxykPYuFbmTRIjYIv85KeN/thbklOKvLjkP4fOzbsQBC5LfQWKk+Qg0vr/ jey/s8zz7Dg+g== Date: Mon, 26 Feb 2024 14:56:06 +0100 From: Frederic Weisbecker To: "Paul E. McKenney" 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: References: <20240217012745.3446231-1-boqun.feng@gmail.com> <8f992601-153e-4cc1-8e7e-6684823cd590@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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8f992601-153e-4cc1-8e7e-6684823cd590@paulmck-laptop> Le Fri, Feb 23, 2024 at 04:43:04PM -0800, Paul E. McKenney a ?crit : > 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? ;-) Wow! And this will need to be done both for process leaders (p->tasks) and for threads (p->thread_node) :-)