lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c558cbfa-3539-40de-b0cf-4c6ae160aacb@amd.com>
Date: Wed, 19 Nov 2025 12:30:50 +0530
From: "Garg, Shivank" <shivankg@....com>
To: Dev Jain <dev.jain@....com>, Andrew Morton <akpm@...ux-foundation.org>,
 David Hildenbrand <david@...hat.com>,
 Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Cc: Zi Yan <ziy@...dia.com>, Baolin Wang <baolin.wang@...ux.alibaba.com>,
 "Liam R . Howlett" <Liam.Howlett@...cle.com>, Nico Pache
 <npache@...hat.com>, Ryan Roberts <ryan.roberts@....com>,
 Barry Song <baohua@...nel.org>, Lance Yang <lance.yang@...ux.dev>,
 Steven Rostedt <rostedt@...dmis.org>, Masami Hiramatsu
 <mhiramat@...nel.org>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
 Zach O'Keefe <zokeefe@...gle.com>, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] mm/khugepaged: return EAGAIN for transient dirty
 pages in MADV_COLLAPSE



On 11/10/2025 7:16 PM, Dev Jain wrote:
> 
> On 10/11/25 5:02 pm, Shivank Garg wrote:
>> When MADV_COLLAPSE encounters dirty file-backed pages, it currently
>> returns -EINVAL, this is misleading as EINVAL suggests invalid arguments,
>> whereas dirty pages are a transient condition that may resolve on retry.
>>
>> Introduce SCAN_PAGE_DIRTY and map it to -EAGAIN. For khugepaged, this
>> is harmless as it will revisit the range after async writeback completes.
> 
> Taking a cursory look at enum scan_result, I am sure there are other error
> codes as well which redirect to -EINVAL when they actually should to something
> else...
> 
>>

>> @@ -1967,7 +1968,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
>>                    */
>>                   xas_unlock_irq(&xas);
>>                   filemap_flush(mapping);
>> -                result = SCAN_FAIL;
>> +                result = SCAN_PAGE_DIRTY;
>>                   goto xa_unlocked;
>>               } else if (folio_test_writeback(folio)) {
>>                   xas_unlock_irq(&xas);
> 
> Now that you are at it, it would make sense to redirect this folio_test_writeback()
> branch also to -EAGAIN, and call the common error code SCAN_PAGE_UNDER_WRITEBACK.
>

Good point about the folio_test_writeback() case.
I think we can use a single error code "SCAN_PAGE_NOT_CLEAN" to cover both dirty and writeback states.

Thanks,
Shivank

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ