2017-12-6 10:26:50
4.9.51
int __get_order(unsigned long size)
{
int order;
size--;
size >>= PAGE_SHIFT;
#if BITS_PER_LONG == 32
order = fls(size);
#else
order = fls64(size);
#endif
return order;
}
1.3.100 __get_order@drivers/block/floppy.c
*/
/* Pure 2^n version of get_order */
static inline int __get_order(unsigned long size)
{
int order;
size = (size-1) >> (PAGE_SHIFT-1);
order = -1;
do {
size >>= 1;
order++;
} while (size);
return order;
}
注:返回值order
块系数k以2为底的对数,[0, NR_MEM_LISTS]
块大小:PAGE_SIZE*k
计算order: order = log2k, k=2^n, 则order=n
k=1 n=0
k=2 n=1
k=4 n=2
k=8 n=3
k=16 n=4
k=32 n=5