Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp190997lqs; Thu, 13 Jun 2024 07:36:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUxX0fHrrOEsHGRJnT4k9i4DjQJDewgHwiS39WQViVQU9dAOoPV+PRbyGFu0SSD8U3uNgO1pyVWPEmU+cNrLvB5ApVbPdTaPCWi+Q4E4g== X-Google-Smtp-Source: AGHT+IExg+FjO0KRO1u6ugvyCPSxxUcqBryWX+g4KZPvt5dCu9CV9YGq3eeUGtPrgSi7vJ7s1x+F X-Received: by 2002:ad4:4f50:0:b0:6b0:72ef:2869 with SMTP id 6a1803df08f44-6b2af2713f5mr367056d6.13.1718289414331; Thu, 13 Jun 2024 07:36:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718289414; cv=pass; d=google.com; s=arc-20160816; b=Wf1n3tPr0xMBE7ycVkpGwYsyYSGbozaKJ19gnIzk7dTsWzFnxKVREcNg83CAUdDth3 wlZwh75kt9Lrhn2qsEei7beNyRfcQ5epooxmmYIy2nFhX57mdB68kFdX+jluNT7tu0gQ +19++K0cOkqRyXEEhKD7qsbC/suGYCaGKxqIBkiqQSlbUI7Fk5/0mqjmfnlXKM15cqlS R4tYR2WYoxp+Z2Ms8I0PwLB8o5Bn1/Qgpomq6v/fn5mUEz69+Wsl+tQLJFBuUXQ+pFWt fy41u57/qA4CvNHWCLmlqfMcNlptehPgvl3VgQPaE2x6b/rMoj74qU2ZGxqgnnF7x6D0 v8bA== 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:message-id:subject:cc :to:from:date:dkim-signature; bh=bTYotPHvHWVXw+fYClqVZTE0/nCfD9CSGXNMPSPSoa8=; fh=h4Cx2Z+nYi5Bbq5zbdSN1dw5p927ORzLHtwc7nckDfM=; b=F9o1oukw+ep/XzxX3scu6DbbEI9DlQ8t51B2c4XKUkfqumQHWpY74zVBykqXHIY/1i xJrFofFGYHYQwUVeW3kbll4Bb0FXb18nRZJ6xWdyJmhQ5NpqYtVZH2n4bSoL2+Dmg1hA ZhFGlrxnXApzd0UvV8hLhQdofGQMrbe3Fom1CIDTRkLzUeCmB3emt0BoPZGfKD+puNlg 2d/WH/yhxDtlw8xXAkJ0NCSDC0QEUxZUo/f6R3RPyRlugEvMRi7pPnmgAduOF4HGtE3M gcP2Dz6yvhruOky65PVJ5hTeaJXMJC+O8sioN/2ln9nTyT6BAvy0u7W6lbHvjo8QYQgT oQkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tHXYhS3F; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213433-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213433-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 d75a77b69052e-441f30f8451si16895251cf.675.2024.06.13.07.36.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 07:36:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213433-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=tHXYhS3F; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213433-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213433-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 A50041C226B3 for ; Thu, 13 Jun 2024 14:36:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90B61145B0F; Thu, 13 Jun 2024 14:36:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tHXYhS3F" 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 BA5DA1DFFC; Thu, 13 Jun 2024 14:36:47 +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=1718289407; cv=none; b=sOycGs2p6UUVOLqiRqBYJ6UjQ+83cbSCB8+RF0gek9jyesfca4j9lAy9kAJJQHygeOu76YNWZX8nPY0nvsN2VZIaEmGXValkY0JFUa/L9h5XOhN7X5+i/P0ps772biquShBSV4s+sytO9jE/51Nnlc5OsR1JpGoJtD9SVNHWqvo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718289407; c=relaxed/simple; bh=rQcVPloL/Qc1hVR24fDLFbTfgfjeOTVGfBNjrvJqCKg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OKXB4l/aIqwMnnQ8YQ3vlGT6Mukiv+6nquQA+vEo2afdtMBzvauHXhlB9LYWQBgDs5IHjSJgPANGUyEixNrJX9WdigQy/M6l6CsBridYJjeAAkkR3Jk79MmLcg3mLa2pFX40kms3zQzBnxlxMUOflgmEW+Rg1DrHRwsVVfwX9kE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tHXYhS3F; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67FE7C32786; Thu, 13 Jun 2024 14:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718289407; bh=rQcVPloL/Qc1hVR24fDLFbTfgfjeOTVGfBNjrvJqCKg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tHXYhS3FyCg5LtOYUzUGQo269no97821yMFOzr5aoyMK5ag4u+Bo1AEMSPa5nmZmQ /z9H8kgfXctKvahUS760ZjpZ+IwyGTma5OACP9bxYqIi9DbejHs4vIU8UHtZRe1QoI tpu+04e+hBOuPqDX2xnqkKgw34Pr/+16i3R2d9FLly8qJrJkT/Ky7L/cI48MVLNc4h lTx/6GIN+5/7GZmI37lEUxT/4DRtBtLXz8zbsGgabSZxEWU7610Ge69hGto9raY6uS a9ajo23fKqksXsoifnMLYh8TAu0Peoc6pj7e5/JG6cEWJ8ODsVOl2NcRiLzwMyx43q hz1MLElRsZvHw== Date: Thu, 13 Jun 2024 08:36:44 -0600 From: Keith Busch To: Nilay Shroff , l@kbusch-mbp.dhcp.thefacebook.com Cc: Keith Busch , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, hch@lst.de, sagi@grimberg.me, paulmck@kernel.org, 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: 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 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.