cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org>
To: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
Cc: Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	KAMEZAWA Hiroyuki
	<kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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-druUgvl0LCNAfugRpC6u6w@public.gmane.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-druUgvl0LCNAfugRpC6u6w@public.gmane.org>

Nice
Acked-by: Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org>

> ---
>  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

  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
     [not found] ` <1337018451-27359-1-git-send-email-hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2012-05-14 18:00   ` [patch 1/6] mm: memcg: remove obsolete statistics array boundary enum item Johannes Weiner
     [not found]     ` <1337018451-27359-2-git-send-email-hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2012-05-15 14:14       ` Michal Hocko
2012-05-15  0:19   ` [patch 0/6] mm: memcg: statistics implementation cleanups KAMEZAWA Hiroyuki
2012-05-15 11:03     ` Johannes Weiner
     [not found]       ` <20120515110302.GH1406-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2012-05-16  0:01         ` KAMEZAWA Hiroyuki
2012-05-14 18:00 ` [patch 2/6] mm: memcg: convert numa stat to read_seq_string interface Johannes Weiner
     [not found]   ` <1337018451-27359-3-git-send-email-hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
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
     [not found]   ` <1337018451-27359-4-git-send-email-hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
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
     [not found]   ` <1337018451-27359-7-git-send-email-hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2012-05-15 15:27     ` Michal Hocko
2012-05-16 23:01     ` Andrew Morton
     [not found]       ` <20120516160131.fecb5ddf.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2012-05-17  0:01         ` KAMEZAWA Hiroyuki
     [not found]           ` <4FB43FDB.6050300-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2012-05-17 10:56             ` Glauber Costa

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-alswssmvlrq@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
    --cc=kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.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;
as well as URLs for NNTP newsgroup(s).