Re: [PATCH] fs: use kmalloc() to allocate fdmem if possible

Avi Kivity
2010-05-03T09:18:28Z

On 05/03/2010 12:03 PM, Jiri Slaby wrote:
>
>
>>> Because vmalloc is used to allocate virtually contiguous memory. v in
>>> vmalloc means virtually.
>>>
>>>
>>>
>> A kmalloc()ed page is virtually contiguous, satisfying your requirement.
>>
> But it won't work well for vmalloc_to_{page,pfn} and similar.

Modify vmalloc_to_{page,pfn} accordingly.

> Some code
> may expect vmalloc result to be in the vmalloc area and page-aligned
> (both in position and size).
>

Both would be a bug IMO. vmalloc() follows kmalloc() and malloc() which
only guarantee natural alignment.

> Not that it won't be possible to inspect the callers, but in my eyes it
> would definitely be better to introduce kmalloc_or_vmalloc-alike where
> the caller explicitly doesn't care about the resulting position and size.
>

You're forcing every user to make a choice about what's essentially a
micro optimization.

If it's really needed to have a vmalloc-in-vmalloc-space, that should be
a special function, while the ordinary vmalloc should make the optimization.

--
error compiling committee.c: too many arguments to function