Make slab use alloc_pages directly
PATCH 1/1 Make slab use alloc_pages directly
__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.
Index: linux-2.6/mm/slab.c
===================================================================
RCS file: /var/cvs/linux-2.6/mm/slab.c,v
retrieving revision 1.29
mm/slab.c +4 -7
@@ -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 )
Signature · 11 lines
"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 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · Matthew Wilcox
__get_free_pages()callsalloc_pages, finds thepage_address()and throws away the struct page *. Slab then callsvirt_to_pageto get it back again. Much more efficient for slab to callalloc_pagesitself, 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
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 9 lines · Matthew Wilcox
__get_free_pages()callsalloc_pages, finds thepage_address()and throws away the struct page *. Slab then callsvirt_to_pageto get it back again. Much more efficient for slab to callalloc_pagesitself, as well as making the NUMA and non-NUMA cases more similarr to each other.Signed-off-by Matthew Wilcox <[email protected]>
Quoted 21 lines
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.29slab.cmm/slab.c +1
-4@@ -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);
mm/slab.c static void *kmem_getpages(kmem_cache_t · line 906
Quoted 10 lines
mm/slab.c +3
-3-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 )
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 Remove special case in kmem_getpages()
In reply to Matthew WilcoxQuoted 4 lines · Matthew Wilcox
__get_free_pages()callsalloc_pages, finds thepage_address()and throws away the struct page *. Slab then callsvirt_to_pageto get it back again. Much more efficient for slab to callalloc_pagesitself, 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().
mm/slab.c +6 -12
@@ -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);
Re: [PATCH] Remove special case in kmem_getpages()
Quoted 7 lines · Brian Gerst
Quoted 4 lines · Matthew Wilcox
__get_free_pages()callsalloc_pages, finds thepage_address()and throws away the struct page *. Slab then callsvirt_to_pageto get it back again. Much more efficient for slab to callalloc_pagesitself, 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.
Quoted 40 lines
Remove the special case of nodeid == -1. Instead, use
numa_node_id()when callingcache_grow().Signed-off-by Brian Gerst <[email protected]>diff -urN
linux-2.6.11-rc2-bk/mm/slab.clinux/mm/slab.cmm/slab.c +6
-12@@ -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);
Signature · 11 lines
"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 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>