]> www.infradead.org Git - users/willy/pagecache.git/commit
mm: decline to manipulate the refcount on a slab page
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 10 Mar 2025 14:35:24 +0000 (14:35 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 14 Mar 2025 22:52:38 +0000 (15:52 -0700)
commit1e8e28d9bbd3c8c7ab5212ec2ba4fef805d50904
treeea770626a3967a820415d448ae690b760d8e3a07
parent8185bee8afe2c13dc5ae548ade355a5062606bfc
mm: decline to manipulate the refcount on a slab page

Slab pages now have a refcount of 0, so nobody should be trying to
manipulate the refcount on them.  Doing so has little effect; the object
could be freed and reallocated to a different purpose, although the slab
itself would not be until the refcount was put making it behave rather
like TYPESAFE_BY_RCU.

Unfortunately, __iov_iter_get_pages_alloc() does take a refcount.  Fix
that to not change the refcount, and make put_page() silently not change
the refcount.  get_page() warns so that we can fix any other callers that
need to be changed.

Long-term, networking needs to stop taking a refcount on the pages that it
uses and rely on the caller to hold whatever references are necessary to
make the memory stable.  In the medium term, more page types are going to
hav a zero refcount, so we'll want to move get_page() and put_page() out
of line.

Link: https://lkml.kernel.org/r/20250310143544.1216127-1-willy@infradead.org
Fixes: 9aec2fb0fd5e (slab: allocate frozen pages)
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reported-by: Hannes Reinecke <hare@suse.de>
Closes: https://lore.kernel.org/all/08c29e4b-2f71-4b6d-8046-27e407214d8c@suse.com/
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mm.h
lib/iov_iter.c