lkml.org 
[lkml]   [2010]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] mm: generic adaptive large memory allocation APIs
On 05/13/2010 06:45 AM, KOSAKI Motohiro wrote:
> Hi
>
>> void *kvmalloc(size_t size)
>> {
>> void *ptr;
>>
>> if (size < PAGE_SIZE)
>> return kmalloc(PAGE_SIZE, GFP_KERNEL);
>> ptr = alloc_pages_exact(size, GFP_KERNEL | __GFP_NOWARN);
>
> low order GFP_KERNEL allocation never fail. then, this doesn't works
> as you expected.

Hi, I suppose you mean the kmalloc allocation -- so kmalloc should fail
iff alloc_pages_exact (unless somebody frees a heap of memory indeed)?

>> if (ptr != NULL)
>> return ptr;
>>
>> return vmalloc(size);
>
> On x86, vmalloc area is only 128MB address space. it is very rare
> resource than physical ram. vmalloc fallback is not good idea.

These functions are a replacement for explicit
if (!(x = kmalloc()))
x = vmalloc();
...
if (is_vmalloc(x))
vfree(x);
else
kfree(x);
in the code (like fdtable does this).

The 128M limit on x86_32 for vmalloc is configurable so if drivers in
sum need more on some specific hardware, it can be increased on the
command line (I had to do this on one machine in the past).

Anyway as this is a replacement for explicit tests, it shouldn't change
the behaviour in any way. Obviously when a user doesn't need virtually
contiguous space, he shouldn't use this interface at all.

thanks,
--
js
suse labs


\
 
 \ /
  Last update: 2010-05-13 10:45    [W:0.098 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site