mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH mm-unstable v2 1/1] fs/proc/task_mmu: avoid spurious seq_file warning on interrupted VMA lookup
@ 2026-11-18 10:34 Adrian Huang (Lenovo)
  2026-11-18 12:12 ` Lorenzo Stoakes (ARM)
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Huang (Lenovo) @ 2026-11-18 10:34 UTC (permalink / raw)
  To: Suren Baghdasaryan, Lorenzo Stoakes
  Cc: Andrew Morton, Liam R . Howlett, Vlastimil Babka, Jann Horn,
	Pedro Falcato, linux-mm, linux-kernel, linux-fsdevel, ahuang12,
	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

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.

Suggested-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Signed-off-by: Adrian Huang (Lenovo) <adrianhuang0701@gmail.com>
---
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(-)

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.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH mm-unstable v2 1/1] fs/proc/task_mmu: avoid spurious seq_file warning on interrupted VMA lookup
  2026-11-18 10:34 [PATCH mm-unstable v2 1/1] fs/proc/task_mmu: avoid spurious seq_file warning on interrupted VMA lookup Adrian Huang (Lenovo)
@ 2026-11-18 12:12 ` Lorenzo Stoakes (ARM)
  0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-18 12:12 UTC (permalink / raw)
  To: Adrian Huang (Lenovo)
  Cc: Suren Baghdasaryan, Andrew Morton, Liam R . Howlett,
	Vlastimil Babka, Jann Horn, Pedro Falcato, linux-mm,
	linux-kernel, linux-fsdevel, ahuang12

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

On Wed, Nov 18, 2026 at 06:34:21PM +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 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.
>
> Suggested-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> Signed-off-by: Adrian Huang (Lenovo) <adrianhuang0701@gmail.com>

LGTM and:

Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

> ---
> 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(-)
>
> 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.43.0
>

--
Cheers, Lorenzo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-18 12:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 10:34 [PATCH mm-unstable v2 1/1] fs/proc/task_mmu: avoid spurious seq_file warning on interrupted VMA lookup Adrian Huang (Lenovo)
2026-11-18 12:12 ` Lorenzo Stoakes (ARM)

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®