linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Rare memory leakage
@ 2020-09-22  3:12 Matthew Wilcox
  2020-09-22  3:43 ` Ira Weiny
  2020-09-22 11:22 ` Vlastimil Babka
  0 siblings, 2 replies; 8+ messages in thread
From: Matthew Wilcox @ 2020-09-22  3:12 UTC (permalink / raw)
  To: linux-mm

This is a fun little race.

Dramatis personae: Pages P0, P1 are consecutive and aligned.
Threads A, B, C.

Page P0 is allocated to the page cache.
Page P1 is free.

Thread A calls find_get_entry()
P0 is returned from xas_load()

Thread B removes the page from the page cache (eg truncate, invalidatepage).
P0 is buddy-merged with P1.

Thread C calls alloc_pages, order 1, does not specify GFP_COMP.  P0 now
has refcount 1.

Thread A calls page_cache_get_speculative().  P0 has refcount 2.

Thread C calls __free_page(P0, 1)
put_page_testzero is _false_.  Do not call free_the_page().

Thread A calls put_page(P0)
We free P0 and nobody knows to free P1.


Weird solution: In __free_page(), if put_page_testzero() fails and page
is not PageHead, convert it to a compound page.  Then the put_page()
by Thread A will free P1.

Better ideas?


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

end of thread, other threads:[~2020-09-23 11:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-22  3:12 Rare memory leakage Matthew Wilcox
2020-09-22  3:43 ` Ira Weiny
2020-09-22 11:04   ` Matthew Wilcox
2020-09-22 11:22 ` Vlastimil Babka
2020-09-22 11:44   ` Matthew Wilcox
2020-09-22 13:12     ` Matthew Wilcox
2020-09-23  6:46       ` Kirill A. Shutemov
2020-09-23 11:26         ` Matthew Wilcox

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