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: <ZO1TgSCevv5JJEz0@casper.infradead.org>
Date:   Tue, 29 Aug 2023 03:10:09 +0100
From:   Matthew Wilcox <willy@...radead.org>
To:     "Huang, Ying" <ying.huang@...el.com>
Cc:     Zi Yan <ziy@...dia.com>, Kefeng Wang <wangkefeng.wang@...wei.com>,
        Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, david@...hat.com,
        Mike Kravetz <mike.kravetz@...cle.com>, hughd@...gle.com
Subject: Re: [PATCH v2 4/8] mm: migrate: use a folio in
 migrate_misplaced_page()

On Tue, Aug 29, 2023 at 08:49:31AM +0800, Huang, Ying wrote:
> Zi Yan <ziy@...dia.com> writes:
> 
> > On 21 Aug 2023, at 7:56, Kefeng Wang wrote:
> >
> >> Use a folio in migrate_misplaced_page() to save compound_head() calls.
> >>
> >> Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.com>
> >> ---
> >>  mm/migrate.c | 23 ++++++++++++-----------
> >>  1 file changed, 12 insertions(+), 11 deletions(-)
> >
> > LGTM. And a comment below. Reveiwed-by: Zi Yan <ziy@...dia.com>
> >
> >>
> >> diff --git a/mm/migrate.c b/mm/migrate.c
> >> index 281eafdf8e63..fc728f9a383f 100644
> >> --- a/mm/migrate.c
> >> +++ b/mm/migrate.c
> >> @@ -2521,17 +2521,18 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma,
> >>  			   int node)
> >>  {
> >>  	pg_data_t *pgdat = NODE_DATA(node);
> >> +	struct folio *folio = page_folio(page);
> >>  	int isolated;
> >>  	int nr_remaining;
> >>  	unsigned int nr_succeeded;
> >>  	LIST_HEAD(migratepages);
> >> -	int nr_pages = thp_nr_pages(page);
> >> +	int nr_pages = folio_nr_pages(folio);
> >>
> >>  	/*
> >>  	 * Don't migrate file pages that are mapped in multiple processes
> >>  	 * with execute permissions as they are probably shared libraries.
> >>  	 */
> >> -	if (page_mapcount(page) != 1 && page_is_file_lru(page) &&
> >> +	if (page_mapcount(page) != 1 && folio_is_file_lru(folio) &&
> >
> > page_mapcount() is not converted, since folio_mapcount() is not equivalent
> > to page_mapcount(). It can be converted and this function can be converted
> > to migrate_misplaced_folio() once we have something like folio_num_sharers().
> 
> It seems that we can use folio_estimated_sharers() here.

So, funny thing, page_mapcount() was always wrong here.  We have two
callers, do_huge_pmd_numa_page() and do_numa_page().  do_numa_page()
has a check for PageCompound() (and /* TODO: handle PTE-mapped THP */).
do_huge_pmd_numa_page() returns pfn_to_page(), after it got the pfn
fromm pmd_pfn(pmd).

That makes folio_estimated_sharers() an improvement, possibly even
a bugfix.  Also, we should look at removing the PageCompound() check
in do_numa_page().

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ