[patch 1/2]slub: add slab with one free object to partial list tail - v2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The slab has just one free object, adding it to partial list head doesn't make
sense. And it can cause lock contentation. For example,
1. CPU takes the slab from partial list
2. fetch an object
3. switch to another slab
4. free an object, then the slab is added to partial list again
In this way n->list_lock will be heavily contended.
In fact, Alex had a hackbench regression. 3.1-rc1 performance drops about 70%
against 3.0. This patch fixes it. Thanks Alex to bisect the issue to be a slub
regression and collect perf data. Add comments in the code as suggested by Alex.

Reported-by: Alex Shi <alex.shi@xxxxxxxxx>
Signed-off-by: Shaohua Li <shli@xxxxxxxxxx>
Signed-off-by: Shaohua Li <shaohua.li@xxxxxxxxx>
Acked-by: Christoph Lameter <cl@xxxxxxxxx>

---
 mm/slub.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: linux/mm/slub.c
===================================================================
--- linux.orig/mm/slub.c	2011-08-24 08:59:06.000000000 +0800
+++ linux/mm/slub.c	2011-08-30 09:45:03.000000000 +0800
@@ -2377,7 +2377,12 @@ static void __slab_free(struct kmem_cach
 		 */
 		if (unlikely(!prior)) {
 			remove_full(s, page);
-			add_partial(n, page, 0);
+			/*
+			 * The slab has just one free object, add it to the
+			 * partial list tail so it will not be used
+			 * immediately.
+			 */
+			add_partial(n, page, 1);
 			stat(s, FREE_ADD_PARTIAL);
 		}
 	}


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]