Something's not adding up, literally, when I compare the old values
with those shown by your patch.
For examples, without your patch, check just the caches with a single slab page,
like the nfs_commit_data, fuse_inode and bio-2 caches:
crash> kmem -s
CACHE NAME OBJSIZE ALLOCATED TOTAL SLABS SSIZE
ffff880467c36300 nf_conntrack_ffff880065dd8000 312 0 0 0 8k
ffff88046751f900 nf_conntrack_ffff880465411200 312 0 0 0 8k
ffff8804608db000 nfs_direct_cache 352 0 0 0 8k
ffff8804608daf00 nfs_commit_data 680 23 23 1 16k <=
ffff8804608dae00 nfs_read_data 872 447 576 16 32k
ffff8804608dad00 nfs_inode_cache 1048 1315 1364 44 32k
ffff8804608dac00 fscache_cookie_jar 80 256 276 6 4k
ffff88040b958000 fuse_inode 728 21 21 1 16k <=
ffff88046751f800 btrfs_delayed_data_ref 96 0 0 0 4k
ffff88046751f700 btrfs_delayed_ref_head 160 0 0 0 4k
ffff88046751f600 btrfs_delayed_node 304 0 0 0 8k
ffff88046751f500 btrfs_ordered_extent 424 0 0 0 16k
ffff88046751f400 bio-2 320 25 25 1 8k <=
...
Taking their respective object sizes into account:
nfs_commit_data has an object size of 680, and the 16k slab can hold 23 objects:
23 * 680 = 15640
fuse_inode has an object size of 728, and the 16k slab can hold 21 objects:
21 * 728 = 15288
bio-2 has an object size of 320, and the 8k slab can hold 25 objects:
25 * 320 = 8000
With your patch applied, note that those caches show double the number above, or
46, 42 and 50 respectively:
crash> kmem -s
CACHE NAME OBJSIZE ALLOCATED TOTAL SLABS SSIZE
ffff880467c36300 nf_conntrack_ffff880065dd8000 312 0 0 0 8k
ffff88046751f900 nf_conntrack_ffff880465411200 312 0 0 0 8k
ffff8804608db000 nfs_direct_cache 352 0 0 0 8k
ffff8804608daf00 nfs_commit_data 680 46 46 1 16k
ffff8804608dae00 nfs_read_data 872 684 724 15 32k
ffff8804608dad00 nfs_inode_cache 1048 1534 1534 43 32k
ffff8804608dac00 fscache_cookie_jar 80 532 532 6 4k
ffff88040b958000 fuse_inode 728 42 42 1 16k
ffff88046751f800 btrfs_delayed_data_ref 96 0 0 0 4k
ffff88046751f700 btrfs_delayed_ref_head 160 0 0 0 4k
ffff88046751f600 btrfs_delayed_node 304 0 0 0 8k
ffff88046751f500 btrfs_ordered_extent 424 0 0 0 16k
ffff88046751f400 bio-2 320 50 50 1 8k
...
What am I missing?
Hi Dave,
Looks like this is because of counting the per cpu objects twice. They
are already included in kmem_cache_node.total_objects. This should fix
that. New patch attached.
diff --git a/memory.c b/memory.c
index 7b645b8..1343a11 100644
--- a/memory.c
+++ b/memory.c
@@ -17939,6 +17939,9 @@ get_kmem_cache_slub_data(long cmd, struct meminfo *si)
total_slabs = total_objects = free_objects = 0;
+ if (VALID_MEMBER(kmem_cache_node_total_objects))
+ node_total_avail = 1;
+
for (i = 0; i < kt->cpus; i++) {
cpu_slab_ptr = get_cpu_slab_ptr(si, i, NULL);
@@ -17955,7 +17958,8 @@ get_kmem_cache_slub_data(long cmd, struct meminfo *si)
KVADDR, &inuse, sizeof(short),
"page inuse", RETURN_ON_ERROR))
return FALSE;
- total_objects += inuse;
+ if (!node_total_avail)
+ total_objects += inuse;
total_slabs++;
break;
@@ -17992,7 +17996,6 @@ get_kmem_cache_slub_data(long cmd, struct meminfo *si)
KVADDR, &node_total_objects, sizeof(ulong),
"kmem_cache_node total_objects", RETURN_ON_ERROR))
goto bailout;
- node_total_avail = 1;
}
switch (cmd)
(END)
Vinayak