login
Header Space

 
 

__get_free_pages in kernel 2.4 vs kernel 2.6

June 4, 2008 - 8:37pm
Submitted by Anonymous on June 4, 2008 - 8:37pm.
Linux

Hi Y'all,

I am porting a framebuffer driver from kernel 2.4.19 to 2.6.19 in which __get_free_pages() is used to allocate 0x915d40 bytes (apprx 2300 pages) of GFP_ATOMIC memory.

Trying to use the function as is in kernel 2.6 gives me "allocation failed" error. I tried to use kmalloc but I guess kmalloc cannot allocate such a huge chunk.

Can anyone tell me why __get_free_pages() is failing? Is there any other way I can get the huge chunk other than __get_free_pages?

Thanks,
KT

why?

June 5, 2008 - 12:33am

why GFP_ATOMIC? why do you say "allocate GFP_ATOMIC memory" instead of "GFP_ATOMIC allocate memory"?

I only meant to say that

June 5, 2008 - 2:13pm
Anonymous (not verified)

I only meant to say that flag being passed to __get_free_pages is GFP_ATOMIC

still 'why?'

June 5, 2008 - 2:21pm

i understood this but i have to ask again why are you doing that? what do you try to accomplish?

GFP flags

June 6, 2008 - 4:08pm
Ferdinand (not verified)

It's pretty clear that what Anonymous is trying to accomplish is to port a driver that somebody else wrote.

In the initialization code, change GFP_ATOMIC to GFP_KERNEL and give it a try.

Hello Ferdinand, You were

June 6, 2008 - 10:05pm
Anonymous (not verified)

Hello Ferdinand,

You were right I was porting somebody else's framebuffer driver and I solved the reason why __get_free_pages is failing.

The problem is the number of pages the driver is requesting via __get_free_pages() which is 1 more than MAX_ORDER used by alloc_pages().

And MAX_ORDER is defined in include/linux/mmzone.h as

#ifndef CONFIG_FORCE_MAX_ZONEORDER
#define MAX_ORDER 11
#else
#define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER
#endif

Defining CONFIG_FORCE_MAX_ZONEORDER to the number of pages the driver needs helped solve the problem. It does not matter whether you use GFP_ATOMIC or GFP_KERNEL.

Thanks,
KT

Question still remains.. why you can't do without GFP_ATOMIC

June 9, 2008 - 7:28am
manishsharma (not verified)

Hi,

I really appreciate the way you came up with the solution.. but you want you are using GFP_ATOMIC.... i guess you can do without it.. or you have some other purpose

Manish

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
speck-geostationary