linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Michal Hocko <mhocko@kernel.org>
Cc: Jan Kara <jack@suse.cz>, NeilBrown <neilb@suse.de>,
	Trond Myklebust <trondmy@hammerspace.com>,
	"Anna.Schumaker@Netapp.com" <Anna.Schumaker@netapp.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-nfs@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] MM: Discard NR_UNSTABLE_NFS, use NR_WRITEBACK instead.
Date: Tue, 7 Apr 2020 13:33:48 +0200	[thread overview]
Message-ID: <20200407113348.GG9482@quack2.suse.cz> (raw)
In-Reply-To: <20200407112412.GO18914@dhcp22.suse.cz>

On Tue 07-04-20 13:24:12, Michal Hocko wrote:
> On Tue 07-04-20 12:25:15, Jan Kara wrote:
> > > @@ -1707,8 +1706,16 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
> > >  static void *vmstat_next(struct seq_file *m, void *arg, loff_t *pos)
> > >  {
> > >  	(*pos)++;
> > > -	if (*pos >= NR_VMSTAT_ITEMS)
> > > +	if (*pos >= NR_VMSTAT_ITEMS) {
> > > +		/*
> > > +		 * Deprecated counters which are no longer represented
> > > +		 * in vmstat arrays. We just lie about them to be always
> > > +		 * 0 to not break userspace which might expect them in
> > > +		 * the output.
> > > +		 */
> > > +		seq_puts(m, "nr_unstable 0");
> > >  		return NULL;
> > > +	}
> > >  	return (unsigned long *)m->private + *pos;
> > >  }
> > 
> > Umm, how is this supposed to work? vmstat_next() should return next element
> > of the sequence, not fill anything into seq_file - that's the job of
> > vmstat_show(). Looking at seq_read() implementation it may actually end up
> > working fine but I wouldn't really bet much on it especially in corner
> > cases like when we are just about to fill the user buffer and then need to
> > restart reading close to an end of vmstat file or so.
> 
> Well, I have to confess I haven't really tested this myself but the
> logic was to have this output close to NR_VMSTAT_ITEMS break out of
> the counters loop.
> 
> > Michal, won't it be cleaner to have NR_VM_DEPRECATED_ITEMS included in
> > NR_VMSTAT_ITEMS, have names of these items in vmstat_text, and just set
> > appropriate number of 0 entries at the end of the array generated in
> > vmstat_start() and be done with it? That seems conceptually simpler and the
> > overhead is minimal.
> 
> Yes, that would be much nicer, albeit more code.  So I believe you meant
> something like this?
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 462f6873905a..a18611197bea 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -237,7 +237,6 @@ enum node_stat_item {
>  	NR_FILE_THPS,
>  	NR_FILE_PMDMAPPED,
>  	NR_ANON_THPS,
> -	NR_UNSTABLE_NFS,	/* NFS unstable pages */
>  	NR_VMSCAN_WRITE,
>  	NR_VMSCAN_IMMEDIATE,	/* Prioritise for reclaim when writeback ends */
>  	NR_DIRTIED,		/* page dirtyings since bootup */
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 78d53378db99..992e162f1886 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1162,7 +1162,6 @@ const char * const vmstat_text[] = {
>  	"nr_file_hugepages",
>  	"nr_file_pmdmapped",
>  	"nr_anon_transparent_hugepages",
> -	"nr_unstable",
>  	"nr_vmscan_write",
>  	"nr_vmscan_immediate_reclaim",
>  	"nr_dirtied",
> @@ -1293,9 +1292,13 @@ const char * const vmstat_text[] = {
>  	"swap_ra_hit",
>  #endif
>  #endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
> +	/* Deprecated counters. Count them in NR_VM_DEPRECATED_ITEMS */
> +	"nr_unstable",
>  };
>  #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA || CONFIG_MEMCG */
>  
> +#define NR_VM_DEPRECATED_ITEMS 1
> +
>  #if (defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION)) || \
>       defined(CONFIG_PROC_FS)
>  static void *frag_start(struct seq_file *m, loff_t *pos)
> @@ -1661,7 +1664,8 @@ static const struct seq_operations zoneinfo_op = {
>  			 NR_VM_NODE_STAT_ITEMS + \
>  			 NR_VM_WRITEBACK_STAT_ITEMS + \
>  			 (IS_ENABLED(CONFIG_VM_EVENT_COUNTERS) ? \
> -			  NR_VM_EVENT_ITEMS : 0))
> +			  NR_VM_EVENT_ITEMS : 0) + \
> +			  NR_VM_DEPRECATED_ITEMS)
>  
>  static void *vmstat_start(struct seq_file *m, loff_t *pos)
>  {
> @@ -1698,7 +1702,11 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
>  	all_vm_events(v);
>  	v[PGPGIN] /= 2;		/* sectors -> kbytes */
>  	v[PGPGOUT] /= 2;
> +	v += NR_VM_EVENT_ITEMS;
>  #endif
> +	for (i = 0; i < NR_VM_DEPRECATED_ITEMS)
					     ^^ ; i++ here

but otherwise yes, this is what I meant. Thanks!

> +		v[i] = 0;
> +
>  	return (unsigned long *)m->private + *pos;
>  }

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2020-04-07 11:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <draft-87d08kw57p.fsf@notabene.neil.brown.name>
2020-04-06 23:44 ` [PATCH 2/2] MM: Discard NR_UNSTABLE_NFS, use NR_WRITEBACK instead NeilBrown
2020-04-07  2:34   ` Trond Myklebust
2020-04-07  9:19   ` Michal Hocko
2020-04-07 10:25   ` Jan Kara
2020-04-07 11:24     ` Michal Hocko
2020-04-07 11:33       ` Jan Kara [this message]
2020-03-26  3:25 [PATCH/RFC] MM: fix writeback for NFS NeilBrown
2020-04-01 23:52 ` Writeback fixes " NeilBrown
2020-04-06 23:42   ` Writeback fixes for NFS - V2 NeilBrown
2020-04-16  0:29     ` Writeback fixes for NFS - V3 NeilBrown
2020-04-16  0:30       ` [PATCH 1/2 V3] MM: replace PF_LESS_THROTTLE with PF_LOCAL_THROTTLE NeilBrown
2020-04-16 15:19         ` Jan Kara
2020-04-21  2:22           ` NeilBrown
2020-04-22 12:46             ` Jan Kara
2020-05-13  7:16               ` NeilBrown
2020-05-13  7:17                 ` [PATCH 1/2 V4] " NeilBrown
2020-05-15 11:10                   ` Jan Kara
2020-06-01  0:46                     ` Writeback fixes for NFS NeilBrown
2020-06-01  0:49                       ` [PATCH 2/2] MM: Discard NR_UNSTABLE_NFS, use NR_WRITEBACK instead NeilBrown

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=20200407113348.GG9482@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=Anna.Schumaker@netapp.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mhocko@kernel.org \
    --cc=neilb@suse.de \
    --cc=trondmy@hammerspace.com \
    /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).