Not a long ago I had one of those humiliating moments when a simple question makes you numb a or even worse – you begin to mumble an absolute rubbish. That is exactly what has happened to me recently and being an afterthought person (which, of course, doesn’t give me any advantage) I decided to do some homework/recap o the questions I’ve failed miserably.
- Linux PIPE
- First, take a look at struct pipe_buffer.
- Then study how an inode object and two file objects are created for pipe to work create_pipe_files().
- Linux VM overcommit
– Read vm sysctl documentation about the swappiness parameter.
– swappiness comes into play in get_scan_count() which is called from shrink_lruvec().
– If the code looks murky, take a look at the answer published at unix.stackexchange.com which goes in a greater details about vm.swappiness.
– Read about Split LRU
– Read “man 2 pipe” as it basically says it all in a single sentene:
pipe() creates a pair of file descriptors, pointing to a pipe inode, and places them in the array pointed to by filedes. filedes is for reading, filedes is for writing.
– Want to go deeper then the source code is the best place to start:
– Again, start from reading the documentation.
– Take a look at the code to figure out how the heuristic overcommit handling works. Especially, __vm_enough_memory() which is run by security_vm_enough_memory_mm(), which in turn could be called from different places, e.g. mmap_region(), acct_stack_growth(), do_brk(), insert_vm_struct(), dup_mmap().
– “man 3 malloc”, “man 2 mallopt”
– Go through do_brk() code.
And of course, buy, read and re-read Understanding the Linux Kernel even if it’s a bit dated.