Linux Kernel - Per-CPU Storage
# Prerequisites
# Preface
On multiprocessor, each cpu has its own storage of all global variables, e.g. they have different addresses while running on different cpus. For example, each cpu schedules processes separately and has their own runqueues; Obviously, though statically sharing the same identifier, the per-cpu runqueues should be stored in different addresses.
Linux kernel provides convenient APIs for creating and accessing per-cpu variables, which prevent developers from misunderstanding and misuse of them.
# References
https://0xax.gitbooks.io/linux-insides/content/Concepts/linux-cpu-1.html
https://www.kernel.org/doc/html/latest/core-api/this_cpu_ops.html
https://stackoverflow.com/questions/16978959/how-are-percpu-pointers-implemented-in-the-linux-kernel
https://elixir.bootlin.com/linux/latest/ident/PER_CPU_BASE_SECTION
- 01
- Reading Papers - Kernel Concurrency06-01
- 02
- Linux Kernel - Source Code Overview05-01
- 03
- Linux Kernel 88 - Macros05-01