[ewg] Re: [PATCH ofed-1.2.c] ehca: backport kmem_cache_zalloc() for 2.6.10/sles10/sles10_sp1

Hoang-Nam Nguyen hnguyen at linux.vnet.ibm.com
Tue Aug 7 00:13:35 PDT 2007


On Tuesday 07 August 2007 07:34, Michael S. Tsirkin wrote:
> Hmm, I thought about it some more.
> kmem_cache struct is not exported on recent kernels,
> so this might br hard to do.
I looked at slab.h in various kernel and see this function
extern unsigned int kmem_cache_size(kmem_cache_t *);
which returns buffer_size that is set by kmem_cache_create() to size.
So the backport will look like:
static inline
void *kmem_cache_zalloc(kmem_cache_t *cache, gfp_t flags)
{
	void *ret = kmem_cache_alloc(cache, flags);
	if (ret)
		memset(ret, 0, kmem_cache_size(cache));
	return ret;
}
Would you agree? Do I oversee something else?

Nam




More information about the ewg mailing list