From: David Hildenbrand <david@redhat.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>, linux-mm@kvack.org
Cc: Oscar Salvador <osalvador@suse.de>
Subject: Re: [PATCH 1/5] hugetlb: Make folio_test_hugetlb safer to call
Date: Tue, 5 Mar 2024 09:39:19 +0100 [thread overview]
Message-ID: <24a7f4e5-9d30-494e-b19d-2e010a4c4b7e@redhat.com> (raw)
In-Reply-To: <20240301214712.2853147-2-willy@infradead.org>
On 01.03.24 22:47, Matthew Wilcox (Oracle) wrote:
> At least two places (memory failure and page migration) need to call
> folio_test_hugetlb() without a reference on the folio. This can currently
> result in false positives (returning true when the folio doesn't belong
> to hugetlb) and more commonly in VM_BUG_ON() when a folio is split.
>
> The new way to distinguish a hugetlb folio is to see if (1) the page
> is compound (or the folio is large) and (2) page[1].mapping is set to
> the address of hugetlb_lock. If the folio is (or has been) large then
> page[1] is guaranteed to exist. If the folio is split between the two
> tests, page[1].mapping will be set to something which definitely isn't
> the address of hugetlb_lock.
>
> Because we shift around the layout of struct folio a bit, we now use
> page[1].private, which means we need to adjust __split_huge_page_tail()
> a little. We also need to annoy the vmcore_info people again. Sorry.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/mm_types.h | 4 +++-
> include/linux/page-flags.h | 25 ++++---------------------
> kernel/vmcore_info.c | 3 ++-
> mm/huge_memory.c | 10 ++--------
> mm/hugetlb.c | 24 ++++++++++++++++++++++++
> 5 files changed, 35 insertions(+), 31 deletions(-)
>
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index a7223ba3ea1e..fd80bf8b5d8a 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -289,6 +289,7 @@ typedef struct {
> * @virtual: Virtual address in the kernel direct map.
> * @_last_cpupid: IDs of last CPU and last process that accessed the folio.
> * @_entire_mapcount: Do not use directly, call folio_entire_mapcount().
> + * @large_id: May identify the type of a large folio.
> * @_nr_pages_mapped: Do not use directly, call folio_mapcount().
> * @_pincount: Do not use directly, call folio_maybe_dma_pinned().
> * @_folio_nr_pages: Do not use directly, call folio_nr_pages().
> @@ -348,9 +349,9 @@ struct folio {
> struct {
> unsigned long _flags_1;
> unsigned long _head_1;
> - unsigned long _folio_avail;
> /* public: */
> atomic_t _entire_mapcount;
> + void *large_id;
> atomic_t _nr_pages_mapped;
> atomic_t _pincount;
Hm, I wanted that for the total mapcount. :(
Great that hugetlb makes things once again worse for everybody ... gah.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-03-05 8:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 21:47 [PATCH 0/5] Remove some races around folio_test_hugetlb Matthew Wilcox (Oracle)
2024-03-01 21:47 ` [PATCH 1/5] hugetlb: Make folio_test_hugetlb safer to call Matthew Wilcox (Oracle)
2024-03-05 6:43 ` Oscar Salvador
2024-03-05 8:39 ` David Hildenbrand [this message]
2024-03-01 21:47 ` [PATCH 2/5] hugetlb: Add hugetlb_pfn_folio Matthew Wilcox (Oracle)
2024-03-05 6:58 ` Oscar Salvador
2024-03-01 21:47 ` [PATCH 3/5] memory-failure: Use hugetlb_pfn_folio Matthew Wilcox (Oracle)
2024-03-01 21:47 ` [PATCH 4/5] memory-failure: Reorganise get_huge_page_for_hwpoison() Matthew Wilcox (Oracle)
2024-03-01 21:47 ` [PATCH 5/5] compaction: Use hugetlb_pfn_folio in isolate_migratepages_block Matthew Wilcox (Oracle)
2024-03-04 9:09 ` [PATCH 0/5] Remove some races around folio_test_hugetlb Miaohe Lin
2024-03-04 17:08 ` Matthew Wilcox
2024-03-06 7:58 ` Miaohe Lin
2024-03-07 21:16 ` Matthew Wilcox
2024-03-05 9:10 ` David Hildenbrand
2024-03-05 20:35 ` Matthew Wilcox
2024-03-06 15:18 ` David Hildenbrand
2024-03-07 4:31 ` Matthew Wilcox
2024-03-07 9:20 ` David Hildenbrand
2024-03-07 21:14 ` Matthew Wilcox
2024-03-07 21:38 ` David Hildenbrand
2024-03-08 4:31 ` Matthew Wilcox
2024-03-08 8:46 ` David Hildenbrand
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=24a7f4e5-9d30-494e-b19d-2e010a4c4b7e@redhat.com \
--to=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--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).