linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Make slab use alloc_pages directly
@ 2005-01-24 16:54 Matthew Wilcox
  2005-01-24 17:03 ` David Howells
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Matthew Wilcox @ 2005-01-24 16:54 UTC (permalink / raw)
  To: Andrew Morton, linux-mm, manfred; +Cc: linux-kernel, dhowells


__get_free_pages() calls alloc_pages, finds the page_address() and
throws away the struct page *.  Slab then calls virt_to_page to get it
back again.  Much more efficient for slab to call alloc_pages itself,
as well as making the NUMA and non-NUMA cases more similarr to each other.

Signed-off-by: Matthew Wilcox <matthew@wil.cx>

Index: linux-2.6/mm/slab.c
===================================================================
RCS file: /var/cvs/linux-2.6/mm/slab.c,v
retrieving revision 1.29
diff -u -p -r1.29 slab.c
--- linux-2.6/mm/slab.c	12 Jan 2005 20:18:07 -0000	1.29
+++ linux-2.6/mm/slab.c	24 Jan 2005 16:47:02 -0000
@@ -894,16 +894,13 @@ static void *kmem_getpages(kmem_cache_t 
 
 	flags |= cachep->gfpflags;
 	if (likely(nodeid == -1)) {
-		addr = (void*)__get_free_pages(flags, cachep->gfporder);
-		if (!addr)
-			return NULL;
-		page = virt_to_page(addr);
+		page = alloc_pages(flags, cachep->gfporder);
 	} else {
 		page = alloc_pages_node(nodeid, flags, cachep->gfporder);
-		if (!page)
-			return NULL;
-		addr = page_address(page);
 	}
+	if (!page)
+		return NULL;
+	addr = page_address(page);
 
 	i = (1 << cachep->gfporder);
 	if (cachep->flags & SLAB_RECLAIM_ACCOUNT)

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

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

* Re: [PATCH] Make slab use alloc_pages directly
  2005-01-24 16:54 [PATCH] Make slab use alloc_pages directly Matthew Wilcox
@ 2005-01-24 17:03 ` David Howells
  2005-01-24 19:30 ` Manfred Spraul
  2005-01-25  0:58 ` [PATCH] Remove special case in kmem_getpages() Brian Gerst
  2 siblings, 0 replies; 5+ messages in thread
From: David Howells @ 2005-01-24 17:03 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Andrew Morton, linux-mm, manfred, linux-kernel


Matthew Wilcox <matthew@wil.cx> wrote:

> __get_free_pages() calls alloc_pages, finds the page_address() and
> throws away the struct page *.  Slab then calls virt_to_page to get it
> back again.  Much more efficient for slab to call alloc_pages itself,
> as well as making the NUMA and non-NUMA cases more similarr to each other.

Looks reasonable. Should also work in the NOMMU case.

David

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

* Re: [PATCH] Make slab use alloc_pages directly
  2005-01-24 16:54 [PATCH] Make slab use alloc_pages directly Matthew Wilcox
  2005-01-24 17:03 ` David Howells
@ 2005-01-24 19:30 ` Manfred Spraul
  2005-01-25  0:58 ` [PATCH] Remove special case in kmem_getpages() Brian Gerst
  2 siblings, 0 replies; 5+ messages in thread
From: Manfred Spraul @ 2005-01-24 19:30 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Andrew Morton, linux-mm, linux-kernel, dhowells

Matthew Wilcox wrote:

>__get_free_pages() calls alloc_pages, finds the page_address() and
>throws away the struct page *.  Slab then calls virt_to_page to get it
>back again.  Much more efficient for slab to call alloc_pages itself,
>as well as making the NUMA and non-NUMA cases more similarr to each other.
>
>Signed-off-by: Matthew Wilcox <matthew@wil.cx>
>
>  
>
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>

>Index: linux-2.6/mm/slab.c
>===================================================================
>RCS file: /var/cvs/linux-2.6/mm/slab.c,v
>retrieving revision 1.29
>diff -u -p -r1.29 slab.c
>--- linux-2.6/mm/slab.c	12 Jan 2005 20:18:07 -0000	1.29
>+++ linux-2.6/mm/slab.c	24 Jan 2005 16:47:02 -0000
>@@ -894,16 +894,13 @@ static void *kmem_getpages(kmem_cache_t 
> 
> 	flags |= cachep->gfpflags;
> 	if (likely(nodeid == -1)) {
>-		addr = (void*)__get_free_pages(flags, cachep->gfporder);
>-		if (!addr)
>-			return NULL;
>-		page = virt_to_page(addr);
>+		page = alloc_pages(flags, cachep->gfporder);
> 	} else {
> 		page = alloc_pages_node(nodeid, flags, cachep->gfporder);
>-		if (!page)
>-			return NULL;
>-		addr = page_address(page);
> 	}
>+	if (!page)
>+		return NULL;
>+	addr = page_address(page);
> 
> 	i = (1 << cachep->gfporder);
> 	if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
>
>  
>


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

* [PATCH] Remove special case in kmem_getpages()
  2005-01-24 16:54 [PATCH] Make slab use alloc_pages directly Matthew Wilcox
  2005-01-24 17:03 ` David Howells
  2005-01-24 19:30 ` Manfred Spraul
@ 2005-01-25  0:58 ` Brian Gerst
  2005-01-25  1:04   ` Matthew Wilcox
  2 siblings, 1 reply; 5+ messages in thread
From: Brian Gerst @ 2005-01-25  0:58 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Andrew Morton, linux-mm, manfred, linux-kernel, dhowells

[-- Attachment #1: Type: text/plain, Size: 488 bytes --]

Matthew Wilcox wrote:
> __get_free_pages() calls alloc_pages, finds the page_address() and
> throws away the struct page *.  Slab then calls virt_to_page to get it
> back again.  Much more efficient for slab to call alloc_pages itself,
> as well as making the NUMA and non-NUMA cases more similarr to each other.

Here is a better patch:

Remove the special case of nodeid == -1.  Instead, use numa_node_id() 
when calling cache_grow().

Signed-off-by: Brian Gerst <bgerst@didntduck.org>

[-- Attachment #2: slab-numa --]
[-- Type: text/plain, Size: 974 bytes --]

diff -urN linux-2.6.11-rc2-bk/mm/slab.c linux/mm/slab.c
--- linux-2.6.11-rc2-bk/mm/slab.c	2005-01-22 01:58:25.000000000 -0500
+++ linux/mm/slab.c	2005-01-24 15:35:08.000000000 -0500
@@ -893,17 +893,11 @@
 	int i;
 
 	flags |= cachep->gfpflags;
-	if (likely(nodeid == -1)) {
-		addr = (void*)__get_free_pages(flags, cachep->gfporder);
-		if (!addr)
-			return NULL;
-		page = virt_to_page(addr);
-	} else {
-		page = alloc_pages_node(nodeid, flags, cachep->gfporder);
-		if (!page)
-			return NULL;
-		addr = page_address(page);
-	}
+
+	page = alloc_pages_node(nodeid, flags, cachep->gfporder);
+	if (!page)
+		return NULL;
+	addr = page_address(page);
 
 	i = (1 << cachep->gfporder);
 	if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
@@ -2065,7 +2059,7 @@
 
 	if (unlikely(!ac->avail)) {
 		int x;
-		x = cache_grow(cachep, flags, -1);
+		x = cache_grow(cachep, flags, numa_node_id());
 		
 		// cache_grow can reenable interrupts, then ac could change.
 		ac = ac_data(cachep);

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

* Re: [PATCH] Remove special case in kmem_getpages()
  2005-01-25  0:58 ` [PATCH] Remove special case in kmem_getpages() Brian Gerst
@ 2005-01-25  1:04   ` Matthew Wilcox
  0 siblings, 0 replies; 5+ messages in thread
From: Matthew Wilcox @ 2005-01-25  1:04 UTC (permalink / raw)
  To: Brian Gerst
  Cc: Matthew Wilcox, Andrew Morton, linux-mm, manfred, linux-kernel, dhowells

On Mon, Jan 24, 2005 at 07:58:03PM -0500, Brian Gerst wrote:
> Matthew Wilcox wrote:
> >__get_free_pages() calls alloc_pages, finds the page_address() and
> >throws away the struct page *.  Slab then calls virt_to_page to get it
> >back again.  Much more efficient for slab to call alloc_pages itself,
> >as well as making the NUMA and non-NUMA cases more similarr to each other.
> 
> Here is a better patch:

I disagree.  This disables the alloc_pages_current() optimisation.
I considered this option and rejected it.

> Remove the special case of nodeid == -1.  Instead, use numa_node_id() 
> when calling cache_grow().
> 
> Signed-off-by: Brian Gerst <bgerst@didntduck.org>

> diff -urN linux-2.6.11-rc2-bk/mm/slab.c linux/mm/slab.c
> --- linux-2.6.11-rc2-bk/mm/slab.c	2005-01-22 01:58:25.000000000 -0500
> +++ linux/mm/slab.c	2005-01-24 15:35:08.000000000 -0500
> @@ -893,17 +893,11 @@
>  	int i;
>  
>  	flags |= cachep->gfpflags;
> -	if (likely(nodeid == -1)) {
> -		addr = (void*)__get_free_pages(flags, cachep->gfporder);
> -		if (!addr)
> -			return NULL;
> -		page = virt_to_page(addr);
> -	} else {
> -		page = alloc_pages_node(nodeid, flags, cachep->gfporder);
> -		if (!page)
> -			return NULL;
> -		addr = page_address(page);
> -	}
> +
> +	page = alloc_pages_node(nodeid, flags, cachep->gfporder);
> +	if (!page)
> +		return NULL;
> +	addr = page_address(page);
>  
>  	i = (1 << cachep->gfporder);
>  	if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
> @@ -2065,7 +2059,7 @@
>  
>  	if (unlikely(!ac->avail)) {
>  		int x;
> -		x = cache_grow(cachep, flags, -1);
> +		x = cache_grow(cachep, flags, numa_node_id());
>  		
>  		// cache_grow can reenable interrupts, then ac could change.
>  		ac = ac_data(cachep);


-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

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

end of thread, other threads:[~2005-01-25  1:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-24 16:54 [PATCH] Make slab use alloc_pages directly Matthew Wilcox
2005-01-24 17:03 ` David Howells
2005-01-24 19:30 ` Manfred Spraul
2005-01-25  0:58 ` [PATCH] Remove special case in kmem_getpages() Brian Gerst
2005-01-25  1:04   ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).