From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "Adrian Huang (Lenovo)" <adrianhuang0701@gmail.com>
Cc: Suren Baghdasaryan <surenb@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Liam R . Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Jann Horn <jannh@google.com>, Pedro Falcato <pfalcato@suse.de>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, ahuang12@lenovo.com
Subject: Re: [PATCH mm-unstable 1/1] fs/proc/task_mmu: advance seq_file position on interrupted VMA lookup
Date: Mon, 16 Nov 2026 14:37:25 +0000 [thread overview]
Message-ID: <avsQKLgi9bqD51W8@gremlin> (raw)
In-Reply-To: <20261112140101.647-1-adrianhuang0701@gmail.com>
On Thu, Nov 12, 2026 at 10:01:01PM +0800, Adrian Huang (Lenovo) wrote:
> Commit 5631da56c9a8 ("fs/proc/task_mmu: read proc/pid/maps under
> per-vma lock") introduced the possibility of returning -EINTR
> from proc_get_vma() when the VMA lookup is interrupted.
>
> When this happens in m_next(), proc_get_vma() returns an error
> pointer without updating the position index. Consequently,
> seq_read_iter() reports:
>
> seq_file: buggy .next function m_next did not update position index
What does seq_read_iter() 'reporting' something mean? It feels like you're
trying to make this into something bigger than it is.
What you mean to say is a rate-limited pr_info() output occurs, and when a
process that _has received a fatal signal_ (!!) somehow continues long
enough to try to output more data, you get an pr_info().
The relevant code from seq_read_iter():
if (pos == m->index) {
pr_info_ratelimited("buggy .next function %ps did not update position index\n",
m->op->next);
m->index++;
}
Anyway you should mention the fatal signal requirement clearly.
>
> The above buggy message is reproduced by the following command:
>
> # stress-ng --vma 0 -t 60
OK I could reproduce the output locally. It seems that this run results in
fatal signals being sent to the processes triggering this output.
> Update the position index when VMA lookup fails, as required by
> the seq_file interface. Also save the original position in
> priv->last_pos so that subsequent iteration can restart from
> the correct address without skipping or repeating a VMA.
We don't really care about skipping or repeating a VMA for a process that's
about to die :)
We may as well do this but better to just hoist that to share code.
>
> Fixes: 5631da56c9a8 ("fs/proc/task_mmu: read proc/pid/maps under per-vma lock")
This isn't really a bug, it's really cosmetic to be honest. So not sure if
we need a cc: stable hmm.
> Signed-off-by: Adrian Huang (Lenovo) <adrianhuang0701@gmail.com>
See attached suggested patch that makes the comment sane + hoists the shared
bit (dropping a silly existing comment).
With that and an updated commit message should be ok.
> ---
> fs/proc/task_mmu.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 22361607020d..164b4efc5e09 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -221,6 +221,16 @@ static struct vm_area_struct *proc_get_vma(struct seq_file *m, loff_t *ppos)
> if (PTR_ERR(vma) == -EAGAIN && fallback_to_mmap_lock(priv, *ppos))
> goto retry;
>
> + /*
> + * seq_file checks that the position advanced before it looks at
> + * the returned pointer, so an error return that leaves *ppos
> + * alone is reported as a buggy ->next. Advance it, and keep
> + * last_pos at the pending position so m_start() would resume
> + * the lookup from there.
> + */
We don't want (schloppy?) comments that go into painful detail about super
specific elements of the code.
This is asking for bit rot and is too complicated to be in any way useful.
> + priv->last_pos = *ppos;
This is duplicative with code below and strictly not necessary for the fix,
better to hoist I think.
> + (*ppos)++;
> +
> return vma;
> }
>
> --
> 2.43.0
>
Suggested:
----8<----
From 860d936c61bb641b72135e95c291aa6dfbf5fb0f Mon Sep 17 00:00:00 2001
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Date: Mon, 16 Nov 2026 14:33:12 +0000
Subject: [PATCH] tmp
---
fs/proc/task_mmu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 22361607020d..564e52f7ddc6 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -216,16 +216,17 @@ static struct vm_area_struct *proc_get_vma(struct seq_file *m, loff_t *ppos)
retry:
vma = get_next_vma(priv, *ppos);
- /* EINTR of EAGAIN is possible */
+ /* Store previous position to be able to restart if needed */
+ priv->last_pos = *ppos;
if (IS_ERR(vma)) {
if (PTR_ERR(vma) == -EAGAIN && fallback_to_mmap_lock(priv, *ppos))
goto retry;
+ /* Advance to avoid spurious buggy seq warning in dmesg */
+ (*ppos)++;
return vma;
}
- /* Store previous position to be able to restart if needed */
- priv->last_pos = *ppos;
if (vma) {
/*
* Track the end of the reported vma to ensure position changes
--
2.56.0
prev parent reply other threads:[~2026-11-16 14:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 14:01 [PATCH mm-unstable 1/1] fs/proc/task_mmu: advance seq_file position on interrupted VMA lookup Adrian Huang (Lenovo)
2026-11-13 2:37 ` Andrew Morton
2026-11-13 3:13 ` Suren Baghdasaryan
2026-11-13 3:17 ` Suren Baghdasaryan
2026-11-16 6:26 ` Huang Adrian
2026-11-16 14:37 ` Lorenzo Stoakes (ARM) [this message]
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=avsQKLgi9bqD51W8@gremlin \
--to=ljs@kernel.org \
--cc=adrianhuang0701@gmail.com \
--cc=ahuang12@lenovo.com \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=liam@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pfalcato@suse.de \
--cc=surenb@google.com \
--cc=vbabka@kernel.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