Messages in this thread | | | Subject | Re: [PATCH] fs: use kmalloc() to allocate fdmem if possible | From | Eric Dumazet <> | Date | Mon, 03 May 2010 11:13:52 +0200 |
| |
Le lundi 03 mai 2010 à 11:49 +0300, Avi Kivity a écrit :
> A kmalloc()ed page is virtually contiguous, satisfying your requirement. >
Still, a different function pair is needed, at least for documentation reasons.
Changli, _many_ patches like yours were suggested and refused in the past for the reason it should be generic. Maybe its time...
So first introduce a pair of funtions, then we can use them.
At free time we can use is_vmalloc_addr() so that no extra bit is needed to tell if a zone was vmalloced() or kmalloced()
One remark :
+ data = kmalloc(size, GFP_KERNEL);
If allocation fails (because of fragmentation), we would have a kernel log. Still, vmalloc() might be OK. So you should add a __GFP_NOWARN flag.
/* * Warning: if size is not a power of two, kmalloc() might * waste memory because of its requirements. */ void *kvmalloc(size_t size) { void *ptr = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
if (ptr) return ptr; return vmalloc(size); }
void kvfree(void *ptr) { BUG_ON(in_interrupt()); if (is_vmalloc_addr(ptr)) vfree(ptr); else kfree(ptr); }
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |