--- mm/slub.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2008-02-05 22:43:32.528246844 -0800 +++ linux-2.6/mm/slub.c 2008-02-05 22:53:24.769179403 -0800 @@ -4015,15 +4015,31 @@ SLAB_ATTR(remote_node_defrag_ratio); #ifdef CONFIG_SLUB_STATS +static int show_stat(struct kmem_cache *s, char *buf, enum stat_item si) +{ + unsigned long sum = 0; + int cpu; + int len; + + for_each_online_cpu(cpu) + sum += get_cpu_slab(s, cpu)->stat[si]; + + len = sprintf(buf, "%lu", sum); + + for_each_online_cpu(cpu) { + int counter = get_cpu_slab(s, cpu)->stat[si]; + + if (counter && len < PAGE_SIZE - 20) + len += sprintf(buf + len, " c%d=%u", cpu, counter); + } + + return len + sprintf(buf + len, "\n"); +} + #define STAT_ATTR(si, text) \ static ssize_t text##_show(struct kmem_cache *s, char *buf) \ { \ - unsigned long sum = 0; \ - int cpu; \ - \ - for_each_online_cpu(cpu) \ - sum += get_cpu_slab(s, cpu)->stat[si]; \ - return sprintf(buf, "%lu\n", sum); \ + return show_stat(s, buf, si); \ } \ SLAB_ATTR_RO(text); \