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: <aJo7_B6cQc1EucA1@hyeyoo>
Date: Tue, 12 Aug 2025 03:52:44 +0900
From: Harry Yoo <harry.yoo@...cle.com>
To: Jialin Wang <wjl.linux@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
        Johannes Weiner <hannes@...xchg.org>,
        David Hildenbrand <david@...hat.com>, Michal Hocko <mhocko@...nel.org>,
        Qi Zheng <zhengqi.arch@...edance.com>,
        Shakeel Butt <shakeel.butt@...ux.dev>,
        Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND] mm/vmscan: remove redundant
 folio_test_swapbacked()

This is marked as RESEND, but which patch is it a resend of?
I can’t find the original one.

On Tue, Aug 12, 2025 at 02:25:00AM +0800, Jialin Wang wrote:
> When !folio_is_file_lru(folio) is false, it implies that
> !folio_test_swapbacked(folio) must be true.

That is not true.

MADV_FREE pages are anonymous pages that are not swapbacked
(and thus can be reclaimed without pageout if they are clean).

See below commit that added the condition and the patch series
that introduced it:
https://lore.kernel.org/all/cover.1487965799.git.shli@fb.com/

commit 802a3a92ad7ac0b9be9df229dee530a1f0a8039b
Author: Shaohua Li <shli@...com>
Date:   Wed May 3 14:52:32 2017 -0700

    mm: reclaim MADV_FREE pages

    When memory pressure is high, we free MADV_FREE pages.  If the pages are
    not dirty in pte, the pages could be freed immediately.  Otherwise we
    can't reclaim them.  We put the pages back to anonumous LRU list (by
    setting SwapBacked flag) and the pages will be reclaimed in normal
    swapout way.

    We use normal page reclaim policy.  Since MADV_FREE pages are put into
    inactive file list, such pages and inactive file pages are reclaimed
    according to their age.  This is expected, because we don't want to
    reclaim too many MADV_FREE pages before used once pages.

    Based on Minchan's original patch

    [minchan@...nel.org: clean up lazyfree page handling]
      Link: http://lkml.kernel.org/r/20170303025237.GB3503@bbox
    Link: http://lkml.kernel.org/r/14b8eb1d3f6bf6cc492833f183ac8c304e560484.1487965799.git.shli@fb.com
    Signed-off-by: Shaohua Li <shli@...com>
    Signed-off-by: Minchan Kim <minchan@...nel.org>
    Acked-by: Minchan Kim <minchan@...nel.org>
    Acked-by: Michal Hocko <mhocko@...e.com>
    Acked-by: Johannes Weiner <hannes@...xchg.org>
    Acked-by: Hillf Danton <hillf.zj@...baba-inc.com>
    Cc: Hugh Dickins <hughd@...gle.com>
    Cc: Rik van Riel <riel@...hat.com>
    Cc: Mel Gorman <mgorman@...hsingularity.net>
    Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>

-- 
Cheers,
Harry / Hyeonggon

> Therefore, the additional
> check for !folio_test_swapbacked(folio) is redundant and can be safely
> removed.
> 
> This cleanup simplifies the code without changing any functionality.
> 
> Signed-off-by: Jialin Wang <wjl.linux@...il.com>
> ---
>  mm/vmscan.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 7de11524a936..9d4745ad5e23 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -985,8 +985,7 @@ static void folio_check_dirty_writeback(struct folio *folio,
>  	 * They could be mistakenly treated as file lru. So further anon
>  	 * test is needed.
>  	 */
> -	if (!folio_is_file_lru(folio) ||
> -	    (folio_test_anon(folio) && !folio_test_swapbacked(folio))) {
> +	if (!folio_is_file_lru(folio) || folio_test_anon(folio)) {
>  		*dirty = false;
>  		*writeback = false;
>  		return;
> -- 
> 2.50.0
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ