From: Alistair Popple <apopple@nvidia.com>
To: Gavin Shan <gshan@redhat.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, william.kucharski@oracle.com,
ziy@nvidia.com, kirill.shutemov@linux.intel.com,
david@redhat.com, zhenyzha@redhat.com, shan.gavin@gmail.com
Subject: Re: [PATCH] mm: migrate: Fix THP's mapcount on isolation
Date: Wed, 23 Nov 2022 15:26:25 +1100 [thread overview]
Message-ID: <87sfias2hd.fsf@nvidia.com> (raw)
In-Reply-To: <20221123005752.161003-1-gshan@redhat.com>
Gavin Shan <gshan@redhat.com> writes:
> The issue is reported when removing memory through virtio_mem device.
> The transparent huge page, experienced copy-on-write fault, is wrongly
> regarded as pinned. The transparent huge page is escaped from being
> isolated in isolate_migratepages_block(). The transparent huge page
> can't be migrated and the corresponding memory block can't be put
> into offline state.
>
> Fix it by replacing page_mapcount() with total_mapcount(). With this,
> the transparent huge page can be isolated and migrated, and the memory
> block can be put into offline state.
>
> Fixes: 3917c80280c9 ("thp: change CoW semantics for anon-THP")
> Cc: stable@vger.kernel.org # v5.8+
> Reported-by: Zhenyu Zhang <zhenyzha@redhat.com>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Gavin Shan <gshan@redhat.com>
> ---
> mm/compaction.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index c51f7f545afe..c408b5e04c1d 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -990,7 +990,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
> * admittedly racy check.
> */
> mapping = page_mapping(page);
> - if (!mapping && page_count(page) > page_mapcount(page))
> + if (!mapping && page_count(page) > total_mapcount(page))
We have several versions of these checks for pinned pages open-coded
around the place. See for example migrate_vma_check_page() and
folio_expected_refs(). It looks like you could use a variant of
migrate_vma_check_page() which would also check non-anon pins, although
I don't know the compaction code well enough to know if that's useful.
Either way it would be nice if we had a common helper for these kind of
checks. Guess that would be harder to backport, and the change itself
looks ok. But why isn't the fixes tag 119d6d59dcc0 ("mm, compaction:
avoid isolating pinned pages")?
> goto isolate_fail;
>
> /*
next prev parent reply other threads:[~2022-11-23 4:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-23 0:57 Gavin Shan
2022-11-23 4:26 ` Alistair Popple [this message]
2022-11-23 5:06 ` Gavin Shan
2022-11-23 5:14 ` Hugh Dickins
2022-11-23 8:56 ` David Hildenbrand
2022-11-23 16:07 ` Matthew Wilcox
2022-11-24 8:50 ` David Hildenbrand
2022-11-24 0:14 ` Gavin Shan
2022-11-24 8:46 ` David Hildenbrand
2022-11-24 9:44 ` Gavin Shan
2022-11-24 1:06 ` Alistair Popple
2022-11-24 3:33 ` Matthew Wilcox
2022-11-24 8:49 ` David Hildenbrand
2022-11-25 0:58 ` Alistair Popple
2022-11-25 8:54 ` David Hildenbrand
2022-12-01 22:35 ` Alistair Popple
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=87sfias2hd.fsf@nvidia.com \
--to=apopple@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=gshan@redhat.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shan.gavin@gmail.com \
--cc=william.kucharski@oracle.com \
--cc=zhenyzha@redhat.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