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: <87ilbk8b89.fsf@yhuang6-desk2.ccr.corp.intel.com>
Date:   Mon, 19 Jun 2023 09:57:58 +0800
From:   "Huang, Ying" <ying.huang@...el.com>
To:     Yosry Ahmed <yosryahmed@...gle.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Yu Zhao <yuzhao@...gle.com>,
        "Jan Alexander Steffens (heftig)" <heftig@...hlinux.org>,
        Steven Barrett <steven@...uorix.net>,
        Brian Geffon <bgeffon@...gle.com>,
        "T.J. Alumbaugh" <talumbau@...gle.com>,
        Gaosheng Cui <cuigaosheng1@...wei.com>,
        Suren Baghdasaryan <surenb@...gle.com>,
        "Matthew Wilcox (Oracle)" <willy@...radead.org>,
        "Liam R. Howlett" <Liam.Howlett@...cle.com>,
        David Hildenbrand <david@...hat.com>,
        Jason Gunthorpe <jgg@...pe.ca>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        David Howells <dhowells@...hat.com>,
        Hugh Dickins <hughd@...gle.com>,
        Greg Thelen <gthelen@...gle.com>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH 5/5] Revert "mm/migrate: __unmap_and_move() push
 good newpage to LRU"

Hi, Yosry,

Yosry Ahmed <yosryahmed@...gle.com> writes:

> This reverts commit c3096e6782b733158bf34f6bbb4567808d4e0740.
>
> That commit made sure we immediately add the new page to the LRU before
> remove_migration_ptes() is called in migrate_move_folio() (used to be
> __unmap_and_move() back then), such that the rmap walk will rebuild the
> correct mlock_count for the page again. This was needed because the
> mlock_count was lost when the page is isolated. This is no longer the
> case since mlock_count no longer overlays page->lru.
>
> Revert the commit (the code was foliated afterward the commit, so the
> revert is updated as such).
>
> Signed-off-by: Yosry Ahmed <yosryahmed@...gle.com>
> ---
>  mm/migrate.c | 24 +++++++++---------------
>  1 file changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 01cac26a3127..68f693731865 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1279,19 +1279,6 @@ static int migrate_folio_move(free_page_t put_new_page, unsigned long private,
>  	if (unlikely(!is_lru))
>  		goto out_unlock_both;

The patch itself looks good to me!  Thanks!

Reviewed-by: "Huang, Ying" <ying.huang@...el.com>

And, it seems that we can remove the above 2 lines and "out_unlock_both"
label now.  That can make the code simpler a little.  Right?

Best Regards,
Huang, Ying

> -	/*
> -	 * When successful, push dst to LRU immediately: so that if it
> -	 * turns out to be an mlocked page, remove_migration_ptes() will
> -	 * automatically build up the correct dst->mlock_count for it.
> -	 *
> -	 * We would like to do something similar for the old page, when
> -	 * unsuccessful, and other cases when a page has been temporarily
> -	 * isolated from the unevictable LRU: but this case is the easiest.
> -	 */
> -	folio_add_lru(dst);
> -	if (page_was_mapped)
> -		lru_add_drain();
> -
>  	if (page_was_mapped)
>  		remove_migration_ptes(src, dst, false);
>  
> @@ -1301,9 +1288,16 @@ static int migrate_folio_move(free_page_t put_new_page, unsigned long private,
>  	/*
>  	 * If migration is successful, decrease refcount of dst,
>  	 * which will not free the page because new page owner increased
> -	 * refcounter.
> +	 * refcounter. As well, if it is LRU folio, add the folio to LRU
> +	 * list in here. Use the old state of the isolated source folio to
> +	 * determine if we migrated a LRU folio. dst was already unlocked
> +	 * and possibly modified by its owner - don't rely on the folio
> +	 * state.
>  	 */
> -	folio_put(dst);
> +	if (unlikely(!is_lru))
> +		folio_put(dst);
> +	else
> +		folio_putback_lru(dst);
>  
>  	/*
>  	 * A folio that has been migrated has all references removed

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ