any local implementations of linked lists?
as i'm currently perusing the implementation of the kernel linked
list, it occurred to me to wonder if there are still parts of the kernel that insist on implementing their own design unnecessarily (which they're not supposed to do). anyone know of any such examples, out of curiosity? thanks.
rday
--
====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
Have classroom, will lecture.
http://crashcourse.ca Waterloo, Ontario, CANADA
====================================
Quoted 6 lines · Robert P. J. Day
as i'm currently perusing the implementation of the kernel linked
list, it occurred to me to wonder if there are still parts of the kernel that insist on implementing their own design unnecessarily (which they're not supposed to do). anyone know of any such examples, out of curiosity? thanks.
There are a lot of occurrences of structures that have a field of type pointer to the structure, often with the suggestive name "next". But at least some of them have only a next field and no prev field. Are you interested in them anyway?
An example is:
arch/um/include/aio.h
struct aio_context {
int reply_fd;
struct aio_context *next;};
julia
Quoted 3 lines · Julia Lawall
There are a lot of occurrences of structures that have a field of type pointer to the structure, often with the suggestive name "next". But at least some of them have only a next field and no prev field.
Which suggests that they're single-linked lists on purpose.
Quoted 14 lines · Julia Lawall
Quoted 6 lines · Robert P. J. Day
as i'm currently perusing the implementation of the kernel linked
list, it occurred to me to wonder if there are still parts of the kernel that insist on implementing their own design unnecessarily (which they're not supposed to do). anyone know of any such examples, out of curiosity? thanks.There are a lot of occurrences of structures that have a field of type pointer to the structure, often with the suggestive name "next". But at least some of them have only a next field and no prev field. Are you interested in them anyway?
Quoted 8 lines
An example is:
arch/um/include/aio.hstruct aio_context { int reply_fd; struct aio_context *next;};
based on my own grepping, i noticed a zillion of those things -- i'm just thinking that some of them are probably local implementations of a linked list structure that could be rewritten using the in-kernel linked list structure defined in <linux/list.h>.
i doubt that could be done quickly -- it's undoubtedly a long-term project that could be transformed little by little as people run across examples of it. just something to keep an eye out for if you're feeling ambitious.
rday
--
====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
Have classroom, will lecture.
http://crashcourse.ca Waterloo, Ontario, CANADA
====================================
Quoted 30 lines · Robert P. J. Day
Quoted 14 lines · Julia Lawall
Quoted 6 lines · Robert P. J. Day
as i'm currently perusing the implementation of the kernel linked
list, it occurred to me to wonder if there are still parts of the kernel that insist on implementing their own design unnecessarily (which they're not supposed to do). anyone know of any such examples, out of curiosity? thanks.There are a lot of occurrences of structures that have a field of type pointer to the structure, often with the suggestive name "next". But at least some of them have only a next field and no prev field. Are you interested in them anyway?
Quoted 8 lines
An example is:
arch/um/include/aio.hstruct aio_context { int reply_fd; struct aio_context *next;};
based on my own grepping, i noticed a zillion of those things -- i'm just thinking that some of them are probably local implementations of a linked list structure that could be rewritten using the in-kernel linked list structure defined in <
linux/list.h>.
Quoted 4 lines
i doubt that could be done quickly -- it's undoubtedly a long-term project that could be transformed little by little as people run across examples of it. just something to keep an eye out for if you're feeling ambitious.
The question still stands, though. list_head has both next and prev fields. Is it desirable to convert a singly linked list to a doubly linked list just for the benefit of using the functions in list.h, at a cost of more memory?
I found 89 files that declare a structure with multiple self-pointer-typed fields, and over 400 more that declare a structure with only one self-pointer field. Perhaps there is a need for an API for singly-linked lists as well? Or perhaps they are too simple to be worth it?
Another common pattern is a next field and a parent field. Those should probably not be converted either, for readability, even if doing so would be correct.
julia
Quoted 6 lines · Alexey Dobriyan
Quoted 3 lines · Julia Lawall
There are a lot of occurrences of structures that have a field of type pointer to the structure, often with the suggestive name "next". But at least some of them have only a next field and no prev field.
Which suggests that they're single-linked lists on purpose.
right, i was going to mention that. my original query related to local implementations of linked lists that deserve to be replaced by the in-kernel implementation, and that would normally apply only to doubly-linked lists.
rday
--
====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
Have classroom, will lecture.
http://crashcourse.ca Waterloo, Ontario, CANADA
====================================
Quoted 4 lines · Julia Lawall
The question still stands, though.
list_headhas both next and prev fields. Is it desirable to convert a singly linked list to a doubly linked list just for the benefit of using the functions inlist.h, at a cost of more memory?
i'm guessing no. given how many potential places there are for converting *doubly* linked lists, i would leave singly linked lists alone.
rday
--
====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
Have classroom, will lecture.
http://crashcourse.ca Waterloo, Ontario, CANADA
====================================