linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: Michal Hocko <mhocko@kernel.org>,
	Xiao Guangrong <guangrong.xiao@linux.intel.com>,
	pbonzini@redhat.com, akpm@linux-foundation.org,
	dan.j.williams@intel.com, gleb@kernel.org, mtosatti@redhat.com,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	stefanha@redhat.com, yuhuang@redhat.com, linux-mm@kvack.org,
	ross.zwisler@linux.intel.com
Subject: Re: [PATCH v2] mm, proc: Fix region lost in /proc/self/smaps
Date: Wed, 14 Sep 2016 17:38:14 +0200	[thread overview]
Message-ID: <20160914153814.GA21284@redhat.com> (raw)
In-Reply-To: <57D8277E.80505@intel.com>

On 09/13, Dave Hansen wrote:
>
> On 09/13/2016 07:59 AM, Oleg Nesterov wrote:
> > I agree. I don't even understand why this was considered as a bug.
> > Obviously, m_stop() which drops mmap_sep should not be called, or
> > all the threads should be stopped, if you want to trust the result.
>
> There was a mapping at a given address.  That mapping did not change, it
> was not split, its attributes did not change.  But, it didn't show up
> when reading smaps.  Folks _actually_ noticed this in a test suite
> looking for that address range in smaps.

I understand, and I won't argue with any change which makes the things
better. Just I do not think this is a real problem. And this patch can't
fix other oddities and it seems it adds another one (at least) although
I can easily misread this patch and/or the code.

So we change m_cache_vma(),

	-        m->version = m_next_vma(m->private, vma) ? vma->vm_start : -1UL;
	+        m->version = m_next_vma(m->private, vma) ? vma->vm_end : -1UL;

OK, and another change in m_start()

	-        if (vma && (vma = m_next_vma(priv, vma)))
	+        if (vma)

means that it can return the same vma if it grows in between.

show_map_vma() has another change

	+       start = max(vma->vm_start, start);

so it will be reported as _another_ vma, and this doesn't look exactly
right.

And after that *ppos will be falsely incremented... but probably this
doesn't matter because the "if (pos < mm->map_count)" logic in m_start()
looks broken anyway.

> IOW, we had goofy kernel behavior, and it broke a reasonable test
> program.  The test program just used fgets() to read into a fixed-length
> buffer, which is a completely normal thing to do.
>
> To get "sensible results", doesn't userspace have to somehow know in
> advance how many bytes of data a given VMA will generate in smaps output?

Yes, /proc/has its limitations ;)

Even if you read, say, /proc/pid/status you can get the corrupted result
after the short read. But in this case fgets() should likely work, yes.


Dave, let me repeat, I won't argue with any change and in any case you
can safely ignore my opinion.

Oleg.

  reply	other threads:[~2016-09-14 15:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12  3:12 [PATCH v2] mm, proc: Fix region lost in /proc/self/smaps Xiao Guangrong
2016-09-12 12:54 ` Michal Hocko
2016-09-12 15:01   ` Dave Hansen
2016-09-12 19:10     ` Michal Hocko
2016-09-13  3:01       ` Xiao Guangrong
2016-09-13 14:59       ` Oleg Nesterov
2016-09-13 16:21         ` Dave Hansen
2016-09-14 15:38           ` Oleg Nesterov [this message]
2016-09-19  7:21             ` Xiao Guangrong

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=20160914153814.GA21284@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=gleb@kernel.org \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=ross.zwisler@linux.intel.com \
    --cc=stefanha@redhat.com \
    --cc=yuhuang@redhat.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).