Re: get_free_pages ??

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

 



On Wed, 2004-08-11 at 10:46 +0530, Ketan Mukadam wrote:

> Does the get_free_pages(), allocate memory in terms of "order" or in terms 
> of "pages"?
> To be more clear, can I precisely get 12(say) pages memory allocated or 
> will it always be in
> power of two, so that even if I give a size of 12K , I get 16K ??

The source, let alone just the prototype, answers this.

The second parameter is order.  So 0 = 2^0 = 1 page, 1 = 2^1 = 2 pages,
and so on.

If you want precisely 12 pages, you need to roundup to the nearest
power-of-two[1].  Or use get_free_page() to get 12 nonconsecutive pages.
Or just use kmalloc().

	Robert Love

[1] Buy why would you want 12 pages?  More likely you want that much
memory.  Don't wed yourself to PAGE_SIZE, instead just use kmalloc().



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[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