Question: From *Understanding the Linux Kernel*:

> 
> the Linux kernel defines the list\_head data structure, whose only
>  fields next and prev represent the forward and back pointers of a
>  generic doubly linked list element, respectively. It is important to
>  note, however, that the pointers in a list\_head field store the
>  **addresses of other list\_head fields** rather than the **addresses of
>  the whole data structures in which the list\_head structure is
>  included**; see Figure 3-3 (a).
> 
> 
> 

[![enter image description here](https://i.stack.imgur.com/BOxvn.png)](https://i.stack.imgur.com/BOxvn.png)

Why do the pointers in a list\_head field store the addresses of other list\_head fields rather than the addresses of the whole data structures in which the list\_head structure is included? 

Given a pointer to a `list_head` object, how can I get the object of a data structure (such as "data structure 1") which contains the `list_head` object? For example, [How can I get the process descriptor from a PID in Linux kernel?](https://stackoverflow.com/questions/52361029/how-can-i-get-the-process-descriptor-from-a-pid-in-linux-kernel)

If it were in a OO language, is it that the list\_head fields would likely be private in the data structures in which the list\_head structure is included? So is it more reasonable that the pointers in a list\_head field store the addresses of the whole data structures in which the list\_head structure is included than the addresses of other list\_head fields?

Answer: 
> 
> Why do the pointers in a list\_head field store the addresses of other
>  list\_head fields rather than the addresses of the whole data
>  structures in which the list\_head structure is included?
> 
> 
> 

Because it is logically right and easier to implement. You don't need to know the type to iterate the list. Also list head is not embedded into any structure. What should it point to when list is empty?

> 
> Given a pointer to a list\_head object, how can I get the object of a
>  data structure (such as "data structure 1") which contains the
>  list\_head object?
> 
> 
> 

Using [container\_of](https://stackoverflow.com/questions/15832301/understanding-container-of-macro-in-the-linux-kernel) macro.
`list_head` stores pointer to next/prev list nodes.
One data structure can be placed in more then one list using more then one `list_head` elements in it.
Processing code "knows" which of these elements placed into given list and can restore pointer to data structure from pointer to node using [`list_entry`](https://elixir.bootlin.com/linux/v2.6.11/source/include/linux/list.h#L320).