Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp195247lqs; Thu, 13 Jun 2024 07:43:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV6rxVSuj/IZ3UR1xcAESKIXvj9Tu9A9FzcG5xLyt3UaKuoSpAstblIoOocjHoDrCC7HHntbjrOXM9WW9ThfTJUvpio0/L/Uual9kGMaA== X-Google-Smtp-Source: AGHT+IGOOyGk/QhGrKizzuhsxhIndFD6HLHkvUFq0yhkSnAC6U6N3mSjWTwkSRsmMEMiYzZ9gBUj X-Received: by 2002:a05:620a:4710:b0:795:5973:b037 with SMTP id af79cd13be357-797f602a8f7mr548074585a.27.1718289827786; Thu, 13 Jun 2024 07:43:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718289827; cv=pass; d=google.com; s=arc-20160816; b=MLPENMr5nTjTgCYyMYeu2J19qLVTjiJAivzcJ/ZkVhYQIzl1PomCIaSRF3AfYaBZgn 49YA5dFdkUpR19hdhvoS5h+ZIPGM+78N8GCqs9KqCZfZbq9nniRYWos6Ub7/cx2Ae5P0 tx23d526MhE0vF5B6i3O4GW8S4EULEQOStrhSmA2Azzcl/xnpJCQrj33WV1iBRMhec/h zjVmb/OeiEuN0mMaOkAwFgrtYdH+RUnZWoEVUw0EfctTzC3W8Zu2sfHBpbOubTBq18RT HhrpI+AycZZ7+0hXP4JAqvN0SbfaYOan87rpQzx1uZZSaBgJUmsCwIZwVc7VUC53jCbM BW4w== 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=Ls+U8jJtBjEy+ivrQul3Y3L8Jea1Vy1Uk6m6YMwTy7A=; fh=Sw5v7FvwBe2M9WB+NcgMlodt0MPurFzTw/uTn2UdxSU=; b=LXWWH/SNPsxuBJ/7C99RO3Uxdl7RPYkYJAlQR4V+SwZeSNekuyygDNcrqapkNHqqSq fcZX5yFKC7KtN0BSd+K/34jN0AqqayBvzFVfi1FXd18MIcojBcyYjwuz23Q60BR/f9sq k6s3PYej79vC8TFSk0ZBakXx2/LS4t5yVC8shSdlbrHtLb8ScZa7Do0gO4ibji7ofdah ZvvJQ0c2qxReE9JBpI+BMATqIqCcBSI4M/SBcIPziyYxmCSgru4391ZUu68hNiAjpLfu 8LKzR44Di/cTgNj8kr29M8fsA4AUlsloLa97wwChr0ODGE59l2nP02G6FjXUIVKFBW6c 06PQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k8px7EUm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213450-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. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-798abd1d7fasi147551285a.515.2024.06.13.07.43.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 07:43:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k8px7EUm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213450-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 CD35F1C22C14 for ; Thu, 13 Jun 2024 14:43:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B43B14601C; Thu, 13 Jun 2024 14:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k8px7EUm" 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 68B081411D6; Thu, 13 Jun 2024 14:43:36 +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=1718289816; cv=none; b=NnFTQMn3LXfyF60Bh/eMSesf1fBs7cgYVK1uk/F9krd1FN3E07BQDNadsSH7hYbfGnTVduH969xDvQ+SUwfOEPb3aDlIQ5Zd/Zu7A4BpYkvOgV02pSQzaeLtmlq69h/B+43i6JnOue/okhU3sqEudgOgCiRaaCc7vKLgw1iV2PA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718289816; c=relaxed/simple; bh=ENTr3coAsQURUsjgzm57k8qmYmYqJPesZfILsIqW9hs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=G4OxAm4391w+2VJPRuLw1sh+sR/viHEE0ZY4CZvqq5vqjIkldG5l2l38NNuI6YDopq5IgeVudVw/yGykdoVPbDA9qneSlquRsXnEThNOxmUd8d7ZOX1FB9oG8QIfUrOIHui/GpsMm8aMwUUIDR63FDGiVJnojYHpaP4xC+N3jO8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k8px7EUm; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE122C32786; Thu, 13 Jun 2024 14:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718289815; bh=ENTr3coAsQURUsjgzm57k8qmYmYqJPesZfILsIqW9hs=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=k8px7EUmjvL9L3g1sw13b1cWKwG9k2bUEtNZ3rRAi96pkn27aWBb44BxZK4vA1GHZ BYd//uvON2++hb/5T6rd0VVE7Pw6AR45lCrbinXcISP/w2GBN8i30xn92uBDIjUB/7 TxzBxp9eJUxB1UDbT8gZEA+JC+qQNXV8+Q/KIMuos3QW0phwzJRd5s7+BJiMl6xLAF 1m61ir9x7Hfmm8gs57p/iftOVqB/KS32IYPP7FuXP9DznI3eVvYPb5Kyp4h3K15yws s/8w9p6g0nni+YtNvy9Y/6TZejvXV5YkUfnjKhHUfmAGmwMytbAK2l+LXz3VLO79mO vyPxyQ91dynkg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 7A371CE09E0; Thu, 13 Jun 2024 07:43:35 -0700 (PDT) Date: Thu, 13 Jun 2024 07:43:35 -0700 From: "Paul E. McKenney" To: Keith Busch Cc: Nilay Shroff , l@kbusch-mbp.dhcp.thefacebook.com, Keith Busch , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, hch@lst.de, sagi@grimberg.me, davidgow@google.com, akpm@linux-foundation.org, venkat88@linux.vnet.ibm.com Subject: Re: [PATCH 1/2] list: introduce a new cutting helper Message-ID: <31eb40f9-d68d-4348-b1fd-3cf057939297@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240612155135.3060667-1-kbusch@meta.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=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jun 13, 2024 at 08:36:44AM -0600, Keith Busch wrote: > On Thu, Jun 13, 2024 at 07:11:52PM +0530, Nilay Shroff wrote: > > On 6/13/24 18:26, Keith Busch wrote: > > > But that's not the problem for the rcu case. It's the last line that's > > > the problem: > > > > > > list->prev->next = list; > > > > > > We can't change forward pointers for any element being detached from > > > @head because a reader iterating the list may see that new pointer value > > > and end up in the wrong list, breaking iteration. A synchronize rcu > > > needs to happen before forward pointers can be mucked with, so it still > > > needs to be done in two steps. Oh bother... > > > > Agree and probably we may break it down using this API: > > static inline void list_cut_rcu(struct list_head *list, > > struct list_head *head, struct list_head *entry, > > void (*sync)(void)) > > { > > list->next = entry; > > list->prev = head->prev; > > __list_del(entry->prev, head); > > sync(); > > entry->prev = list; > > list->prev->next = list; > > } > > Yes, that's the pattern, but I think we need an _srcu() variant: the > "sync" callback needs to know the srcu_struct. Just make a helper function like this: static void my_synchronize_srcu(void) { synchronize_srcu(&my_srcu_struct); } Or am I missing something subtle here? Thanx, Paul