From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9ADDA31ED80 for ; Wed, 29 Apr 2026 14:57:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777474645; cv=none; b=Wa0oYqk16ZHklp6JKOCMIq5Ktyz6/znSKSYXUDiH0CWzA5OAMCx6gxN55/meKHt80VVxbGeskdQEm3eem2gNZ05MtCOvx7YavicEFUOHL+YXqxeCk3xf807pyeBu1RjOaDGuuNETvPJjjJ8b4PArS2xtGgXf8T02VNN3Hlzidgs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777474645; c=relaxed/simple; bh=NlNJ6ZE1PtVHQsujI8aiMe4rB+6XsGkXf8RSunRrXUI=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=uTXbmEtxt6rumt5DHx60VO66z0cMPTfXQMZ7SuALhRtiEHlyvWTJFN1FCMsBo1T5mjPoNYaEAqw4sUwuevtxZJ0fB1HeAcum8kX6Z3gz8ywvI4wqu+JT9/7+CbRaPe7vmtFOCL8p6fg35FnzGET+Oo9V/vd2aNtR43Si8ZuRCQs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=ZT7h2jKt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="ZT7h2jKt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D175CC19425; Wed, 29 Apr 2026 14:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1777474645; bh=NlNJ6ZE1PtVHQsujI8aiMe4rB+6XsGkXf8RSunRrXUI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ZT7h2jKtezIYqQe+ESZxeDe1Z3QaoB2gaXbMeIPypYqY+hjd31tIw/88Ipnzt94/M vSWqGo4F+8jJCNVmxIe8O4Ydv5j1TPp1ez6ix3/6ErT4+WIMDGEcXYWZcy0x0dVTcF SLChFWxLI7k996tm7v3moitsx9QGpD7DRfSJPw7A= Date: Wed, 29 Apr 2026 07:57:24 -0700 From: Andrew Morton To: Vineet Agarwal 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 Message-Id: <20260429075724.a97a964003f624e47d9c0a54@linux-foundation.org> In-Reply-To: <20260429140434.439456-1-agarwal.vineet2006@gmail.com> References: <20260429140434.439456-1-agarwal.vineet2006@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 29 Apr 2026 19:34:34 +0530 Vineet Agarwal 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!