Article directory
1. The memory allocation process of the partner allocator
The partner allocator allocates/ releases physical pages in units of "orders" ;
Order (Order): the unit of the number of physical pages, nnn -order page blockrefers to2 n 2^n2n consecutive"physical pages";
Page/order concept reference [Linux Kernel Memory Management] Partner Allocator ① (Partner Allocator Introduction | Page Block, Order | Partner) Blog;
"Buddy allocator" allocates memory process: suppose to allocate nnn -order page blocks;
1. Query n-order page blocks
Query whether there is currently free nnn -order page blocks,
- If there is, assign it directly ,
- If not, go to the next step, query n + 1 n + 1n+1st order page block;
2. Query n + 1 order page blocks
Query whether there is currently free n + 1 n + 1n+1st order page block,
-
If there is, put n + 1 n + 1n+Tier 1 Page Blocks Divided into 2 22 nn_n -order page blocks,
- one piece insert free nnn -order page block linked list;
- A block is allocated directly ,
-
If not, go to the next step, query n + 2 n + 2n+2nd order page block;
3. Query n + 2-order page blocks
Query whether there are currently free n + 2 n + 2n+2nd order page block,
-
If there is, put n + 2 n + 2n+Level 2 Page Blocks Divided into 2 22 n+ 1 n + 1n+1st order page block,
- Block Insert Freen + 1 n + 1n+1st -order page block list;
- A block will be n + 1 n + 1n+Tier 1 Page Blocks Divided into 2 22 nn_n -order page blocks,
- one piece insert free nnn -order page block linked list;
- A block is allocated directly ,
-
If not, go to the next step, query n + 3 n + 3n+3rd order page block;