Re: [PATCH] streq()

Denis Vlasenko (vda@port.imtp.ilyichevsk.odessa.ua)
Tue, 24 Sep 2002 11:07:58 -0200


On 24 September 2002 03:40, Ingo Molnar wrote:
> On Tue, 24 Sep 2002, Rusty Russell wrote:
> there's a few more places that tend to cause wasted time, no matter what:
> - kmalloc(size, flags)/gfp(order, flags) argument ordering. A few months
> ago i wasted two days on such a bug - since 'size' was very small
> usually, it never showed up that the allocated buffer was short, until
> some rare load-test increased the 'size'.

Aughment kmalloc(size, GFP_XXXXX) with kmalloc_XXXXX(size) (inline of course)?
You may use this form in those 90% cases where flags are constant.

This also gets rid of GFP_ prefixes (shorter).

Ingo, Rusty?

--
vda

--- linux-2.5.36/include/linux/slab.h.orig Tue Sep 24 11:00:42 2002 +++ linux-2.5.36/include/linux/slab.h Tue Sep 24 11:06:32 2002 @@ -61,6 +61,15 @@

extern void *kmalloc(size_t, int); extern void kfree(const void *); +extern inline void *kmalloc_NOHIGHIO(size_t sz) { return kmalloc(sz, GFP_NOHIGHIO); } +extern inline void *kmalloc_NOIO (size_t sz) { return kmalloc(sz, GFP_NOIO ); } +extern inline void *kmalloc_NOFS (size_t sz) { return kmalloc(sz, GFP_NOFS ); } +extern inline void *kmalloc_ATOMIC (size_t sz) { return kmalloc(sz, GFP_ATOMIC ); } +extern inline void *kmalloc_USER (size_t sz) { return kmalloc(sz, GFP_USER ); } +extern inline void *kmalloc_HIGHUSER(size_t sz) { return kmalloc(sz, GFP_HIGHUSER); } +extern inline void *kmalloc_KERNEL (size_t sz) { return kmalloc(sz, GFP_KERNEL ); } +extern inline void *kmalloc_NFS (size_t sz) { return kmalloc(sz, GFP_NFS ); } +extern inline void *kmalloc_KSWAPD (size_t sz) { return kmalloc(sz, GFP_KSWAPD ); }

extern int FASTCALL(kmem_cache_reap(int));

- 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/