From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-mm@kvack.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Oscar Salvador <osalvador@suse.de>
Subject: [PATCH 0/5] Remove some races around folio_test_hugetlb
Date: Fri, 1 Mar 2024 21:47:05 +0000 [thread overview]
Message-ID: <20240301214712.2853147-1-willy@infradead.org> (raw)
Oscar and I have been exchanging a bit of email recently about the
bug reported here:
https://lore.kernel.org/all/ZXNhGsX32y19a2Xv@casper.infradead.org
I've come to the conclusion that folio_test_hugetlb() is just too fragile
as it can give both false positives and false negatives, as well as
resulting in the above bug. With this patch series, it becomes a lot
more robust. In the memory-failure case, we always hold the hugetlb_lock
so it's perfectly reliable. In the compaction caase, it's unreliable, but
the failures are acceptable and we recheck after taking the hugetlb_lock.
The cost of this reliability is that we now consume the word I recently
freed in folio->page[1]. I think this is acceptable; we've still gained
a completely reliable folio_test_hugetlb() (which we didn't have before
I started messing around with the folio dtors). Non-hugetlb users
can use large_id as a pointer to something else entirely, or even as a
non-pointer, as long as they can guarantee it can't conflict (ie don't
use it as a bitfield).
So far, this is working for me. Some stress testing would be appreciated.
Matthew Wilcox (Oracle) (5):
hugetlb: Make folio_test_hugetlb safer to call
hugetlb: Add hugetlb_pfn_folio
memory-failure: Use hugetlb_pfn_folio
memory-failure: Reorganise get_huge_page_for_hwpoison()
compaction: Use hugetlb_pfn_folio in isolate_migratepages_block
include/linux/hugetlb.h | 13 ++-----
include/linux/mm.h | 8 -----
include/linux/mm_types.h | 4 ++-
include/linux/page-flags.h | 25 +++----------
kernel/vmcore_info.c | 3 +-
mm/compaction.c | 16 ++++-----
mm/huge_memory.c | 10 ++----
mm/hugetlb.c | 72 +++++++++++++++++++++++++++++---------
mm/memory-failure.c | 14 +++++---
9 files changed, 87 insertions(+), 78 deletions(-)
--
2.43.0
next reply other threads:[~2024-03-01 21:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 21:47 Matthew Wilcox (Oracle) [this message]
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
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=20240301214712.2853147-1-willy@infradead.org \
--to=willy@infradead.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
/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).