Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp198288lqs; Thu, 13 Jun 2024 07:49:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXanUX+iupVmu2OtBCRIFl+RWPUNV1RM08x3dZ+tUtDjy2UQRHEKvK9QedfabU+awuxwTAmnNpGOlMF3B0SBsItrBEk8QlcH+xid8ALOg== X-Google-Smtp-Source: AGHT+IGJ+YMSCzvFL+0ns4Zf6X4zN2xyfqC/wKHZ8Q9yo1FIfJPn72illkb+1MLUP3izvRVQmKif X-Received: by 2002:a05:6e02:19cd:b0:374:593f:914a with SMTP id e9e14a558f8ab-375cd159914mr52708575ab.4.1718290141134; Thu, 13 Jun 2024 07:49:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718290141; cv=pass; d=google.com; s=arc-20160816; b=Gh+R6jmxOlsptHaPtvNdFMHIFcZ2GslYbd/2KMTgDuVluO4tl959jpK3J3r04qekXR SlQA4Or8sEQh9x46T0WOQCwfWgt69Nn+nTKoCaFhIPFWKVrf3h5azvz/M6iTU982d5s6 IcBAaoL0627OGGtxxXHDppw0tJZaAgJJdMnpFl1+hPv6f/LZum3iDvGjT93fCCGxv04j UxYnnSI2m1tL0qxljnLSFT92NJtWr1eh3b2abc6NQyQI9yB3BmO1VRm5fd89umskCMbc gehTujrSyrmQrhbC8EwqQ1He8MOA8gxddpLDqp2AbR1lbrYOdfFRcII+D612HMYzDXws Pj5A== 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=Wc+jXIVQJElTMxNHiUbAqz4/Ftbxlk2tFxkJaaD93i4=; fh=4xrGZ7Td1F3tJmTF0tfzw92P3bLonY51+1tWyQ7884c=; b=XNXyQMLDxTlOhEpd7eMi1CFXXLM3Dz+/ZXirSxcHKkg2QPeDzj1dkCPgkSBr8HTITo 7P71/jQmA2PhtSRE1WZSAhAApjS+NcAtKxSCX9GQCW4K1cvOQtrcbXMlsIpnNE3PZBiv SU6uMN13Hws8qyLtCqyiFsm/YZiLgf6a8691f4yK3scYMRLpE2/FHf8uJBXiMmcq9I6+ DjmJUywmlezCSL4vSFPIbE0v7URiLxd7KtqeGq1HF1XyJ7eGfg1AOd1AY+OjhZ1DVMBG UoN8fS8pFd+JFjS6aQSasQ6DsJPSYiRw8XjHyqPfGVAitlddPwh3DXL9FDNZVUBZdcQq RyKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hwg5ghc1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213458-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213458-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fee61fa85asi1534135a12.781.2024.06.13.07.49.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 07:49:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213458-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hwg5ghc1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213458-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213458-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 28AE62861C4 for ; Thu, 13 Jun 2024 14:48:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A7EA1465A4; Thu, 13 Jun 2024 14:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hwg5ghc1" 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 C07CE7E76D; Thu, 13 Jun 2024 14:47:29 +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=1718290049; cv=none; b=b0jv8JEFNznohwLcwi46wltLz6HjaDdYwzbvQWApN4z/GPUeTROh5OE6peIIkaDdP5rHYQhXbUhFidv5C1XsArDyRUXYTKWEVZ0d/t7Zp9IEIwpCsR4ktClfFgpQwZV1hUnHbWk6A+jbhAbjIXIY8knxeMuj3M9bzXKQ8U6unu4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718290049; c=relaxed/simple; bh=kjzDGOG2YXMGDf6L85vqKWOLSBd/y+drS146eunQElM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HkLDVXa705sal3g2VZx2CPT6uiOG5lNgK9qPYoV+jwaVfo21QmTkih570x5VwrumE52zzimQVKGSdtXcJw+rpodpap0dWenN5DXqMtAT/tgpDHXo82w+iMyeBElBQSFlg9dV3ENvIAs80Vfg9k6Mgxp92iZmMcxLqOfGTeb4268= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hwg5ghc1; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86B95C32786; Thu, 13 Jun 2024 14:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718290049; bh=kjzDGOG2YXMGDf6L85vqKWOLSBd/y+drS146eunQElM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hwg5ghc1ZNz7jjOf9igMuFsFU/zOhkMsDbUhpJuEz1nr7Kc/Za+nMY6fXggf3SUpM aw4j3b1+5GyFLkQbWkbTwfU4JCH1+A1gzgCGjBix+eoShbE1qQ9cKf3DXgGVLEMEWT q2VMZhj08lzDgA9MhyvRLAJezfO+L4uIt36v8Vb4XKEHKdGMJ1sHUuw/LDN0OL90nF 6UHNs/m9UjwnmOTm6RDX6OV5Gt8slm8BaGAQA3wqhADtRX6EQpY+FWHBfZUEKEEz3E VD/k6HAMaurA3jcAjhGup1iAsq4POeoJIX/nnOC73+DtUIgiCHUdzf3LTY7oUCUgMx nBZU+XpGCVEGw== Date: Thu, 13 Jun 2024 08:47:26 -0600 From: Keith Busch To: "Paul E. McKenney" 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: References: <20240612155135.3060667-1-kbusch@meta.com> <31eb40f9-d68d-4348-b1fd-3cf057939297@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: <31eb40f9-d68d-4348-b1fd-3cf057939297@paulmck-laptop> On Thu, Jun 13, 2024 at 07:43:35AM -0700, Paul E. McKenney wrote: > 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? That would work if we had a global srcu, but the intended usage dynamically allocates one per device the driver is attached to, so a void callback doesn't know which one to sync.