linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] hugetlb: fix potential ref counting races
@ 2021-07-10  0:24 Mike Kravetz
  2021-07-10  0:24 ` [PATCH 1/3] hugetlb: simplify prep_compound_gigantic_page ref count racing code Mike Kravetz
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Mike Kravetz @ 2021-07-10  0:24 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Muchun Song, Michal Hocko, Oscar Salvador, David Hildenbrand,
	Matthew Wilcox, Naoya Horiguchi, Mina Almasry, Andrew Morton,
	Mike Kravetz

When Muchun Song brought up a potential issue with hugetlb ref counting[1],
I started looking closer at the code.  hugetlbfs is the only code with it's
own specialized compound page destructor and taking special action when ref
counts drop to zero.  Potential races happen in this unique handling of ref
counts.  The following patches address these races when creating and
destroying hugetlb pages.

These potential races have likely existed since the creation of
hugetlbfs.  They certainly have been around for more than 10 years.
However, I am unaware of anyone actually hitting these races.  It is
VERY unlikely than anyone will actually hit these races, but they do
exist.

I could not think of an easy (or difficult) way to force these races.
Therefore, testing consisted of adding code to randomly increase ref
counts in strategic places.  In this way, I was able to exercise all the
race handling code paths.

[1] https://lore.kernel.org/linux-mm/CAMZfGtVMn3daKrJwZMaVOGOaJU+B4dS--x_oPmGQMD=c=QNGEg@mail.gmail.com/

Mike Kravetz (3):
  hugetlb: simplify prep_compound_gigantic_page ref count racing code
  hugetlb: drop ref count earlier after page allocation
  hugetlb: before freeing hugetlb page set dtor to appropriate value

 mm/hugetlb.c | 137 ++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 104 insertions(+), 33 deletions(-)

-- 
2.31.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-07-28  4:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-10  0:24 [PATCH 0/3] hugetlb: fix potential ref counting races Mike Kravetz
2021-07-10  0:24 ` [PATCH 1/3] hugetlb: simplify prep_compound_gigantic_page ref count racing code Mike Kravetz
2021-07-13  6:31   ` [External] " Muchun Song
2021-07-10  0:24 ` [PATCH 2/3] hugetlb: drop ref count earlier after page allocation Mike Kravetz
2021-07-10  0:24 ` [PATCH 3/3] hugetlb: before freeing hugetlb page set dtor to appropriate value Mike Kravetz
2021-07-14 10:57   ` [External] " Muchun Song
2021-07-14 17:39     ` Mike Kravetz
2021-07-15  3:14       ` Muchun Song
2021-07-27 23:41 ` [PATCH 0/3] hugetlb: fix potential ref counting races Mike Kravetz
2021-07-28  4:03   ` Muchun Song

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).