|
|
Subscribe / Log in / New account

Quotes of the week

The problem is that the current code enqueues the same structure onto up to four different lists, and we don't have a quantum computer, so head.next can't point to four different places.
Paul McKenney

I seldom use printk these days. It's far too limited in its uses. For one, most things worth debugging happen thousands of times a second, and printk will just slow things down to a crawl if it is used.
Steven Rostedt

to post comments

Next pointer inside the struct

Posted Sep 25, 2014 10:04 UTC (Thu) by epa (subscriber, #39769) [Link] (2 responses)

I've never understood the common preference for intrusive linked lists. Surely you define a struct with just the relevant fields, and if somebody wants to put it in a linked list they can do so easily by making a container struct which adds a 'next' pointer. There is no need to cruft up the object itself with the list housekeeping, which in any case breaks when you want to put it in several different containers, as happened here.

Next pointer inside the struct

Posted Sep 25, 2014 11:53 UTC (Thu) by andresfreund (subscriber, #69562) [Link] (1 responses)

That doesn't solve the problem. You still can't move it into more than one list - as you can't embed the same struct into multiple other ones without other users being aware of it. Sure, you can have containers with pointers to the actual element, but that rounds counter to the goal of not having pointer indirections and it makes lifetime management harder.

Next pointer inside the struct

Posted Sep 30, 2014 14:09 UTC (Tue) by nix (subscriber, #2304) [Link]

You can avoid this with a scheme whereby the list's per-item metadata is physically prepended to the content (sort of like container_of() only with the list metadata invisible to everything outside the list machinery, just like malloc()s metadata is invisible to everything outside it). Of course, this introduces a lot of complexity which may well not be necessary -- or, when it becomes clear it is necessary, the changes are scattered across so many disparate places that fixing it is out of the question. A sort of technical-debt tragedy of the commons.


Copyright © 2014, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds