Commit 0fa8103b authored by Wanpeng Li's avatar Wanpeng Li Committed by Pekka Enberg

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: default avatarChristoph Lameter <cl@linux.com>
Signed-off-by: default avatarWanpeng Li <liwanp@linux.vnet.ibm.com>
Signed-off-by: default avatarPekka Enberg <penberg@kernel.org>
parent 069e2b35
...@@ -1180,6 +1180,12 @@ static int init_cache_node_node(int node) ...@@ -1180,6 +1180,12 @@ static int init_cache_node_node(int node)
return 0; return 0;
} }
static inline int slabs_tofree(struct kmem_cache *cachep,
struct kmem_cache_node *n)
{
return (n->free_objects + cachep->num - 1) / cachep->num;
}
static void __cpuinit cpuup_canceled(long cpu) static void __cpuinit cpuup_canceled(long cpu)
{ {
struct kmem_cache *cachep; struct kmem_cache *cachep;
...@@ -1241,7 +1247,7 @@ static void __cpuinit cpuup_canceled(long cpu) ...@@ -1241,7 +1247,7 @@ static void __cpuinit cpuup_canceled(long cpu)
n = cachep->node[node]; n = cachep->node[node];
if (!n) if (!n)
continue; continue;
drain_freelist(cachep, n, n->free_objects); drain_freelist(cachep, n, slabs_tofree(cachep, n));
} }
} }
...@@ -1408,7 +1414,7 @@ static int __meminit drain_cache_node_node(int node) ...@@ -1408,7 +1414,7 @@ static int __meminit drain_cache_node_node(int node)
if (!n) if (!n)
continue; continue;
drain_freelist(cachep, n, n->free_objects); drain_freelist(cachep, n, slabs_tofree(cachep, n));
if (!list_empty(&n->slabs_full) || if (!list_empty(&n->slabs_full) ||
!list_empty(&n->slabs_partial)) { !list_empty(&n->slabs_partial)) {
...@@ -2534,7 +2540,7 @@ static int __cache_shrink(struct kmem_cache *cachep) ...@@ -2534,7 +2540,7 @@ static int __cache_shrink(struct kmem_cache *cachep)
if (!n) if (!n)
continue; continue;
drain_freelist(cachep, n, n->free_objects); drain_freelist(cachep, n, slabs_tofree(cachep, n));
ret += !list_empty(&n->slabs_full) || ret += !list_empty(&n->slabs_full) ||
!list_empty(&n->slabs_partial); !list_empty(&n->slabs_partial);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment