From: Andrew Morton <akpm@linux-foundation.org>
To: Weilin Tong <tongweilin@linux.alibaba.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
David Hildenbrand <david@kernel.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] tools/mm/thpmaps: fix missing mapping names
Date: Sun, 1 Nov 2026 21:16:44 -0800 [thread overview]
Message-ID: <20261101211644.c63a2028bbede0f763f41f80@linux-foundation.org> (raw)
In-Reply-To: <20261027074904.3328878-4-tongweilin@linux.alibaba.com>
On Tue, 27 Oct 2026 15:49:04 +0800 Weilin Tong <tongweilin@linux.alibaba.com> wrote:
> VMAList splits smaps lines on whitespace and only keeps the mapping
> name when there are exactly six fields. Names containing whitespace,
> including paths with a (deleted) suffix, are therefore lost.
>
> Limit splitting to the five fixed fields and preserve the remaining
> name.
>
> ...
>
> --- a/tools/mm/thpmaps
> +++ b/tools/mm/thpmaps
> @@ -198,7 +198,7 @@ class VMAList:
> self.vmas = []
> with open(f'/proc/{pid}/smaps', 'r') as file:
> for line in file:
> - elements = line.split()
> + elements = line.rstrip('\n').split(maxsplit=5)
> if '-' in elements[0]:
> start, end = map(lambda x: int(x, 16), elements[0].split('-'))
> major, minor = map(lambda x: int(x, 16), elements[3].split(':'))
Thanks. My pedantic reviewbot points out
: Could we also handle carriage returns and non-UTF-8 bytes in filenames?
: Both are valid filename contents. Python's universal newline handling
: splits the former into separate records, while strict decoding raises
: UnicodeDecodeError for the latter.
:
: I reproduced both failures with real file mappings, before and after
: this series. Opening smaps this way fixes the tested cases:
:
: with open(f'/proc/{pid}/smaps', 'r', newline='\n',
: errors='surrogateescape') as file:
:
: These are pre-existing problems, not regressions introduced here.
: They could be included in [3/3] or handled in a follow-up.
and yup, these patterns could indeed be encountered.
But let me grab the series as-is, on the grounds it's much better than
before - spaces in filenames are common whereas \r's and non-UTF8 are
not.
next prev parent reply other threads:[~2026-11-02 5:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 7:49 [PATCH 0/3] tools/mm/thpmaps: fix THP statistics and " Weilin Tong
2026-10-27 7:49 ` [PATCH 1/3] tools/mm/thpmaps: fix partial THP anon/file accounting Weilin Tong
2026-10-27 7:49 ` [PATCH 2/3] tools/mm/thpmaps: fix missing order-1 file THP statistics Weilin Tong
2026-11-02 12:51 ` David Hildenbrand (Arm)
2026-10-27 7:49 ` [PATCH 3/3] tools/mm/thpmaps: fix missing mapping names Weilin Tong
2026-11-02 5:16 ` Andrew Morton [this message]
2026-11-02 8:54 ` [PATCH] tools/mm/thpmaps: handle carriage returns and non-UTF-8 filenames Weilin Tong
2026-11-02 12:53 ` [PATCH 3/3] tools/mm/thpmaps: fix missing mapping names David Hildenbrand (Arm)
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=20261101211644.c63a2028bbede0f763f41f80@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryan.roberts@arm.com \
--cc=tongweilin@linux.alibaba.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
all inboxes | Powered by JetHome®