Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933018Ab2EYNJt (ORCPT ); Fri, 25 May 2012 09:09:49 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:9638 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932867Ab2EYNJq (ORCPT ); Fri, 25 May 2012 09:09:46 -0400 From: Glauber Costa To: Cc: , , , Tejun Heo , Li Zefan , Greg Thelen , Suleiman Souhlal , Michal Hocko , Johannes Weiner , , David Rientjes , Glauber Costa , Christoph Lameter , Pekka Enberg Subject: [PATCH v3 25/28] slub: create slabinfo file for memcg Date: Fri, 25 May 2012 17:03:45 +0400 Message-Id: <1337951028-3427-26-git-send-email-glommer@parallels.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1337951028-3427-1-git-send-email-glommer@parallels.com> References: <1337951028-3427-1-git-send-email-glommer@parallels.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1699 Lines: 60 This patch implements mem_cgroup_slabinfo() for the slub. With that, we can also probe the used caches for it. Signed-off-by: Glauber Costa CC: Christoph Lameter CC: Pekka Enberg CC: Michal Hocko CC: Kamezawa Hiroyuki CC: Johannes Weiner CC: Suleiman Souhlal --- mm/slub.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index c8a8cab..4c29e5f 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4113,6 +4113,33 @@ struct kmem_cache *kmem_cache_dup(struct mem_cgroup *memcg, int mem_cgroup_slabinfo(struct mem_cgroup *memcg, struct seq_file *m) { + struct kmem_cache *s; + int node; + unsigned long nr_objs = 0; + unsigned long nr_free = 0; + + seq_printf(m, "# name \n"); + + down_read(&slub_lock); + list_for_each_entry(s, &slab_caches, list) { + if (s->memcg_params.memcg != memcg) + continue; + + for_each_online_node(node) { + struct kmem_cache_node *n = get_node(s, node); + + if (!n) + continue; + + nr_objs += atomic_long_read(&n->total_objects); + nr_free += count_partial(n, count_free); + } + + seq_printf(m, "%-17s %6lu %6lu %6u\n", s->name, + nr_objs - nr_free, nr_objs, s->size); + } + up_read(&slub_lock); + return 0; } #endif -- 1.7.7.6 -- 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/