Index
Home
About
Blog
From: Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups: fa.linux.kernel
Subject: Re: [PATCH RFC] struct list_node
Date: Sun, 10 Jun 2007 17:20:52 UTC
Message-ID: <fa.a/11Kt9Yh0aIA5HSukjqnJvfpsQ@ifi.uio.no>
On Sun, 10 Jun 2007, Rusty Russell wrote:
>
> The current list.h has the same type for list elements and list heads
> even though most code and coders treat them as distinct.
I think the old list.h is technically superior to yours.
Exactly *because* nodes and heads are interchangeable.
In fact, you are incorrect that "most code" treat them as distinct. Most
code that uses list.h in fact uses it as a list of entries, often without
any head at all (and each *entry* is a point of removal), because the way
to actually *find* the structure that contains the lists is separate from
the lists themselves.
In other words, I think your patch is HORRIBLY BAD, because it totally
obscures the beauty of the current list.h implementation, and makes it be
something *average*.
The Linux kernel list.h is _better_ than most stupid list implementations
that think that a head node is different from the list node. Exactly
because it very naturally supports the notion of "this structure exists in
a 'ring of entries'" where each node is 100% equivalent to any other node,
and there _is_ no head.
And your patch totally misunderstands that, and breaks it.
Nack.
Linus
From: Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups: fa.linux.kernel
Subject: Re: [PATCH RFC] struct list_node
Date: Sun, 10 Jun 2007 20:20:06 UTC
Message-ID: <fa.AkE8GwKi0Fv42u3B2VggoFLMwXs@ifi.uio.no>
On Sun, 10 Jun 2007, Linus Torvalds wrote:
>
> The Linux kernel list.h is _better_ than most stupid list implementations
> that think that a head node is different from the list node. Exactly
> because it very naturally supports the notion of "this structure exists in
> a 'ring of entries'" where each node is 100% equivalent to any other node,
> and there _is_ no head.
Btw, to extend a bit on this: there actually *is* a "list with a head"
implementation in <linux/list.h>, called "hlist".
Now, the "h" actually historically stands for "hash", but if you prefer,
you can think of it as standing for "head", and be happy.
And if you want a head, you really do want to use "hlist", since the head
is smaller than a list entry (a single pointer rather than two).
And yes, I'm sure we could change some "struct list" users to "struct
hlist" if you wanted to.
Linus
Index
Home
About
Blog