Skip to contentSkip to conversation

fs/proc/task_mmu: avoid spurious seq_file warning on interrupted VMA lookup

PATCH In review Adrian Huang (Lenovo) 4 participants 5 messages Nov 18 – Nov 19

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fs/proc/task_mmu: avoid spurious seq_file warning on interrupted VMA lookup

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 a fatal signal interrupts mmap_read_lock_killable().

The issue can be reproduced using stress-ng's VMA stressor, which reads /proc/self/maps while concurrently modifying VMAs and periodically terminates child processes with SIGKILL. The reproduced command is:

  # stress-ng --vma 0 -t 60

When the VMA lookup is interrupted, proc_get_vma() returns an error pointer without advancing the position index. Consequently, seq_read_iter() emits the following rate-limited informational message:

seq_file: buggy .next function m_next did not update position index

Save the current position in priv->last_pos before checking the VMA lookup result, allowing it to be reused by both successful and error paths. Advance the position index when returning an error to avoid the spurious warning, while preserving the original error handling.

---
Changes since v1:
- Simplify the error handling and comments as suggested by Lorenzo.
- Clarify the fatal-signal trigger and the cosmetic nature of the warning.

 fs/proc/task_mmu.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/proc/task_mmu.c +4 -3
index 22361607020d..564e52f7ddc6 100644
@@ -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
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 1/1
#1 lore raw

(micro-nit - no need to say 1/1 for a single patch :)

Quoted 16 lines · Adrian Huang (Lenovo)

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 a fatal signal interrupts mmap_read_lock_killable().

The issue can be reproduced using stress-ng's VMA stressor, which reads /proc/self/maps while concurrently modifying VMAs and periodically terminates child processes with SIGKILL. The reproduced command is:

  # stress-ng --vma 0 -t 60

When the VMA lookup is interrupted, proc_get_vma() returns an error pointer without advancing the position index. Consequently, seq_read_iter() emits the following rate-limited informational message:

seq_file: buggy .next function m_next did not update position index

Quoted 7 lines

Save the current position in priv->last_pos before checking the VMA lookup result, allowing it to be reused by both successful and error paths. Advance the position index when returning an error to avoid the spurious warning, while preserving the original error handling.

LGTM and:

Quoted 34 lines

---
Changes since v1:
- Simplify the error handling and comments as suggested by Lorenzo.
- Clarify the fatal-signal trigger and the cosmetic nature of the warning.

 fs/proc/task_mmu.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/proc/task_mmu.c +4 -4
index 22361607020d..564e52f7ddc6 100644
@@ -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
--
Quoted 2 lines

2.43.0

--
Cheers, Lorenzo

maintainer
#2 lore raw
In reply to Adrian Huang (Lenovo)
Quoted 8 lines · On Wed, 18 Nov 2026 18:34:21 +0800 "Adrian Huang (Lenovo)"…

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 a fatal signal interrupts mmap_read_lock_killable().

The issue can be reproduced using stress-ng's VMA stressor, which reads /proc/self/maps while concurrently modifying VMAs and periodically terminates child processes with SIGKILL. The reproduced command is:

Quoted 7 lines
  # stress-ng --vma 0 -t 60

When the VMA lookup is interrupted, proc_get_vma() returns an error pointer without advancing the position index. Consequently, seq_read_iter() emits the following rate-limited informational message:

seq_file: buggy .next function m_next did not update position index

Thanks. That's just bad behavior.

Quoted 4 lines

Save the current position in priv->last_pos before checking the VMA lookup result, allowing it to be reused by both successful and error paths. Advance the position index when returning an error to avoid the spurious warning, while preserving the original error handling.

So I'll add a cc:stable to this, target the next merge window.

maintainer tree notice
#3 lore raw

+ fs-proc-task_mmu-avoid-spurious-seq_file-warning-on-interrupted-vma-lookup.patch added to mm-new branch

In reply to Adrian Huang (Lenovo)
The patch titled Subject: fs/proc/task_mmu: avoid spurious seq_file warning on interrupted VMA lookup has been added to the -mm mm-new branch. Its filename is…

The patch titled
Subject: fs/proc/task_mmu: avoid spurious seq_file warning on interrupted VMA lookup
has been added to the -mm mm-new branch. Its filename is
fs-proc-task_mmu-avoid-spurious-seq_file-warning-on-interrupted-vma-lookup.patch

This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/fs-proc-task_mmu-avoid-spurious-seq_file-warning-on-interrupted-vma-lookup.patch

This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new.

The mm-new branch of mm.git is not included in linux-next

If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: "Adrian Huang (Lenovo)" <[email protected]>
Subject: fs/proc/task_mmu: avoid spurious seq_file warning on interrupted VMA lookup
Date: Wed, 18 Nov 2026 18:34:21 +0800

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 a fatal signal interrupts mmap_read_lock_killable().

The issue can be reproduced using stress-ng's VMA stressor, which reads /proc/self/maps while concurrently modifying VMAs and periodically terminates child processes with SIGKILL. The reproduced command is:

  # stress-ng --vma 0 -t 60

When the VMA lookup is interrupted, proc_get_vma() returns an error pointer without advancing the position index. Consequently, seq_read_iter() emits the following rate-limited informational message:

seq_file: buggy .next function m_next did not update position index

Save the current position in priv->last_pos before checking the VMA lookup result, allowing it to be reused by both successful and error paths. Advance the position index when returning an error to avoid the spurious warning, while preserving the original error handling.

 fs/proc/task_mmu.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/proc/task_mmu.c renamed from fs/proc/task_mmu.c~fs-proc-task_mmu-avoid-spurious-seq_file-warning-on-interrupted-vma-lookup +4 -3
@@ -216,16 +216,17 @@ static struct vm_area_struct *proc_get_v
 
 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

_

Patches currently in -mm which might be from [email protected] are

mm-damon-core-remove-unnecessary-zero-initialization-in-damon_new_ctx.patch docs-admin-guide-mm-damon-fix-various-typos.patch docs-admin-guide-mm-damon-lru_sort-fix-copy-paste-mistakes.patch docs-admin-guide-mm-damon-usage-fix-incorrect-option-syntax-in-perf-example.patch fs-proc-task_mmu-avoid-spurious-seq_file-warning-on-interrupted-vma-lookup.patch

#4 lore raw
In reply to Adrian Huang (Lenovo)
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] fs/proc/task_mmu: missing Fixes trailer for commit 5631da56c9a8 --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] fs/proc/task_mmu: missing Fixes trailer for commit 5631da56c9a8 --

commit ea1e2d22fcfe8a8b373cfb53c201e13a9ff8f69b
Author: Adrian Huang (Lenovo) <[email protected]>

Quoted 18 lines

fs/proc/task_mmu: avoid spurious seq_file warning on interrupted VMA lookup

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 a fatal signal interrupts mmap_read_lock_killable().

The issue can be reproduced using stress-ng's VMA stressor, which reads /proc/self/maps while concurrently modifying VMAs and periodically terminates child processes with SIGKILL. The reproduced command is:

  # stress-ng --vma 0 -t 60

When the VMA lookup is interrupted, proc_get_vma() returns an error pointer without advancing the position index. Consequently, seq_read_iter() emits the following rate-limited informational message:

seq_file: buggy .next function m_next did not update position index

Quoted 7 lines

Save the current position in priv->last_pos before checking the VMA lookup result, allowing it to be reused by both successful and error paths. Advance the position index when returning an error to avoid the spurious warning, while preserving the original error handling.

[Severity: Low]
Should this commit include a Fixes tag for the commit it identifies?

Fixes 5631da56c9a8 ("fs/proc/task_mmu: read proc/pid/maps under per-vma lock")
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1