Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


(calculated bysize >> 1). The front half of the initial area is inserted in thefree_arealist for
order=4.

5
4
3
2
1

page

mem_map

Area

5
4
3
2
1

page

mem_map

Area

5
4
3
2
1

page

mem_map

Area

Figure 3-34: Steps performed byexpandwhen splitting a memory area.

Only the firstpageinstance of a memory area is needed by the buddy system for
management purposes; the size of the areais derived automatically from the list in
which the page is located.


  1. The index of the rear memory area withsize = 16can be calculated by addingsizetoindex,
    thus skipping the next 16 bits in the allocation bitmap. Because allpageinstances are in lin-
    ear succession in memory, the pointer topagemust also be increased by 16 to arrive at the
    correspondingpageinstance. The position of thepagepointer is indicated by an arrow in
    Figure 3-34.

  2. The next loop pass places the first half of the remaining 16 units on thefree_arealist with
    size=8.Bothindexandpageare then increased by 8 units. The function has now arrived at
    the desired size unit, and thepagepointer can be returned as the result. From the figure, it
    is evident that the last 8 pages of the original area of 32 pages are used; all other pages are in
    the appropriatefree_arealists of the buddy system.

Free download pdf