slab: fix the alias count (via sysfs) of slab cache
authorGu Zheng <[email protected]>
Wed, 6 Aug 2014 23:04:51 +0000 (16:04 -0700)
committerLinus Torvalds <[email protected]>
Thu, 7 Aug 2014 01:01:15 +0000 (18:01 -0700)
We mark some slab caches (e.g.  kmem_cache_node) as unmergeable by
setting refcount to -1, and their alias should be 0, not refcount-1, so
correct it here.

Signed-off-by: Gu Zheng <[email protected]>
Acked-by: David Rientjes <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/slub.c

index d9aadbfe7c29c313672cf1fedc2cec4407376d7b..9b861b90cde1ff5f2c2cfc6d3b282158a5f2811d 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4466,7 +4466,7 @@ SLAB_ATTR_RO(ctor);
 
 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
 {
-       return sprintf(buf, "%d\n", s->refcount - 1);
+       return sprintf(buf, "%d\n", s->refcount < 0 ? 0 : s->refcount - 1);
 }
 SLAB_ATTR_RO(aliases);