public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] make kmem_find_general_cachep static in slab.c
@ 2004-09-07 14:36 Christoph Hellwig
  2004-09-07 16:50 ` Manfred Spraul
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2004-09-07 14:36 UTC (permalink / raw)
  To: akpm, manfred; +Cc: linux-kernel


--- 1.35/include/linux/slab.h	2004-09-03 11:08:25 +02:00
+++ edited/include/linux/slab.h	2004-09-07 14:47:58 +02:00
@@ -55,7 +55,6 @@
 /* prototypes */
 extern void kmem_cache_init(void);
 
-extern kmem_cache_t *kmem_find_general_cachep(size_t, int gfpflags);
 extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long,
 				       void (*)(void *, kmem_cache_t *, unsigned long),
 				       void (*)(void *, kmem_cache_t *, unsigned long));
--- 1.146/mm/slab.c	2004-09-03 11:08:25 +02:00
+++ edited/mm/slab.c	2004-09-07 14:48:33 +02:00
@@ -562,6 +562,22 @@
 	return cachep->array[smp_processor_id()];
 }
 
+static kmem_cache_t * kmem_find_general_cachep (size_t size, int gfpflags)
+{
+	struct cache_sizes *csizep = malloc_sizes;
+
+	/* This function could be moved to the header file, and
+	 * made inline so consumers can quickly determine what
+	 * cache pointer they require.
+	 */
+	for ( ; csizep->cs_size; csizep++) {
+		if (size > csizep->cs_size)
+			continue;
+		break;
+	}
+	return (gfpflags & GFP_DMA) ? csizep->cs_dmacachep : csizep->cs_cachep;
+}
+
 /* Cal the num objs, wastage, and bytes left over for a given slab size. */
 static void cache_estimate (unsigned long gfporder, size_t size, size_t align,
 		 int flags, size_t *left_over, unsigned int *num)
@@ -2554,24 +2570,6 @@
 }
 
 EXPORT_SYMBOL(kmem_cache_size);
-
-kmem_cache_t * kmem_find_general_cachep (size_t size, int gfpflags)
-{
-	struct cache_sizes *csizep = malloc_sizes;
-
-	/* This function could be moved to the header file, and
-	 * made inline so consumers can quickly determine what
-	 * cache pointer they require.
-	 */
-	for ( ; csizep->cs_size; csizep++) {
-		if (size > csizep->cs_size)
-			continue;
-		break;
-	}
-	return (gfpflags & GFP_DMA) ? csizep->cs_dmacachep : csizep->cs_cachep;
-}
-
-EXPORT_SYMBOL(kmem_find_general_cachep);
 
 struct ccupdate_struct {
 	kmem_cache_t *cachep;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] make kmem_find_general_cachep static in slab.c
  2004-09-07 14:36 [PATCH] make kmem_find_general_cachep static in slab.c Christoph Hellwig
@ 2004-09-07 16:50 ` Manfred Spraul
  2004-09-07 16:52   ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Manfred Spraul @ 2004-09-07 16:50 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: akpm, linux-kernel

Christoph Hellwig wrote:

>--- 1.35/include/linux/slab.h	2004-09-03 11:08:25 +02:00
>+++ edited/include/linux/slab.h	2004-09-07 14:47:58 +02:00
>@@ -55,7 +55,6 @@
> /* prototypes */
> extern void kmem_cache_init(void);
> 
>-extern kmem_cache_t *kmem_find_general_cachep(size_t, int gfpflags);
>  
>

Why?
It's intended for users that want to kmalloc always the same amount of 
memory.
For example the network layer could call kmem_find_general_cachep once 
for dev->mtu and then just call kmem_cache_alloc instead of kmalloc. The 
loop in kmalloc often needs more cpu cycles than the actual alloc.

--
    Manfred

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] make kmem_find_general_cachep static in slab.c
  2004-09-07 16:50 ` Manfred Spraul
@ 2004-09-07 16:52   ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2004-09-07 16:52 UTC (permalink / raw)
  To: Manfred Spraul; +Cc: akpm, linux-kernel

On Tue, Sep 07, 2004 at 06:50:17PM +0200, Manfred Spraul wrote:
> Why?
> It's intended for users that want to kmalloc always the same amount of 
> memory.
> For example the network layer could call kmem_find_general_cachep once 
> for dev->mtu and then just call kmem_cache_alloc instead of kmalloc. The 
> loop in kmalloc often needs more cpu cycles than the actual alloc.

Because there's no single user, and for constant size arguments kmalloc
already optimizes very well, so I rather doubt people are ever going to
use this one.

Is the basic don't design APIs for a maybe future scheme.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-09-07 17:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-07 14:36 [PATCH] make kmem_find_general_cachep static in slab.c Christoph Hellwig
2004-09-07 16:50 ` Manfred Spraul
2004-09-07 16:52   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox