linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] mm, slab: warn when increasing refcount on large kmalloc page
@ 2025-04-17  7:41 Vlastimil Babka
  2025-04-18 14:04 ` Harry Yoo
  2025-04-23 18:20 ` Matthew Wilcox
  0 siblings, 2 replies; 5+ messages in thread
From: Vlastimil Babka @ 2025-04-17  7:41 UTC (permalink / raw)
  To: Matthew Wilcox, linux-mm
  Cc: Harry Yoo, David Rientjes, Christoph Lameter, Andrew Morton,
	Vlastimil Babka

Since slab pages are now frozen, increasing refcount on a page
containing a kmalloc() allocation is not possible anymore. Large kmalloc
pages should ideally behave the same, because the decision for which
allocation size to use them is the slab allocator's implementation
detail, and sizes passed to kmalloc() might depend on e.g. user input.

Because of some unexpected fallout in the slab pages case (see commit
b9c0e49abfca ("mm: decline to manipulate the refcount on a slab page"),
let's take a more cautious approach and before making large kmalloc
pages actually frozen, start warning about code that would try to
increase refcount on them.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
I'd like to expose this via slab-next and see if there are any reports.
If not for few weeks, maybe proceed immediately to freezing refcount and
handling it in get_page/put_page exactly like folio_test_slab. Thoughts?

 include/linux/mm.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index b7f13f087954..664c67346484 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1532,6 +1532,7 @@ static inline void get_page(struct page *page)
 	struct folio *folio = page_folio(page);
 	if (WARN_ON_ONCE(folio_test_slab(folio)))
 		return;
+	WARN_ON_ONCE(folio_test_large_kmalloc(folio));
 	folio_get(folio);
 }
 
-- 
2.49.0



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

end of thread, other threads:[~2025-04-23 18:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-17  7:41 [PATCH RFC] mm, slab: warn when increasing refcount on large kmalloc page Vlastimil Babka
2025-04-18 14:04 ` Harry Yoo
2025-04-20  2:41   ` David Rientjes
2025-04-20  2:46     ` David Rientjes
2025-04-23 18:20 ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox