Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp312839lqs; Thu, 13 Jun 2024 10:39:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUL1Ulafbkjlqj1nMqtQj8l3Jy042iyaTKmdP00ZFerNWY1kQjnGBuR+CVd++7c1om7z4F8VSIPLs8+5buCAU9JX+M4HWa6R0PXmN0gWg== X-Google-Smtp-Source: AGHT+IHX4o/DrpvD6/IIsRY/f+8apb3vXcPg/3jVjdt4pzWEC7c/uhaGjp8/1jVksjmeIMXddYyJ X-Received: by 2002:a50:ab5b:0:b0:578:57b7:9f32 with SMTP id 4fb4d7f45d1cf-57cbd6a58a1mr301059a12.35.1718300397032; Thu, 13 Jun 2024 10:39:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718300397; cv=pass; d=google.com; s=arc-20160816; b=SPmpszGvmvm5/3XrSvAiHeRXeR5NppSgo0iWHNPpD6/Qh8QqpladtYb4qOHQVKMYID Smv8rvKZ40NPDT5Nv62pw2467NrATEi3SJ1DjOMi3RTXzoJa4d81l9EGCe5Ii5yD1kOG 4RCRdoqW3xAehEVuHLOVYOh3nsI0yiQsM4NVCNAPKF8lXxdGJaiHku8Nz5BOQsS6XHzH ss8QiziW2EZrOkbvYV0blAqHeRlPYRmnRVXUZwExWeb5itbSS3EXwWpGvtOxkLPlWI/W wgQm4+oam+NNMNXPAWgQ3iAof0ZZvmi8zqIQzPR0NjHETqwhZQmHcwzdi2VDsl/7t5cs ZjOA== 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=1wHp5rr4jOhLspjXHo/w85f8BHmVNISjWiprmsF2ncc=; fh=0yog0N2+SxhP6+NMFzaPcpuRoizS1x0yF5EQRXgtfe0=; b=zAGexcHgL4xl9MEAzxuMtUEs/SAOkEOZPQTVVlCLaCBu5RDVp4B7HU5mHtobEqPrMc El9vpJWoaGJqiDCFLBlxkUjluaNSwGTHzD4JqE848BswusIKGHf4qVh1fkUohsVPrLWh JUEg21I8KWPqQ7SMWQQWbZmpGAApycgZyqIEzqyylWexodnfifeXym5eh2QsL1+feZNb 8wdXNhajqQZd5Dk7VTkDqkoIiKaiQJi1uZzftUeeyeSUmOmQ3ZpVT5i2dmmU3O4qFBtg 1oNnHTdU5oCAh6eeZdif5Dv50ebYtReeY7jkmTi/2fiqwEJxZylZcjrOrR4Y2zNOG6vx JbwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vLmEkgNi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213762-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57cb72d6999si903311a12.93.2024.06.13.10.39.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 10:39:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vLmEkgNi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213762-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 B61981F233B7 for ; Thu, 13 Jun 2024 17:39:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C61FB14B09E; Thu, 13 Jun 2024 17:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vLmEkgNi" 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 EAF5514B081; Thu, 13 Jun 2024 17:39:12 +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=1718300353; cv=none; b=d1c/hf6Z+G1jxuvZz74VShKlQ5BRY71EcF69vWK7OwD9KHT5LvF4GQwCf2a+oLy/n8/mT3ZSFxSdJbZhgo0p2YepLAtiyx/AUPG4aO2B4dQZXgf8V6BscZkvspqyMaPLSPF0DgDdOajnPpMvm6LN+ZMXoLbpiXn74vcL6SUCdRM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718300353; c=relaxed/simple; bh=cM/32dqi6fZt6LQTmM2EuhniCZp3BnJkhJ9u/IvhkK4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=paEG9jWIEj62Rl+3eqIbCqGWMwysOYvy660eFmBi0EvVD7ElSOMTxzNi9VihkRV0McAq5Skm5hpiGUeBjNIyTPT0u9NuAMXOsFBOuDkpl1Luwx7PfcPxzSw3zWocdrei3V9eYdGwjZupuBQoaYdtHRUqFXG2pFDyYXSAtOuM5v4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vLmEkgNi; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83C36C2BBFC; Thu, 13 Jun 2024 17:39:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718300352; bh=cM/32dqi6fZt6LQTmM2EuhniCZp3BnJkhJ9u/IvhkK4=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=vLmEkgNiXKte5/uSoWuxw8K2LivuOoveM9eY5IF53RdFd2/aHR3HPlsyeJbzOxJCM 0ab8T/A/5ugDDiTNIKpJUsZI5NNfA2P5ojQ6p4L9AOmyGZy7hmApe2Ie1KuPnd2oWQ kXNonU/JFutpllQ1SgrHvwSMciwJbVQ2fuUAAt4YrxDI6cXqqJmXwL82KdipaQUc/E 27x5unmbWSKF3Y27/q/MwCanDS7OIVp5BbCztEwJpnc1QSFA3CWP0Fu1cfZtxAyc7T fdohD6WjscUhX3c/2T1Lu6zPrXCytxcvyKT19RP1XnEvWL9VBWu28a3Yjg/+b/qIzM +1cPrEz6SQm/Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2E965CE0760; Thu, 13 Jun 2024 10:39:12 -0700 (PDT) Date: Thu, 13 Jun 2024 10:39:12 -0700 From: "Paul E. McKenney" To: Keith Busch Cc: Nilay Shroff , 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: Reply-To: paulmck@kernel.org References: <31eb40f9-d68d-4348-b1fd-3cf057939297@paulmck-laptop> <73b994eb-c689-48e0-b09c-a414041a0525@paulmck-laptop> <046f42c5-34b5-41a2-9680-5ef86ef25c01@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 Thu, Jun 13, 2024 at 10:10:38AM -0600, Keith Busch wrote: > On Thu, Jun 13, 2024 at 09:01:47AM -0700, Paul E. McKenney wrote: > > > > Is there a way to avoid this issue by making this be a statement parameter > > to a macro? > > Something like this? It appears to work for the intended use, at least. > > --- > diff --git a/include/linux/rculist.h b/include/linux/rculist.h > index 3dc1e58865f77..cdd2e5c0d5cdb 100644 > --- a/include/linux/rculist.h > +++ b/include/linux/rculist.h > @@ -204,6 +204,30 @@ static inline void list_replace_rcu(struct list_head *old, > old->prev = LIST_POISON2; > } > > + > +static inline void __list_cut_start(struct list_head *list, > + struct list_head *head, > + struct list_head *entry) > +{ > + list->next = entry; > + list->prev = head->prev; > + __list_del(entry->prev, head); > +} > + > +static inline void __list_cut_end(struct list_head *list, > + struct list_head *entry) > +{ > + entry->prev = list; > + list->prev->next = list; > +} > + > +#define list_cut_rcu(list, head, entry, sync) \ > + do { \ > + __list_cut_start(list, head, entry); \ At this point, old readers might see the new list starting from "head" and new readers see the new (shorter) list, again, starting from "head". Presumably no readers can yet see "list". > + sync; \ There are now no old readers, and thus no readers that can see any elements in the list starting from "entry". > + __list_cut_end(list, entry); \ And this fixes up the list now headed by "list". So: Reviewed-by: Paul E. McKenney And another argument for lambdas, not that there is a shortage of arguments against them. ;-) > + } while (0) > + > /** > * __list_splice_init_rcu - join an RCU-protected list into an existing list. > * @list: the RCU-protected list to splice > --