tcp_init函数的一点疑问
if (num_physpages >= (128 * 1024))
goal = num_physpages >> (21 - PAGE_SHIFT);
else
goal = num_physpages >> (23 - PAGE_SHIFT);
for (order = 0; (1UL << order) < goal; order++)
;
do {
tcp_ehash_size = (1UL << order) * PAGE_SIZE /
sizeof(struct tcp_ehash_bucket);
tcp_ehash_size >>= 1;
while (tcp_ehash_size & (tcp_ehash_size - 1))
tcp_ehash_size--;
tcp_ehash = (struct tcp_ehash_bucket *)
__get_free_pages(GFP_ATOMIC, order);
} while (!tcp_ehash && --order > 0);
这段代码是确定order值,最终通过order值,确定可以存储的tcp_ehash_bucket结构数目,通过__get_free_pages函数分配该结构所需的页面空间。
但是我不知道order为什麽需要这样确定?依据是什么?哪里有相关的参考信息? order is number of pages. it has to be 2(x) which is required by binary buddy allocator the kernel uses. 从上面这段代码看,并不能保证是order是2的倍数呀。
另外,为什麽内存大于512M时是21-12呢?小于时是23-12呢? sorry, order is the exponent of 2, 2^order is the number of the pages requested. guess: greater than 512MB, ehash size can be 1/512 of total memory
less than 512, ehash size can be 1/2048 of the total. thanks!
页:
[1]