Kernel Data Structures Linkedlist | by Uraj singh | Medium
Working as a kernel developer is interesting , you never know when you will encounter a macro or data structure that is subtle. One of these in my journey was how linked list abstraction is done in kernel. So lets start with how a programmer will generally use linked list and then move forward about doing it in kernel world. To be able to link each element of type struct mystruct to others, we need to add a struct mystruct *(next) field: Then you create structures , initialise the values and link those structures. This in nutshell will have structures and pointers to similar structure element. Let’s take a look at the kernel’s linked list API from the perspective of “how would I use it in my own code?” (e.g. a Loadable Kernel Module). Let’s start by defining a data structure in which we will embed kernel linked list: To be able to link each element of type struct mystruct to others, we need to add a struct list_head field: Well struct list_head is defined in include/linux/types.h as: I
11 min read Oct 17, 2018 -- Table of Contents Introduction Creating a doubly linked-list Looping it up ! Accessing the addresses of linked-list Where are other elements, “container_of ” to Rescue ? Demystifying “container_of” ! Finally bringing it all together. Wow ! Our little example now reads References History License Introduction Ordinary world Working as a kernel developer is interesting , you never know when you will encounter a macro or data structure that is subtle. One of these in my journey was how linked list abstraction is done in kernel. So lets start with how…
related reading
- Intrusive linked lists - Data structures in practicedata-structures-in-practice.com
- The Lost Art of Structure Packingcatb.org
- Linked list - Wikipediaen.wikipedia.org
- Inside NVIDIA GPUs: Anatomy of high performance matmul kernels - Aleksa Gordićaleksagordic.com
- Kernel modules - The Linux Kernel documentationlinux-kernel-labs.github.io
- Unreliable Guide To Locking — The Linux Kernel documentationdocs.kernel.org
- Linux kernel memory barriers — The Linux Kernel documentationdocs.kernel.org
- How to execute an object file: Part 1blog.cloudflare.com
- CS106B Linked Structuresweb.stanford.edu
- What happens when you run a CUDA kernelfergusfinn.com
- The true cost of linked lists · YKarroumykarroum.com
- Introduction - Learning Rust With Entirely Too Many Linked Listsrust-unofficial.github.io