public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] slob: fix page order calculation on not 4KB page
@ 2007-04-29 11:02 Akinobu Mita
  2007-04-29 11:46 ` Matt Mackall
  0 siblings, 1 reply; 2+ messages in thread
From: Akinobu Mita @ 2007-04-29 11:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: Matt Mackall

SLOB doesn't caluclate correct page order when page size is not 4KB.
This patch fixes it with using get_order() instead of find_order()
which is SLOB version of get_order().

Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

Index: 2.6-mm/mm/slob.c
===================================================================
--- 2.6-mm.orig/mm/slob.c
+++ 2.6-mm/mm/slob.c
@@ -150,15 +150,6 @@ static void slob_free(void *block, int s
 	spin_unlock_irqrestore(&slob_lock, flags);
 }
 
-static int FASTCALL(find_order(int size));
-static int fastcall find_order(int size)
-{
-	int order = 0;
-	for ( ; size > 4096 ; size >>=1)
-		order++;
-	return order;
-}
-
 void *__kmalloc(size_t size, gfp_t gfp)
 {
 	slob_t *m;
@@ -174,7 +165,7 @@ void *__kmalloc(size_t size, gfp_t gfp)
 	if (!bb)
 		return 0;
 
-	bb->order = find_order(size);
+	bb->order = get_order(size);
 	bb->pages = (void *)__get_free_pages(gfp, bb->order);
 
 	if (bb->pages) {
@@ -318,7 +309,7 @@ void *kmem_cache_alloc(struct kmem_cache
 	if (c->size < PAGE_SIZE)
 		b = slob_alloc(c->size, flags, c->align);
 	else
-		b = (void *)__get_free_pages(flags, find_order(c->size));
+		b = (void *)__get_free_pages(flags, get_order(c->size));
 
 	if (c->ctor)
 		c->ctor(b, c, SLAB_CTOR_CONSTRUCTOR);
@@ -345,7 +336,7 @@ void kmem_cache_free(struct kmem_cache *
 	if (c->size < PAGE_SIZE)
 		slob_free(b, c->size);
 	else
-		free_pages((unsigned long)b, find_order(c->size));
+		free_pages((unsigned long)b, get_order(c->size));
 }
 EXPORT_SYMBOL(kmem_cache_free);
 

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

* Re: [PATCH] slob: fix page order calculation on not 4KB page
  2007-04-29 11:02 [PATCH] slob: fix page order calculation on not 4KB page Akinobu Mita
@ 2007-04-29 11:46 ` Matt Mackall
  0 siblings, 0 replies; 2+ messages in thread
From: Matt Mackall @ 2007-04-29 11:46 UTC (permalink / raw)
  To: Akinobu Mita, linux-kernel

On Sun, Apr 29, 2007 at 08:02:49PM +0900, Akinobu Mita wrote:
> SLOB doesn't caluclate correct page order when page size is not 4KB.
> This patch fixes it with using get_order() instead of find_order()
> which is SLOB version of get_order().

Doh, that's a pretty blatant use of a magic number.

> Cc: Matt Mackall <mpm@selenic.com>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

Acked-by: Matt Mackal <mpm@selenic.com>

-- 
Mathematics is the supreme nostalgia of our time.

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

end of thread, other threads:[~2007-04-29 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-29 11:02 [PATCH] slob: fix page order calculation on not 4KB page Akinobu Mita
2007-04-29 11:46 ` Matt Mackall

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