From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Suren Baghdasaryan <surenb@google.com>, Hao Ge <hao.ge@linux.dev>,
Vlastimil Babka <vbabka@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <brendan.jackman@linux.dev>,
Zi Yan <ziy@nvidia.com>,
Andrew Morton <akpm@linux-foundation.org>,
Usama Arif <usamaarif642@gmail.com>,
Shakeel Butt <shakeel.butt@linux.dev>,
Harry Yoo <harry@kernel.org>, Hao Li <hao.li@linux.dev>,
Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>
Cc: linux-mm@kvack.org, "David Hildenbrand (Arm)" <david@kernel.org>,
Chris Mason <mason@kernel.org>
Subject: [PATCH 2/3] mempool: fix missing alloc tagging in mempool_resize()
Date: Thu, 19 Nov 2026 09:52:21 +0100 [thread overview]
Message-ID: <20261119-alloc_tag-v1-2-efcccfd3a9c9@kernel.org> (raw)
In-Reply-To: <20261119-alloc_tag-v1-0-efcccfd3a9c9@kernel.org>
From: Chris Mason <mason@kernel.org>
With memory allocation profiling enabled, mempool_resize() allocates new
elements without an allocation tag: mempool_alloc_slab() and friends
use the _noprof allocators and rely on the caller to have set
current->alloc_tag.
Unlike mempool_init() or mempool_alloc(), mempool_resize() is not an
alloc_hooks() wrapper, though.
Therefore, the newly allocated elements are missing from /proc/allocinfo,
and with CONFIG_MEM_ALLOC_PROFILING_DEBUG=y we can trigger
"current->alloc_tag not set" and "alloc_tag was not set" warnings.
Fix it by turning mempool_resize() into an alloc_hooks() wrapper, just
like the other mempool functions that allocate elements.
This has low urgency.
Fixes: e26d8769da6d ("mempool: hook up to memory allocation profiling")
Signed-off-by: Chris Mason <mason@kernel.org>
[ david: adjust description, remove kmalloc_objs() change ]
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
include/linux/mempool.h | 4 +++-
mm/mempool.c | 4 ++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/include/linux/mempool.h b/include/linux/mempool.h
index 6da502aef2f71..5444dcb63efa8 100644
--- a/include/linux/mempool.h
+++ b/include/linux/mempool.h
@@ -59,7 +59,9 @@ struct mempool *mempool_create_node_noprof(int min_nr,
mempool_create_node(_min_nr, _alloc_fn, _free_fn, _pool_data, \
GFP_KERNEL, NUMA_NO_NODE)
-int mempool_resize(struct mempool *pool, int new_min_nr);
+int mempool_resize_noprof(struct mempool *pool, int new_min_nr);
+#define mempool_resize(...) \
+ alloc_hooks(mempool_resize_noprof(__VA_ARGS__))
void mempool_destroy(struct mempool *pool);
void *mempool_alloc_noprof(struct mempool *pool, gfp_t gfp_mask) __malloc;
diff --git a/mm/mempool.c b/mm/mempool.c
index cb74e718b2c65..5e0ba516efdbf 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -361,7 +361,7 @@ EXPORT_SYMBOL(mempool_create_node_noprof);
*
* Return: %0 on success, negative error code otherwise.
*/
-int mempool_resize(struct mempool *pool, int new_min_nr)
+int mempool_resize_noprof(struct mempool *pool, int new_min_nr)
{
void *element;
void **new_elements;
@@ -420,7 +420,7 @@ int mempool_resize(struct mempool *pool, int new_min_nr)
out:
return 0;
}
-EXPORT_SYMBOL(mempool_resize);
+EXPORT_SYMBOL(mempool_resize_noprof);
static unsigned int mempool_alloc_from_pool(struct mempool *pool, void **elems,
unsigned int count, unsigned int allocated,
--
2.56.1
next prev parent reply other threads:[~2026-11-19 8:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 8:52 [PATCH 0/3] alloc_tag: two fixes and one cleanup David Hildenbrand (Arm)
2026-11-19 8:52 ` [PATCH 1/3] alloc_tag: handle a NULL tag in alloc_tag_set_inaccurate() David Hildenbrand (Arm)
2026-11-19 8:52 ` David Hildenbrand (Arm) [this message]
2026-11-19 8:52 ` [PATCH 3/3] mempool: account the element array to the caller David Hildenbrand (Arm)
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=20261119-alloc_tag-v1-2-efcccfd3a9c9@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brendan.jackman@linux.dev \
--cc=cl@gentwo.org \
--cc=hannes@cmpxchg.org \
--cc=hao.ge@linux.dev \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=linux-mm@kvack.org \
--cc=mason@kernel.org \
--cc=mhocko@suse.com \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=usamaarif642@gmail.com \
--cc=vbabka@kernel.org \
--cc=ziy@nvidia.com \
/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