From: David Hildenbrand <david@redhat.com>
To: Mike Kravetz <mike.kravetz@oracle.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Naoya Horiguchi <naoya.horiguchi@linux.dev>,
James Houghton <jthoughton@google.com>,
Peter Xu <peterx@redhat.com>, Michal Hocko <mhocko@suse.com>,
Yang Shi <shy828301@gmail.com>,
Vishal Moola <vishal.moola@gmail.com>,
Matthew Wilcox <willy@infradead.org>,
Muchun Song <songmuchun@bytedance.com>,
Andrew Morton <akpm@linux-foundation.org>,
stable@vger.kernel.org
Subject: Re: [PATCH 2/2] migrate: hugetlb: Check for hugetlb shared PMD in node migration
Date: Fri, 27 Jan 2023 17:23:59 +0100 [thread overview]
Message-ID: <f9f13d4d-5882-2647-0032-e4f0e9296c69@redhat.com> (raw)
In-Reply-To: <20230126222721.222195-3-mike.kravetz@oracle.com>
On 26.01.23 23:27, Mike Kravetz wrote:
> migrate_pages/mempolicy semantics state that CAP_SYS_NICE is required
> to move pages shared with another process to a different node.
> page_mapcount > 1 is being used to determine if a hugetlb page is shared.
> However, a hugetlb page will have a mapcount of 1 if mapped by multiple
> processes via a shared PMD. As a result, hugetlb pages shared by multiple
> processes and mapped with a shared PMD can be moved by a process without
> CAP_SYS_NICE.
>
> To fix, check for a shared PMD if mapcount is 1. If a shared PMD is
> found consider the page shared.
>
> Fixes: e2d8cf405525 ("migrate: add hugepage migration code to migrate_pages()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
> ---
> mm/mempolicy.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 85a34f1f3ab8..72142fbe7652 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -600,7 +600,8 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
>
> /* With MPOL_MF_MOVE, we migrate only unshared hugepage. */
> if (flags & (MPOL_MF_MOVE_ALL) ||
> - (flags & MPOL_MF_MOVE && page_mapcount(page) == 1)) {
> + (flags & MPOL_MF_MOVE && page_mapcount(page) == 1 &&
> + !hugetlb_pmd_shared(pte))) {
> if (isolate_hugetlb(page, qp->pagelist) &&
> (flags & MPOL_MF_STRICT))
> /*
Acked-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2023-01-27 16:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 22:27 [PATCH 0/2] Fixes for hugetlb mapcount at most 1 for shared PMDs Mike Kravetz
2023-01-26 22:27 ` [PATCH 1/2] mm: hugetlb: proc: check for hugetlb shared PMD in /proc/PID/smaps Mike Kravetz
2023-01-27 16:23 ` David Hildenbrand
2023-01-27 23:04 ` Andrew Morton
2023-01-28 1:12 ` Mike Kravetz
2023-01-30 12:36 ` Michal Hocko
2023-01-30 22:08 ` Mike Kravetz
2023-02-01 7:47 ` Michal Hocko
2023-02-01 21:05 ` Mike Kravetz
2023-02-03 13:40 ` Michal Hocko
2023-02-03 20:16 ` Mike Kravetz
2023-02-13 18:01 ` Michal Hocko
2023-02-14 1:40 ` Mike Kravetz
2023-01-26 22:27 ` [PATCH 2/2] migrate: hugetlb: Check for hugetlb shared PMD in node migration Mike Kravetz
2023-01-27 16:23 ` David Hildenbrand [this message]
2023-01-26 22:47 ` [PATCH 0/2] Fixes for hugetlb mapcount at most 1 for shared PMDs Andrew Morton
2023-01-26 22:48 ` Peter Xu
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=f9f13d4d-5882-2647-0032-e4f0e9296c69@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=jthoughton@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=mike.kravetz@oracle.com \
--cc=naoya.horiguchi@linux.dev \
--cc=peterx@redhat.com \
--cc=shy828301@gmail.com \
--cc=songmuchun@bytedance.com \
--cc=stable@vger.kernel.org \
--cc=vishal.moola@gmail.com \
--cc=willy@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).