From: David Hildenbrand <david@redhat.com>
To: Minchan Kim <minchan@kernel.org>, Mike Kravetz <mike.kravetz@oracle.com>
Cc: John Hubbard <jhubbard@nvidia.com>,
Andrew Morton <akpm@linux-foundation.org>,
syzbot <syzbot+acf65ca584991f3cc447@syzkaller.appspotmail.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
llvm@lists.linux.dev, nathan@kernel.org, ndesaulniers@google.com,
syzkaller-bugs@googlegroups.com, trix@redhat.com,
Matthew Wilcox <willy@infradead.org>,
Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [syzbot] WARNING in follow_hugetlb_page
Date: Sat, 21 May 2022 17:51:58 +0200 [thread overview]
Message-ID: <b025ddd5-aca2-f3e2-6a4f-24a1b4eda985@redhat.com> (raw)
In-Reply-To: <YokEEAemXTwTSZh5@google.com>
On 21.05.22 17:24, Minchan Kim wrote:
> On Fri, May 20, 2022 at 05:04:22PM -0700, Mike Kravetz wrote:
>> On 5/20/22 16:43, Minchan Kim wrote:
>>> On Fri, May 20, 2022 at 04:31:31PM -0700, Mike Kravetz wrote:
>>>> On 5/20/22 15:56, John Hubbard wrote:
>>>>> On 5/20/22 15:19, Minchan Kim wrote:
>>>>>> The memory offline would be an issue so we shouldn't allow pinning of any
>>>>>> pages in *movable zone*.
>>>>>>
>>>>>> Isn't alloc_contig_range just best effort? Then, it wouldn't be a big
>>>>>> problem to allow pinning on those area. The matter is what target range
>>>>>> on alloc_contig_range is backed by CMA or movable zone and usecases.
>>>>>>
>>>>>> IOW, movable zone should be never allowed. But CMA case, if pages
>>>>>> are used by normal process memory instead of hugeTLB, we shouldn't
>>>>>> allow longterm pinning since someone can claim those memory suddenly.
>>>>>> However, we are fine to allow longterm pinning if the CMA memory
>>>>>> already claimed and mapped at userspace(hugeTLB case IIUC).
>>>>>>
>>>>>
>>>>> From Mike's comments and yours, plus a rather quick reading of some
>>>>> CMA-related code in mm/hugetlb.c (free_gigantic_page(), alloc_gigantic_pages()), the following seems true:
>>>>>
>>>>> a) hugetlbfs can allocate pages *from* CMA, via cma_alloc()
>>>>>
>>>>> b) while hugetlbfs is using those CMA-allocated pages, it is debatable
>>>>> whether those pages should be allowed to be long term pinned. That's
>>>>> because there are two cases:
>>>>>
>>>>> Case 1: pages are longterm pinned, then released, all while
>>>>> owned by hugetlbfs. No problem.
>>>>>
>>>>> Case 2: pages are longterm pinned, but then hugetlbfs releases the
>>>>> pages entirely (via unmounting hugetlbfs, I presume). In
>>>>> this case, we now have CMA page that are long-term pinned,
>>>>> and that's the state we want to avoid.
>>>>
>>>> I do not think case 2 can happen. A hugetlb page can only be changed back
>>>> to 'normal' (buddy) pages when ref count goes to zero.
>>>>
>>>> It should also be noted that hugetlb code sets up the CMA area from which
>>>> hugetlb pages can be allocated. This area is never unreserved/freed.
>>>>
>>>> I do not think there is a reason to disallow long term pinning of hugetlb
>>>> pages allocated from THE hugetlb CMA area.
Hm. We primarily use CMA for gigantic pages only IIRC. Ordinary huge
pages come via the buddy.
Assume we allocated a (movable) 2MiB huge page ordinarily via the buddy
and it ended up on that CMA area by pure luck (as it's movable). If we'd
allow to pin it long-term, allocating a gigantic page from the
designated CMA area would fail.
So we'd want to allow long-term pinning a gigantic page but we'd not
want to allow long-term pinning an ordinary huge page. We'd want to
migrate the latter away.
The general rules are:
ZONE_MOVABLE: nobody is allowed to place unmovable allocations there; it
could prevent memory offlining/unplug.
CMA: nobody *but the designated owner* is allowed to place unmovable
memory there; it could prevent the actual owner to allocate contiguous
memory.
As explained above, it gets a bit weird if the owner (hugetlb) deals
with different allocation types (huge vs. gigantic pages).
>> Unless I do not understand, normal movable memory allocations can fall
>> back to CMA areas?
Yes, just like ZONE_MOVABLE IIRC.
>
> In the case, Yes, it would be fallback if gfp_flag was __GFP_MOVABLE.
>
> If HugeTLB support it(I think so), pin_user_pages with FOLL_LONGTERM
> will migrate the page out of movable/CMA before the longterm pinning
> so IMHO, we shouldn't have the problem.
As explained, the tricky bit would be hitting a gigantic page that's
valid to reside permanently on the designated CMA area. IIRC, some
gigantic pages are indeed movable, but we never place them on
ZONE_MOVABLE because migration is unlikely to work in practice.
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2022-05-21 15:52 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 9:03 syzbot
2022-05-13 16:43 ` syzbot
2022-05-13 17:26 ` Andrew Morton
2022-05-13 18:09 ` Mike Kravetz
2022-05-13 22:48 ` Mike Kravetz
2022-05-13 23:19 ` Andrew Morton
2022-05-13 23:54 ` Minchan Kim
2022-05-14 0:09 ` John Hubbard
2022-05-14 0:26 ` Minchan Kim
2022-05-14 0:56 ` John Hubbard
2022-05-14 1:16 ` John Hubbard
2022-05-17 3:37 ` Mike Kravetz
2022-05-18 7:12 ` John Hubbard
2022-05-20 22:19 ` Minchan Kim
2022-05-20 22:56 ` John Hubbard
2022-05-20 23:25 ` Minchan Kim
2022-05-20 23:31 ` Mike Kravetz
2022-05-20 23:43 ` Minchan Kim
2022-05-21 0:04 ` Mike Kravetz
2022-05-21 15:24 ` Minchan Kim
2022-05-21 15:51 ` David Hildenbrand [this message]
2022-05-21 16:36 ` Minchan Kim
2022-05-21 16:46 ` David Hildenbrand
2022-05-21 18:25 ` Minchan Kim
2022-05-21 23:50 ` Mike Kravetz
2022-05-14 0:18 ` Andrew Morton
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=b025ddd5-aca2-f3e2-6a4f-24a1b4eda985@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=llvm@lists.linux.dev \
--cc=mike.kravetz@oracle.com \
--cc=minchan@kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=sfr@canb.auug.org.au \
--cc=syzbot+acf65ca584991f3cc447@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=trix@redhat.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
all inboxes | Powered by JetHome®