Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760479AbYBFVBH (ORCPT ); Wed, 6 Feb 2008 16:01:07 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757460AbYBFVAz (ORCPT ); Wed, 6 Feb 2008 16:00:55 -0500 Received: from relay2.sgi.com ([192.48.171.30]:39651 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757468AbYBFVAy (ORCPT ); Wed, 6 Feb 2008 16:00:54 -0500 Date: Wed, 6 Feb 2008 13:00:53 -0800 (PST) From: Christoph Lameter X-X-Sender: clameter@schroedinger.engr.sgi.com To: Andrew Morton cc: Pekka Enberg , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: SLUB: statistics improvements In-Reply-To: <20080206001948.6f749aa8.akpm@linux-foundation.org> Message-ID: References: <20080206001948.6f749aa8.akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2797 Lines: 102 SLUB: statistics improvements - Fix indentation in unfreeze_slab - FREE_SLAB/ALLOC_SLAB counters were slightly misplaced and counted even if the slab was kept because we were below the mininum of partial slabs. - Export per cpu statistics to user space (follow numa convention but change the n character to c (no slabinfo support for display yet) F.e. christoph@stapp:/sys/kernel/slab/kmalloc-8$ cat alloc_fastpath 9968 c0=4854 c1=1050 c2=468 c3=190 c4=116 c5=1779 c6=185 c7=1326 --- mm/slub.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2008-02-06 12:47:41.246444483 -0800 +++ linux-2.6/mm/slub.c 2008-02-06 12:50:42.253891850 -0800 @@ -1377,7 +1377,7 @@ static void unfreeze_slab(struct kmem_ca } else { stat(c, DEACTIVATE_FULL); if (SlabDebug(page) && (s->flags & SLAB_STORE_USER)) - add_full(n, page); + add_full(n, page); } slab_unlock(page); } else { @@ -1395,6 +1395,7 @@ static void unfreeze_slab(struct kmem_ca slab_unlock(page); } else { slab_unlock(page); + stat(get_cpu_slab(s, raw_smp_processor_id()), FREE_SLAB); discard_slab(s, page); } } @@ -1567,9 +1568,9 @@ new_slab: if (new) { c = get_cpu_slab(s, smp_processor_id()); + stat(c, ALLOC_SLAB); if (c->page) flush_slab(s, c); - stat(c, ALLOC_SLAB); slab_lock(new); SetSlabFrozen(new); c->page = new; @@ -4014,15 +4015,37 @@ 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; + int *data = kmalloc(nr_cpu_ids * sizeof(int), GFP_KERNEL); + + if (!data) + return -ENOMEM; + + for_each_online_cpu(cpu) { + int x = get_cpu_slab(s, cpu)->stat[si]; + + data[cpu] = x; + sum += x; + } + + len = sprintf(buf, "%lu", sum); + + for_each_online_cpu(cpu) { + if (data[cpu] && len < PAGE_SIZE - 20) + len += sprintf(buf + len, " c%d=%u", cpu, data[cpu]); + } + kfree(data); + 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); \ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/