slub: correct to calculate num of acquired objects in get_partial_node()
authorJoonsoo Kim <iamjoonsoo.kim@lge.com>
Mon, 21 Jan 2013 08:01:25 +0000 (17:01 +0900)
committerPekka Enberg <penberg@kernel.org>
Tue, 2 Apr 2013 06:42:10 +0000 (09:42 +0300)
commit633b076464da52b3c7bf0f62932fbfc0ea23d8b3
tree546927d08f30ea3049051b89a55b7c7a56937f7f
parent7d557b3cb69398d83ceabad9cf147c93a3aa97fd
slub: correct to calculate num of acquired objects in get_partial_node()

There is a subtle bug when calculating a number of acquired objects.

Currently, we calculate "available = page->objects - page->inuse",
after acquire_slab() is called in get_partial_node().

In acquire_slab() with mode = 1, we always set new.inuse = page->objects.
So,

acquire_slab(s, n, page, object == NULL);

if (!object) {
c->page = page;
stat(s, ALLOC_FROM_PARTIAL);
object = t;
available = page->objects - page->inuse;

!!! availabe is always 0 !!!
...

Therfore, "available > s->cpu_partial / 2" is always false and
we always go to second iteration.
This patch correct this problem.

After that, we don't need return value of put_cpu_partial().
So remove it.

Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Acked-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
mm/slub.c