aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWanpeng Li <liwanp@linux.vnet.ibm.com>2013-07-03 20:33:22 -0400
committerPekka Enberg <penberg@kernel.org>2013-07-07 11:37:46 -0400
commit0fa8103be4c20f893486c533e4c6dfbc5ccddeb4 (patch)
tree890b6eb373acf23232c6f05fdd5fb90ea511c83b
parent069e2b351de67e7a837b15b3d26c65c19b790cc3 (diff)
mm/slab: Fix drain freelist excessively
The drain_freelist is called to drain slabs_free lists for cache reap, cache shrink, memory hotplug callback etc. The tofree parameter should be the number of slab to free instead of the number of slab objects to free. This patch fix the callers that pass # of objects. Make sure they pass # of slabs. Acked-by: Christoph Lameter <cl@linux.com> Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r--mm/slab.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/mm/slab.c b/mm/slab.c
index 273a5ac2ade3..c9b4da9a1fe5 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1180,6 +1180,12 @@ static int init_cache_node_node(int node)
1180 return 0; 1180 return 0;
1181} 1181}
1182 1182
1183static inline int slabs_tofree(struct kmem_cache *cachep,
1184 struct kmem_cache_node *n)
1185{
1186 return (n->free_objects + cachep->num - 1) / cachep->num;
1187}
1188
1183static void __cpuinit cpuup_canceled(long cpu) 1189static void __cpuinit cpuup_canceled(long cpu)
1184{ 1190{
1185 struct kmem_cache *cachep; 1191 struct kmem_cache *cachep;
@@ -1241,7 +1247,7 @@ free_array_cache:
1241 n = cachep->node[node]; 1247 n = cachep->node[node];
1242 if (!n) 1248 if (!n)
1243 continue; 1249 continue;
1244 drain_freelist(cachep, n, n->free_objects); 1250 drain_freelist(cachep, n, slabs_tofree(cachep, n));
1245 } 1251 }
1246} 1252}
1247 1253
@@ -1408,7 +1414,7 @@ static int __meminit drain_cache_node_node(int node)
1408 if (!n) 1414 if (!n)
1409 continue; 1415 continue;
1410 1416
1411 drain_freelist(cachep, n, n->free_objects); 1417 drain_freelist(cachep, n, slabs_tofree(cachep, n));
1412 1418
1413 if (!list_empty(&n->slabs_full) || 1419 if (!list_empty(&n->slabs_full) ||
1414 !list_empty(&n->slabs_partial)) { 1420 !list_empty(&n->slabs_partial)) {
@@ -2534,7 +2540,7 @@ static int __cache_shrink(struct kmem_cache *cachep)
2534 if (!n) 2540 if (!n)
2535 continue; 2541 continue;
2536 2542
2537 drain_freelist(cachep, n, n->free_objects); 2543 drain_freelist(cachep, n, slabs_tofree(cachep, n));
2538 2544
2539 ret += !list_empty(&n->slabs_full) || 2545 ret += !list_empty(&n->slabs_full) ||
2540 !list_empty(&n->slabs_partial); 2546 !list_empty(&n->slabs_partial);