Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Vineet Agarwal <agarwal.vineet2006@gmail.com>
Cc: david@kernel.org, ljs@kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, ziy@nvidia.com,
	baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com,
	npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com,
	baohua@kernel.org, lance.yang@linux.dev
Subject: Re: [PATCH] mm/khugepaged: return -EAGAIN for SCAN_PAGE_HAS_PRIVATE in MADV_COLLAPSE
Date: Wed, 29 Apr 2026 07:57:24 -0700	[thread overview]
Message-ID: <20260429075724.a97a964003f624e47d9c0a54@linux-foundation.org> (raw)
In-Reply-To: <20260429140434.439456-1-agarwal.vineet2006@gmail.com>

On Wed, 29 Apr 2026 19:34:34 +0530 Vineet Agarwal <agarwal.vineet2006@gmail.com> wrote:

> MADV_COLLAPSE uses errno values to provide actionable feedback to
> userspace. Temporary resource constraints are mapped to -EAGAIN so the
> caller may retry, while intrinsic failures of the specified range are
> mapped to -EINVAL.
> 
> collapse_file() returns SCAN_PAGE_HAS_PRIVATE when
> filemap_release_folio() fails while isolating file-backed folios for
> collapse. This currently falls through the default case in
> madvise_collapse_errno() and is reported to userspace as -EINVAL.
> 
> However, filemap_release_folio() failure commonly reflects temporary
> folio state rather than a permanently uncollapsible range.
> 
> For example, ext4 returns false when a folio still has dirty
> journalled data, btrfs returns false for dirty or writeback folios
> before extent state release, and NFS may return false while reclaiming
> filesystem-private folio state.
> 
> In such cases, retrying MADV_COLLAPSE after writeback, reclaim or
> journal progress may succeed. This matches the existing -EAGAIN
> handling for SCAN_PAGE_DIRTY_OR_WRITEBACK and other transient collapse
> failures more closely than -EINVAL.
> 
> Therefore, map SCAN_PAGE_HAS_PRIVATE to -EAGAIN so userspace receives
> retryable feedback for this temporary failure path.

Seems very reasonable to me.

The madvise(2) manpage could be a lot more helpful here.

	EAGAIN A kernel resource was temporarily unavailable.

and that's it!


      parent reply	other threads:[~2026-04-29 14:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29 14:04 [PATCH] mm/khugepaged: return -EAGAIN for SCAN_PAGE_HAS_PRIVATE in MADV_COLLAPSE Vineet Agarwal
2026-04-29 14:20 ` Dev Jain
2026-04-29 14:40   ` David Hildenbrand (Arm)
2026-04-29 14:57 ` Andrew Morton [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=20260429075724.a97a964003f624e47d9c0a54@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=agarwal.vineet2006@gmail.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=lance.yang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=npache@redhat.com \
    --cc=ryan.roberts@arm.com \
    --cc=ziy@nvidia.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