Linux memory page size

When using a memory, a memory to remember PAGE_SIZE byte page is not 4KB. 4KB page size is assumed and this value is hard-coded a PC programmer common mistake, on the contrary, supported platforms show page size from 4 KB to 64 KB, and sometimes their different implementations different on the same platform. macros are associated PAGE_SIZE and PAGE_SHIT. which comprises a number of bits to obtain an address shift its page number. for 4KB or larger the current page number is 12 or more macros are defined in <asm / page.h>; the user can use the space getpagesize library functions, if they need this information.

 

Let's look at non-normal circumstances, if a driver needs 16 KB for temporarily storing data, it should not specify a

Index 2 to get_free_pages you need a portable solution to such a solution, fortunately, has been written by the kernel developers and called get_order..:

 

#include <asm/page.h>

int order = get_order(16*1024);

buf = get_free_pages(GFP_KERNEL, order);

 

Remember, get_order parameter must be a power of two.

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11146090.html