linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mm/slab: Fix drain freelist excessively
@ 2013-06-24 10:23 Wanpeng Li
  2013-06-24 10:23 ` [PATCH 2/3] mm/slab: Sharing s_next and s_stop between slab and slub Wanpeng Li
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Wanpeng Li @ 2013-06-24 10:23 UTC (permalink / raw)
  To: Pekka Enberg, Christoph Lameter, Matt Mackall
  Cc: Glauber Costa, Andrew Morton, Joonsoo Kim, David Rientjes,
	linux-mm, linux-kernel, Wanpeng Li

The drain_freelist is called to drain slabs_free lists for cache reap, 
cache shrink, memory hotplug callback etc. The tofree parameter is the 
number of slab objects to free instead of the number of slabs to free. 
The parameter transfered from callers is n->free_objects or n->freelimit 
+ 5 * (searchp->num - 1) / (5 * searchp->num), and both of them mean 
the number of slabs objects. I add printk to dump drain information:

[  122.864255] tofree is 2, actually free is 52, cache size is 26

The number of objects which caller prefer to drain is 2, however, actually 
52 objects are drained, this destroy the cache locality.This patch fix it 
by compare the number of slabs objects which already drained instead of 
compare the number of slabs to the number of slab objects prefer to drain.

Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
 mm/slab.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index be12f68..18628da 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2479,7 +2479,7 @@ static void drain_cpu_caches(struct kmem_cache *cachep)
 
 /*
  * Remove slabs from the list of free slabs.
- * Specify the number of slabs to drain in tofree.
+ * Specify the number of slab objects to drain in tofree.
  *
  * Returns the actual number of slabs released.
  */
@@ -2491,7 +2491,7 @@ static int drain_freelist(struct kmem_cache *cache,
 	struct slab *slabp;
 
 	nr_freed = 0;
-	while (nr_freed < tofree && !list_empty(&n->slabs_free)) {
+	while (nr_freed * cache->num < tofree && !list_empty(&n->slabs_free)) {
 
 		spin_lock_irq(&n->list_lock);
 		p = n->slabs_free.prev;
-- 
1.7.10.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2013-07-08  8:03 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-24 10:23 [PATCH 1/3] mm/slab: Fix drain freelist excessively Wanpeng Li
2013-06-24 10:23 ` [PATCH 2/3] mm/slab: Sharing s_next and s_stop between slab and slub Wanpeng Li
2013-06-24 21:23   ` David Rientjes
2013-06-27  0:21     ` Wanpeng Li
2013-06-27  0:21     ` Wanpeng Li
2013-07-01 15:48     ` Christoph Lameter
2013-07-01 23:49       ` Wanpeng Li
2013-07-01 23:49       ` Wanpeng Li
2013-07-07 16:41       ` Pekka Enberg
2013-07-08  0:16         ` Wanpeng Li
2013-07-08  8:03           ` Pekka Enberg
2013-07-08  0:16         ` Wanpeng Li
2013-06-24 10:23 ` [PATCH 3/3] mm/slab: Fix /proc/slabinfo unwriteable for slab Wanpeng Li
2013-07-01 15:49   ` Christoph Lameter
2013-07-01 23:43     ` Wanpeng Li
2013-07-01 23:43     ` Wanpeng Li
2013-07-01 15:46 ` [PATCH 1/3] mm/slab: Fix drain freelist excessively Christoph Lameter
2013-07-01 23:45   ` Wanpeng Li
2013-07-01 23:45   ` Wanpeng Li

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).