From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Matthew Wilcox <willy@infradead.org>,
"Huang, Ying" <ying.huang@intel.com>
Cc: Zi Yan <ziy@nvidia.com>,
Andrew Morton <akpm@linux-foundation.org>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, <david@redhat.com>,
Mike Kravetz <mike.kravetz@oracle.com>, <hughd@google.com>
Subject: Re: [PATCH v2 4/8] mm: migrate: use a folio in migrate_misplaced_page()
Date: Wed, 30 Aug 2023 17:45:57 +0800 [thread overview]
Message-ID: <646b619b-470a-40eb-bee9-85c7bd4c8a54@huawei.com> (raw)
In-Reply-To: <ZO1TgSCevv5JJEz0@casper.infradead.org>
On 2023/8/29 10:10, Matthew Wilcox wrote:
> On Tue, Aug 29, 2023 at 08:49:31AM +0800, Huang, Ying wrote:
>> Zi Yan <ziy@nvidia.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@huawei.com>
>>>> ---
>>>> mm/migrate.c | 23 ++++++++++++-----------
>>>> 1 file changed, 12 insertions(+), 11 deletions(-)
>>>
>>> LGTM. And a comment below. Reveiwed-by: Zi Yan <ziy@nvidia.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).
for PMD-mapped page,do_huge_pmd_numa_page() return head page
unsigned long haddr = vmf->address & HPAGE_PMD_MASK;
page = vm_normal_page_pmd(vma, haddr, pmd);
do_numa_page() only handle base page with PageCompound() check, so we
could use folio_estimated_sharers(), I am not clear why page_mapcount
is wrong here, could you explain more, thank.
>
> That makes folio_estimated_sharers() an improvement, possibly even
> a bugfix. Also, we should look at removing the PageCompound() check
> in do_numa_page().
Yes, for pte-mapped thp and the large folio numa migrate support, we
need remove the check, we could do it in another patchset.
>
>
next prev parent reply other threads:[~2023-08-30 19:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-21 11:56 [PATCH v2 0/8] mm: migrate: more folio conversion and unify Kefeng Wang
2023-08-21 11:56 ` [PATCH v2 1/8] mm: migrate: remove PageTransHuge check in numamigrate_isolate_page() Kefeng Wang
2023-08-21 12:38 ` Matthew Wilcox
2023-08-21 12:52 ` Kefeng Wang
2023-08-21 14:41 ` Kefeng Wang
2023-08-25 3:51 ` Kefeng Wang
2023-08-21 11:56 ` [PATCH v2 2/8] mm: migrate: remove THP mapcount " Kefeng Wang
2023-08-22 2:22 ` Huang, Ying
2023-08-21 11:56 ` [PATCH v2 3/8] mm: migrate: convert numamigrate_isolate_page() to numamigrate_isolate_folio() Kefeng Wang
2023-08-28 14:03 ` Zi Yan
2023-08-21 11:56 ` [PATCH v2 4/8] mm: migrate: use a folio in migrate_misplaced_page() Kefeng Wang
2023-08-28 14:10 ` Zi Yan
2023-08-29 0:49 ` Huang, Ying
2023-08-29 2:10 ` Matthew Wilcox
2023-08-30 9:45 ` Kefeng Wang [this message]
2023-08-21 11:56 ` [PATCH v2 5/8] mm: migrate: use __folio_test_movable() Kefeng Wang
2023-08-28 14:11 ` Zi Yan
2023-08-21 11:56 ` [PATCH v2 6/8] mm: migrate: use a folio in add_page_for_migration() Kefeng Wang
2023-08-28 14:13 ` Zi Yan
2023-08-21 11:56 ` [PATCH v2 7/8] mm: migrate: remove PageHead() check for HugeTLB " Kefeng Wang
2023-08-28 14:15 ` Zi Yan
2023-08-21 11:56 ` [PATCH v2 8/8] mm: migrate: remove isolated variable " Kefeng Wang
2023-08-28 14:18 ` Zi Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=646b619b-470a-40eb-bee9-85c7bd4c8a54@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=willy@infradead.org \
--cc=ying.huang@intel.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®