From: Michal Hocko <mhocko@suse.cz>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [patch 3/6] mm: memcg: print statistics directly to seq_file
Date: Tue, 15 May 2012 16:46:35 +0200 [thread overview]
Message-ID: <20120515144635.GH11346@tiehlicka.suse.cz> (raw)
In-Reply-To: <1337018451-27359-4-git-send-email-hannes@cmpxchg.org>
On Mon 14-05-12 20:00:48, Johannes Weiner wrote:
> Being able to use seq_printf() allows being smarter about statistics
> name strings, which are currently listed twice, with the only
> difference being a "total_" prefix on the hierarchical version.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Nice
Acked-by: Michal Hocko <mhocko@suse.cz>
> ---
> mm/memcontrol.c | 56 +++++++++++++++++++++++++++----------------------------
> 1 file changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index f0d248b..9e8551c 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4274,24 +4274,21 @@ struct mcs_total_stat {
> s64 stat[NR_MCS_STAT];
> };
>
> -static struct {
> - char *local_name;
> - char *total_name;
> -} memcg_stat_strings[NR_MCS_STAT] = {
> - {"cache", "total_cache"},
> - {"rss", "total_rss"},
> - {"mapped_file", "total_mapped_file"},
> - {"mlock", "total_mlock"},
> - {"pgpgin", "total_pgpgin"},
> - {"pgpgout", "total_pgpgout"},
> - {"swap", "total_swap"},
> - {"pgfault", "total_pgfault"},
> - {"pgmajfault", "total_pgmajfault"},
> - {"inactive_anon", "total_inactive_anon"},
> - {"active_anon", "total_active_anon"},
> - {"inactive_file", "total_inactive_file"},
> - {"active_file", "total_active_file"},
> - {"unevictable", "total_unevictable"}
> +static const char *memcg_stat_strings[NR_MCS_STAT] = {
> + "cache",
> + "rss",
> + "mapped_file",
> + "mlock",
> + "pgpgin",
> + "pgpgout",
> + "swap",
> + "pgfault",
> + "pgmajfault",
> + "inactive_anon",
> + "active_anon",
> + "inactive_file",
> + "active_file",
> + "unevictable",
> };
>
>
> @@ -4392,7 +4389,7 @@ static int mem_control_numa_stat_show(struct cgroup *cont, struct cftype *cft,
> #endif /* CONFIG_NUMA */
>
> static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
> - struct cgroup_map_cb *cb)
> + struct seq_file *m)
> {
> struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
> struct mcs_total_stat mystat;
> @@ -4405,16 +4402,18 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
> for (i = 0; i < NR_MCS_STAT; i++) {
> if (i == MCS_SWAP && !do_swap_account)
> continue;
> - cb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]);
> + seq_printf(m, "%s %llu\n", memcg_stat_strings[i],
> + (unsigned long long)mystat.stat[i]);
> }
>
> /* Hierarchical information */
> {
> unsigned long long limit, memsw_limit;
> memcg_get_hierarchical_limit(memcg, &limit, &memsw_limit);
> - cb->fill(cb, "hierarchical_memory_limit", limit);
> + seq_printf(m, "hierarchical_memory_limit %llu\n", limit);
> if (do_swap_account)
> - cb->fill(cb, "hierarchical_memsw_limit", memsw_limit);
> + seq_printf(m, "hierarchical_memsw_limit %llu\n",
> + memsw_limit);
> }
>
> memset(&mystat, 0, sizeof(mystat));
> @@ -4422,7 +4421,8 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
> for (i = 0; i < NR_MCS_STAT; i++) {
> if (i == MCS_SWAP && !do_swap_account)
> continue;
> - cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);
> + seq_printf(m, "total_%s %llu\n", memcg_stat_strings[i],
> + (unsigned long long)mystat.stat[i]);
> }
>
> #ifdef CONFIG_DEBUG_VM
> @@ -4443,10 +4443,10 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
> recent_scanned[0] += rstat->recent_scanned[0];
> recent_scanned[1] += rstat->recent_scanned[1];
> }
> - cb->fill(cb, "recent_rotated_anon", recent_rotated[0]);
> - cb->fill(cb, "recent_rotated_file", recent_rotated[1]);
> - cb->fill(cb, "recent_scanned_anon", recent_scanned[0]);
> - cb->fill(cb, "recent_scanned_file", recent_scanned[1]);
> + seq_printf(m, "recent_rotated_anon %lu\n", recent_rotated[0]);
> + seq_printf(m, "recent_rotated_file %lu\n", recent_rotated[1]);
> + seq_printf(m, "recent_scanned_anon %lu\n", recent_scanned[0]);
> + seq_printf(m, "recent_scanned_file %lu\n", recent_scanned[1]);
> }
> #endif
>
> @@ -4880,7 +4880,7 @@ static struct cftype mem_cgroup_files[] = {
> },
> {
> .name = "stat",
> - .read_map = mem_control_stat_show,
> + .read_seq_string = mem_control_stat_show,
> },
> {
> .name = "force_empty",
> --
> 1.7.10.1
>
--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-05-15 14:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-14 18:00 [patch 0/6] mm: memcg: statistics implementation cleanups Johannes Weiner
2012-05-14 18:00 ` [patch 1/6] mm: memcg: remove obsolete statistics array boundary enum item Johannes Weiner
2012-05-15 14:14 ` Michal Hocko
2012-05-14 18:00 ` [patch 2/6] mm: memcg: convert numa stat to read_seq_string interface Johannes Weiner
2012-05-15 14:43 ` Michal Hocko
2012-05-14 18:00 ` [patch 3/6] mm: memcg: print statistics directly to seq_file Johannes Weiner
2012-05-15 14:46 ` Michal Hocko [this message]
2012-05-14 18:00 ` [patch 4/6] mm: memcg: keep ratelimit counter separate from event counters Johannes Weiner
2012-05-15 14:58 ` Michal Hocko
2012-05-14 18:00 ` [patch 5/6] mm: memcg: group swapped-out statistics counter logically Johannes Weiner
2012-05-15 15:04 ` Michal Hocko
2012-05-14 18:00 ` [patch 6/6] mm: memcg: print statistics from live counters Johannes Weiner
2012-05-15 15:27 ` Michal Hocko
2012-05-16 23:01 ` Andrew Morton
2012-05-17 0:01 ` KAMEZAWA Hiroyuki
2012-05-17 10:56 ` Glauber Costa
2012-05-15 0:19 ` [patch 0/6] mm: memcg: statistics implementation cleanups KAMEZAWA Hiroyuki
2012-05-15 11:03 ` Johannes Weiner
2012-05-16 0:01 ` KAMEZAWA Hiroyuki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120515144635.GH11346@tiehlicka.suse.cz \
--to=mhocko@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox