Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp56914lqp; Thu, 4 Apr 2024 07:05:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0DBu4VYe8+zAxb9Pjy97l8DQUqawoiATNoNfG7sHJWdwW1dPfpB0MfvWDXnzZ2MaXKt8+mrDjfVUQbpngkiBbJ1xsZZFGLcmuehlocw== X-Google-Smtp-Source: AGHT+IHQBGta+M4UT1uzmV/f3eQcWo5gIruFdIgq6K4P+GIbgRpUY6l10/PnlgekHiWQon24E/Qw X-Received: by 2002:ad4:5f87:0:b0:696:19d7:49ae with SMTP id jp7-20020ad45f87000000b0069619d749aemr2777867qvb.13.1712239552399; Thu, 04 Apr 2024 07:05:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712239552; cv=pass; d=google.com; s=arc-20160816; b=a8C5w3qhp/32++uhsLJELKBxahfEC0F8p5Jc/VYTrE/S1kA0chNd2FYYtwaw/z66Bv PqdxiQ9Pzf0YddskDXkLCqy9bZ19av/6ipZ4sUdZeiI+25ykY2uBNAwU/PUVI5cja9+g iS03ss2JF3rxa6fcj4S1SN1Q6AgUf3EHFV5lROVqXGigSGMQEIA1md53zwUR1VtfXA/9 Wwjwj5ZZwcz8765ONeF6GsmU6+nJ4jeA8Wyav9QrEoKkLhGRMvvy2XcfPDWGG9uT45a2 +hQh4Ktugg+yyJqBbrewM9jHB7+o7qAaT2V8VKy+BCfYeeJjxw+chNwN3e5eWOEKrXfQ Ep0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=bDF2zaMYbn25r5wA1TfRjMdRiEFg3+k+XSId485H2dY=; fh=8sHBn+0Dkx/XfhYG67+xZlTYYq+cwb+J1tw4PmXWkKY=; b=O//ip0zjuIdbRA3IuHiT59lQmEVluIq0+9vcKhPRApsQyGV8ymtNiprs2xcvwU1ckX +fUdXZA0bmcnvB5s2HY61ZiSGE8kbNfxaGmDukU7Ad3NurJeOSS6WLzcewQXqSWvJQDt QooYhtPY6qJzNwe2IwgOYHiFN5XL37zzUKj3ZALRaS56CyJf8i39yaNC9qZYveXoWx1p zfz+Vu7yXZEBPejWzd5CyAM1nNBXGccte3lFE9O7Pz+7Z82iBIZXCwjy9+PTwP4H5goh gzKUbrAedznh29wKHrjx8UNBlBGESVdRf6Rk4oUtRKhh6YASBqULi67+CMNExgdDMwhd dW8w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=mDxvgZgY; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-131548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t18-20020a0ce592000000b0069627b86c69si16286511qvm.292.2024.04.04.07.05.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 07:05:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131548-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=@google.com header.s=20230601 header.b=mDxvgZgY; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-131548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 548521C24582 for ; Thu, 4 Apr 2024 14:04:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A081D1272BB; Thu, 4 Apr 2024 14:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mDxvgZgY" Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 480C112883A for ; Thu, 4 Apr 2024 14:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712239432; cv=none; b=Vji1p0YJsqaMNbUZP4ugyDBjftufFFdrVjtb1V4EASa5e+wD0MvhqJb+O4SHQpDixRSIB/hqk1u9ifXRr9FnXQ3u2ZKsW01oSsKlUhtoiWe4+lggtWfUB+3d9AoX5eh72+dlg3iw1tkFhHrYIJAk6A1lwf9PLcG98WCPlrzMzRw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712239432; c=relaxed/simple; bh=vMu0LL9ltMkRityf3ku4FuM/lwy4EpU8+q5p5WfKSBI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=UzS+zXRbG+jRM5yaevcO9VctBflhijAslYYnCqzvcR8JffcA+FfEO13OaiYhNQ8GZ4dz6V6kqmklMOUvw4ukm64cQmm3wuUwvP/sLKoRZskkh5bjVGsFRc2OCvtq04l/uiAlzE5ZkZGCVOKw0xFH7DKyAj0InGudXJm/NHikul4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=mDxvgZgY; arc=none smtp.client-ip=209.85.219.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-69185f093f5so5721226d6.3 for ; Thu, 04 Apr 2024 07:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712239430; x=1712844230; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bDF2zaMYbn25r5wA1TfRjMdRiEFg3+k+XSId485H2dY=; b=mDxvgZgYCIElilxjr+QUpfhCI8gQmuewuIvsRJxMsWQhXHpUrzblEdwbFg2AmEvL/c 5JmaCkoc1Q0vkm/AzJ+57/YzEvOYj8qvi+FH4Exox0mo6kyzfuSymX+IeCsprtF375SH DU+Ji+YVnR7vKwXgNL43ZhzagdYLFHNQ/QA7GmMnBAMwzozEgv+5j7X0tQWc6lH8ysLY 5dd+8QjxzFeVFHllzcD+1XpETdCRWGof9mwa2srYAITYxHunXCEQgvgXc9TL071nbBiI JxPYPP9yjYWHKPyitj1qxbddu6PiNs4OOJ4zSutPG7D44xnFEXLmT1dZQscw35rfk54b O4wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712239430; x=1712844230; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bDF2zaMYbn25r5wA1TfRjMdRiEFg3+k+XSId485H2dY=; b=HjQhDlgEvDkv6qhaxJZCxiT1Z3I7LzCthitMiTskoUqq1dknTR0XKrp2AiaFv2Wa+q 2zauZbbXMM3/HVyYj8JGbc68RX4ljkdIF8eWrMr8bz/HjQ/ZxF95UakIQeAdlzQZNjH6 zSH2+5uVk7S3fAr5sndInhoz9duvPIdc2+dFHGgEckvNfoamwGvUdg+kJZXTHifAS/kb TSqJ3MGuTvTsWvem35Uz0qqf6mWEa94ykGjQvyLKUMli4++SZh4p5ZHV/cL5q2b97jbE na0UBcEptd2lPf/Te1r4jbSZ4bXzz2DvA7t5DRP6UYzZlrAnk6DHUFh1DlTBSDeJs4cO vctA== X-Forwarded-Encrypted: i=1; AJvYcCXUFNMYTfOIknZeYtIgiKaOQXHrdITYwFC15T7vcVYsfUeyOxKgyTCiXl3Ih+ZMNL49VwNrOjHWrR+qALA/eaEg5x+dw0tAcSPuWd+P X-Gm-Message-State: AOJu0Yy89uUxLbJ97LeF+eon3feJ8VoxDH6Jo2MZfP69SxX5MBDpdnx/ VJXnlYfY85TlZDS+Oop7NiDpJZ56JLpfMbU/MIsA/2Sqza5d1h9JRvqNOQHhoNVtVn1sNMuIqe7 1/a2B+gYeZc2Acz/+0eVitNcp3BwkGrMeOE0k X-Received: by 2002:a05:6214:d07:b0:698:6e84:95e5 with SMTP id 7-20020a0562140d0700b006986e8495e5mr2270945qvh.16.1712239425130; Thu, 04 Apr 2024 07:03:45 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240402-linked-list-v1-0-b1c59ba7ae3b@google.com> <20240402-linked-list-v1-3-b1c59ba7ae3b@google.com> <2500d66a-e54e-46d8-97cb-37fd9fc00c45@proton.me> In-Reply-To: <2500d66a-e54e-46d8-97cb-37fd9fc00c45@proton.me> From: Alice Ryhl Date: Thu, 4 Apr 2024 16:03:33 +0200 Message-ID: Subject: Re: [PATCH 3/9] rust: list: add struct with prev/next pointers To: Benno Lossin Cc: Miguel Ojeda , Andrew Morton , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Marco Elver , Kees Cook , Coly Li , Paolo Abeni , Pierre Gondois , Ingo Molnar , Jakub Kicinski , Wei Yang , Matthew Wilcox , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 3, 2024 at 5:57=E2=80=AFPM Benno Lossin wrote: > > On 02.04.24 14:17, Alice Ryhl wrote: > > +/// Implemented by types where a [`ListArc`] can be inserted int= o a `List`. > > +/// > > +/// # Safety > > +/// > > +/// Implementers must ensure that they provide the guarantees document= ed on the three methods > > +/// below. > > +/// > > +/// [`ListArc`]: ListArc > > +pub unsafe trait ListItem: ListArcSafe { > > + /// Views the [`ListLinks`] for this value. > > + /// > > + /// # Guarantees > > + /// > > + /// * If there is a currently active call to `prepare_to_insert`, = then this returns the same > > + /// pointer as the one returned by the currently active call to = `prepare_to_insert`. > > I was a bit confused by the term "active call to `prepare_to_insert`", > since I thought that the function would need to be executed at this > moment. I inferred from below that you mean by this that there has been > a `prepare_to_insert` call, but not yet a corresponding `post_remove` > call. > I did not yet find a better way to phrase this. > > I like putting the guarantees on the functions very much. How about this? If there is a previous call to `prepare_to_insert` and there is no call to `post_remove` since the most recent such call, then this returns the same pointer as the one returned by the most recent call to `prepare_to_insert`. Otherwise, the returned pointer points at a read-only [`ListLinks`] with two null pointers. Alice