lkml.org 
[lkml]   [2002]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[RFC] kmem_cache_zalloc
From
Date
In the interest of whittling down the changes that XFS makes to the core
kernel, I thought I'd start throwing out some the easier self-contained
modifications for discussion.

XFS adds a kmem_cache_zalloc function to mm/slab.c, it does what you
might expect: kmem_cache_alloc + memset

Is this something that might be considered for inclusion in the core
kernel, or should we roll it back into fs/xfs?

Thanks,

-Eric

--- 18.1/mm/slab.c Fri, 07 Dec 2001 09:35:49 +1100 kaos (linux-2.4/j/5_slab.c 1.2.1.2.1.2.1.3.1.3 644)
+++ 18.11/mm/slab.c Mon, 07 Jan 2002 13:27:25 +1100 kaos (linux-2.4/j/5_slab.c 1.2.1.2.1.7 644)
@@ -1567,6 +1567,23 @@ void kmem_cache_free (kmem_cache_t *cach
local_irq_restore(flags);
}

+void *
+kmem_cache_zalloc(kmem_cache_t *cachep, int flags)
+{
+ void *ptr;
+ ptr = __kmem_cache_alloc(cachep, flags);
+ if (ptr)
+#if DEBUG
+ memset(ptr, 0, cachep->objsize -
+ (cachep->flags & SLAB_RED_ZONE ? 2*BYTES_PER_WORD : 0));
+#else
+ memset(ptr, 0, cachep->objsize);
+#endif
+
+ return ptr;
+}
+
+


--
Eric Sandeen XFS for Linux http://oss.sgi.com/projects/xfs
sandeen@sgi.com SGI, Inc.
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:25    [W:0.054 / U:1.372 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site