public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
To: David Laight <david.laight.linux@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
	Randy Dunlap <rdunlap@infradead.org>,
	kernel@collabora.com, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] docs: document linked lists
Date: Mon, 07 Jul 2025 14:30:15 +0200	[thread overview]
Message-ID: <2391623.ElGaqSPkdT@workhorse> (raw)
In-Reply-To: <20250707101156.2cc84294@pumpkin>

On Monday, 7 July 2025 11:11:56 Central European Summer Time David Laight wrote:
> On Wed, 02 Jul 2025 22:24:47 +0200
> Nicolas Frattaroli <nicolas.frattaroli@collabora.com> wrote:
> 
> > The kernel contains various generic data structures that should ideally
> > not be reinvented. However, it often fails to document the usage of
> > these in the in-tree kernel documentation beyond just a listing of
> > header symbols in the very lengthy kernel-api docs page. This is fine
> > for things that have simple invocations, but occasionally things devolve
> > into several layers of concatenating macros, which are subpar for humans
> > to parse.
> > 
> > Begin making a small impact by adding some rudimentary example-driven
> > documentation for the linked list functions. Many aspects are covered,
> > though it is not an exhaustive listing of the entire set of list
> > operations. We also direct readers towards further documentation should
> > they be interested in concurrency.
> >
> 
> Jeepers; TLDR.
> I don't think the kernel docs are a place to explain linked lists.

That is not what this is doing. In fact, the very first paragraph
of the documentation page that was too long for you to read does
explain this. What are you trying to achieve with this response?

> What may be relevant is a description of the types of linked list
> the kernel uses.

That is what this is.

> For that you pretty much only need a picture of the head and two
> items showing both the forward and backward pointers.

No you don't, that does not explain the operations on them. The way
the kernel embeds nodes as struct members to then do a container_of
on is not obvious to many, as is evidenced by there existing out-of-
tree documentation explaining this very fact. The way this interacts
with how these list operations are called is worth documenting.

> Then a list of the valid operations for that list type.

Function names are not self-explanatory. That lists are circular and
how that can break traversal after list modifications is not immediately
evident.

> What you can (efficiently) do with a list depends very much on how
> it is constructed.

No. O-notation was invented for a reason. There is no way in which you
can construct a list to make it not a linear search, even if you sort
it.

> 
> Then repeat for hlist and hlist_nulls - I think they are the other
> main list types.
> 

hlist literally just lacks a single pointer in the head, it does not
differ from the kernel's doubly linked list in any meaningful way,
and would be an actual TL;DR.

> IIRC 'LIST' is a double-linked list through a dummy item.
> Not my favourite list type and can cause the sanitisers grief.

I don't see how your opinion on the datastructure is relevant here.

> 
> 	David
> 



  reply	other threads:[~2025-07-07 12:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-02 20:24 [PATCH v2] docs: document linked lists Nicolas Frattaroli
2025-07-03  1:37 ` Bagas Sanjaya
2025-07-03  2:52   ` Jonathan Corbet
2025-07-03  2:54     ` Bagas Sanjaya
2025-07-03  3:24 ` Bagas Sanjaya
2025-07-03  4:16   ` Randy Dunlap
2025-07-03  5:48     ` Bagas Sanjaya
2025-07-03  6:06       ` Randy Dunlap
2025-07-03  6:39         ` Bagas Sanjaya
2025-07-03  6:55 ` Randy Dunlap
2025-07-03 14:10 ` Jonathan Corbet
2025-07-04 20:53   ` Randy Dunlap
2025-07-07  9:11 ` David Laight
2025-07-07 12:30   ` Nicolas Frattaroli [this message]
2025-07-13  7:08 ` Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2391623.ElGaqSPkdT@workhorse \
    --to=nicolas.frattaroli@collabora.com \
    --cc=corbet@lwn.net \
    --cc=david.laight.linux@gmail.com \
    --cc=kernel@collabora.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox