Buddy system - bitmap size calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have some time back started reading LINUX VM code.
From /usr/src/linux/mm/page_alloc.c
I find these lines in free_area_init_core()

Page buddy system uses "index >> (i+1)"
In a 16 page system

        0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

0 order  0  1  2  3  4    5    6    7

1 order    0      1      2          3

2 order            0              1

3 order                    0

Hence idx = page >> ( order + 1 )
For page 10
+++++++++++
0 order    idx = 10 >> ( 0 + 1 ) = 5th bit
1 order    idx = 10 >> ( 1 + 1 ) = 2nd bit
2 order    idx = 10 >> ( 2 + 1 ) = 1st bit
3 order    idx = 10 >> ( 3 + 1 ) = 0th bit

I can understand the computation logic used by buddy system.
However I could not follow remaining part of the comment.

bitmap_size = (size-1) >> (i+4);
i takes value for 0 to 9 since MAX_ORDER is 10 .
MAX_ORDER is 10 because the order can span from 0 to 9

Here size is zone size,for example zone_dma has a value 4096.

Can anyone please help me in understanding how the bitmap size
is calculated??

Thanks,
Sudharsan.

ARISE, AWAKE AND STOP NOT TILL THE GOAL IS REACHED


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux