linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: Jonathan Corbet <corbet@lwn.net>,
	Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Cc: kernel@collabora.com, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] docs: document linked lists
Date: Fri, 4 Jul 2025 13:53:30 -0700	[thread overview]
Message-ID: <ef6e81fd-e609-41fd-b8b1-df629aa61b0f@infradead.org> (raw)
In-Reply-To: <874ivtmkk2.fsf@trenco.lwn.net>

Hi,

Just a few comments while I am still reviewing:


On 7/3/25 7:10 AM, Jonathan Corbet wrote:
> Thanks for doing this!
> 
> I have a few comments, most of which are just nits.  I think we should
> be able to get this in for 6.17.
> 
> Nicolas Frattaroli <nicolas.frattaroli@collabora.com> writes:
> 


>> diff --git a/Documentation/core-api/list.rst b/Documentation/core-api/list.rst
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..b0586056abb04d2bcc4518f7238ff9a94d3dd774
>> --- /dev/null
>> +++ b/Documentation/core-api/list.rst
>> @@ -0,0 +1,847 @@
>> +.. SPDX-License-Identifier: GPL-2.0+
>> +
>> +=====================
>> +Linked Lists in Linux
>> +=====================
>> +
>> +:Author: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>

> 
> I do wonder if you should start by showing the list_head structure
> itself?  It is simple enough and not a secret that needs to be kept.

+1

>> +Declaring and initializing a list
>> +---------------------------------
>> +
>> +A doubly-linked list can then be declared as just another ``struct list_head``,
>> +and initialised with the LIST_HEAD_INIT() macro during initial assignment, or
>> +with the INIT_LIST_HEAD() function later:
>> +
>> +.. code-block:: c
>> +
>> +  struct clown_car {
>> +          int tyre_pressure[4];
>> +          struct list_head clowns;        /* Looks like a node! */
>> +  };
>> +
>> +  /* ... Somewhere later in our driver ... */
>> +
>> +  static int circus_init(struct circus_priv *circus)
>> +  {
>> +          struct clown_car other_car = {
>> +                .tyre_pressure = {10, 12, 11, 9},
>> +                .clowns = LIST_HEAD_INIT(other_car.clowns)
>> +          };
>> +
>> +          circus->car.clowns = INIT_LIST_HEAD(&circus->car.clowns);

linked_lists.c: In function ‘circus_init’:
linked_lists.c:35:30: error: invalid use of void expression
   35 |           circus->car.clowns = INIT_LIST_HEAD(&circus->car.clowns);

due to
static inline void INIT_LIST_HEAD(struct list_head *list);

Should it just be:
		INIT_LIST_HEAD(&circus->car.clowns);
?

>> +
>> +          return 0;
>> +  }
>> +
>> +A further point of confusion to some may be that the list itself doesn't really
>> +have its own type. The concept of the entire linked list and a
>> +``struct list_head`` member that points to other entries in the list are one and
>> +the same.

> [...]
> 
> 
>> +Further reading
>> +---------------
>> +
>> +* `How does the kernel implements Linked Lists? - KernelNewbies <https://kernelnewbies.org/FAQ/LinkedLists>`_
> 
> I do still think you should move the kerneldoc for lists over from
> kernel-api.rst; just tack it onto the end here.

Ack.

-- 
~Randy


  reply	other threads:[~2025-07-04 20:53 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 [this message]
2025-07-07  9:11 ` David Laight
2025-07-07 12:30   ` Nicolas Frattaroli
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=ef6e81fd-e609-41fd-b8b1-df629aa61b0f@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=corbet@lwn.net \
    --cc=kernel@collabora.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.frattaroli@collabora.com \
    /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;
as well as URLs for NNTP newsgroup(s).