From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 85C4918C33 for ; Sat, 21 Feb 2026 08:59:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771664359; cv=none; b=uFltTA0gkUrIap8VcxwsGiks55F9yVIxKnDzyVb7+BnUmFyO/esMpJsdeYczkaNjfkEoBMu9SG86vR2aYyucr1wIfW8wjlDjDm66sdK4FscOOyG+RytqKZefwevacJiIQyW8jzMP1ZI1E+jYcs5ILE//r3g+G5PiX/v+vKv7zxA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771664359; c=relaxed/simple; bh=gFh8xuSc1dOKs5gKk6gqPmmHdoqd/hicr6x62pPVBMo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YPyTivLCEQMm4rIiwhANy/b39tJra4Twwu6liGmAXddA/N0AjgYw4CHEWUPHiuQjXTVWyILp4qmfvSZPq6+8GT0wjNsj78MKS643UtIOCi0gotbcMC7syE0PapdBnMdGqHS/BClCDxGpydcyZBGsmj2VI5zUAhOv2rqv/5QKpXo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=UKSPjuKu; arc=none smtp.client-ip=209.85.128.73 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=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UKSPjuKu" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4836b7c302fso23220845e9.1 for ; Sat, 21 Feb 2026 00:59:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771664357; x=1772269157; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6zMqqgKoh/9hUmXKLa8W/Ktm8MqMG46VT0cs/LJ1MPQ=; b=UKSPjuKuSV0XqhQqJCFnWsBQqsdYirpjZqRmWMZaJHkHKhF+PtjgfiRGL56B5P27cc bo/zbmNz7UdW5PhkVoKacIogtkNJkcTzYhgULURH/hH8ckmIyXdMXmPTtLL8rXb5VYzI S2/GK24RHb1HfI2zQ/Gzz7lbbJyTvACpKUwNPs3J1f5+WARfgbnXZ0WTzIFliwC1tFJf riNcOFkNk+W41NHM3cPSaJpHmTkZsKEuwdM7MNdP3NZ4IFWT7zvLqac3uvAaDIgy435s Y32aHszKhoNdKaufkY0A1qUByOBt01/S8u2/pnYlxqwztOha4IJGHDeMqwdJHpzrPRU1 zFOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771664357; x=1772269157; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6zMqqgKoh/9hUmXKLa8W/Ktm8MqMG46VT0cs/LJ1MPQ=; b=L2aZAAa+Rh9P6hsdTRZpmJKJAqnxs9+QctHQzALXtAEFDA3ds6hR90EPudNFCoxZaZ KNAqFY7uMPpKepj9N9EBYmxbF2Vf7izfc6FX4t/f0hevw1V0H9vuV8jq9g2ZNfAyD39j qliAeB18uRQg12B2p1R3ZigzF3fwcDgNoRcheDfdicdcu6+oGhAWEf2vgBs5820rwNyD xf/6Cp4NmO4bGvJ6/pChxkM2ZPWLTZGdohponmeWJqeUUn46d2EfdrXM6IHuqodxkIeb XlAC/FAAmVSYePvmX2LNVUtJnT3qakGPDwepG7Ctk/x2NQZVW7Tu3/le/atKLSvmeeBB AOMQ== X-Gm-Message-State: AOJu0YxZD2NKo/hEBWYpsES3FN6vvXeOXBsbjQ4y4XNe5TSxTydAEDiz 1+L4viMWYkgCqZ360sTk4XjXLGQZ+sGmL4H1KcgLMEeWkaHcaSPij0zMTrRtNIyLAl712aDczdz D5Zbt+b1V9SuJhKfDUg== X-Received: from wmbz1.prod.google.com ([2002:a05:600c:c081:b0:483:6f89:e2c8]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1e09:b0:480:25ae:9993 with SMTP id 5b1f17b1804b1-483a962e3c9mr39685415e9.20.1771664356547; Sat, 21 Feb 2026 00:59:16 -0800 (PST) Date: Sat, 21 Feb 2026 08:59:15 +0000 In-Reply-To: <20260218205507.689429-6-joelagnelf@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260218205507.689429-1-joelagnelf@nvidia.com> <20260218205507.689429-6-joelagnelf@nvidia.com> Message-ID: Subject: Re: [PATCH v10 5/8] rust: clist: Add support to interface with C linked lists From: Alice Ryhl To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Alexandre Courbot , Dave Airlie , Daniel Almeida , Koen Koning , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, rust-for-linux@vger.kernel.org, Nikola Djukic Content-Type: text/plain; charset="utf-8" On Wed, Feb 18, 2026 at 03:55:03PM -0500, Joel Fernandes wrote: > Add a new module `clist` for working with C's doubly circular linked > lists. Provide low-level iteration over list nodes. > > Typed iteration over actual items is provided with a `clist_create` > macro to assist in creation of the `CList` type. > > Cc: Nikola Djukic > Reviewed-by: Daniel Almeida > Acked-by: Gary Guo > Signed-off-by: Joel Fernandes In general this looks like a useful tool to write other abstractions, so that's good. A few nits below. Also, I think it would make more sense to split this series into two with titles like this: * Add clist helper for writing abstractions using C lists * Move buddy alloctor one level up That way, you can tell what the series actually does from its title. Yes, the 'why' of a series is very important, and must be included in the cover letter or commit messages, but I think the title of a series should explain the 'what', not the 'why'. > +impl CListHead { > + /// Create a `&CListHead` reference from a raw `list_head` pointer. > + /// > + /// # Safety > + /// > + /// - `ptr` must be a valid pointer to an allocated and initialized `list_head` structure. > + /// - `ptr` must remain valid and unmodified for the lifetime `'a`. > + /// - The list and all linked `list_head` nodes must not be modified by non-Rust code > + /// for the lifetime `'a`. I don't think C vs Rust is useful here. What you want is that the list is not modified by random other code in ways you didn't expect. It doesn't matter if it's C or Rust code that carries out the illegal modification. > +// SAFETY: [`CListHead`] can be sent to any thread. > +unsafe impl Send for CListHead {} > + > +// SAFETY: [`CListHead`] can be shared among threads as it is not modified > +// by non-Rust code per safety requirements of [`CListHead::from_raw`]. > +unsafe impl Sync for CListHead {} Same here. If another piece of Rust code modifies the list in parallel from another thread, you'll have a bad time too. C vs Rust does not matter. Alice