Skip to content

Commit 9415983

Browse files
surenbaghdasaryanakpm00
authored andcommitted
mm: fix xyz_noprof functions calling profiled functions
Grepping /proc/allocinfo for "noprof" reveals several xyz_noprof functions, which means internally they are calling profiled functions. This should never happen as such calls move allocation charge from a higher level location where it should be accounted for into these lower level helpers. Fix this by replacing profiled function calls with noprof ones. Link: https://lkml.kernel.org/r/20240531205350.3973009-1-surenb@google.com Fixes: b951aaf ("mm: enable page allocation tagging") Fixes: e26d876 ("mempool: hook up to memory allocation profiling") Fixes: 88ae5fb ("mm: vmalloc: enable memory allocation profiling") Signed-off-by: Suren Baghdasaryan <surenb@google.com> Cc: Kent Overstreet <kent.overstreet@linux.dev> Reviewed-by: Kees Cook <kees@kernel.org> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Pasha Tatashin <pasha.tatashin@soleen.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 3f0c44c commit 9415983

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

mm/filemap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ struct folio *filemap_alloc_folio_noprof(gfp_t gfp, unsigned int order)
10001000
do {
10011001
cpuset_mems_cookie = read_mems_allowed_begin();
10021002
n = cpuset_mem_spread_node();
1003-
folio = __folio_alloc_node(gfp, order, n);
1003+
folio = __folio_alloc_node_noprof(gfp, order, n);
10041004
} while (!folio && read_mems_allowed_retry(cpuset_mems_cookie));
10051005

10061006
return folio;

mm/mempool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ mempool_t *mempool_create_node_noprof(int min_nr, mempool_alloc_t *alloc_fn,
273273
{
274274
mempool_t *pool;
275275

276-
pool = kzalloc_node(sizeof(*pool), gfp_mask, node_id);
276+
pool = kmalloc_node_noprof(sizeof(*pool), gfp_mask | __GFP_ZERO, node_id);
277277
if (!pool)
278278
return NULL;
279279

mm/util.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ void *kvrealloc_noprof(const void *p, size_t oldsize, size_t newsize, gfp_t flag
705705

706706
if (oldsize >= newsize)
707707
return (void *)p;
708-
newp = kvmalloc(newsize, flags);
708+
newp = kvmalloc_noprof(newsize, flags);
709709
if (!newp)
710710
return NULL;
711711
memcpy(newp, p, oldsize);
@@ -726,7 +726,7 @@ void *__vmalloc_array_noprof(size_t n, size_t size, gfp_t flags)
726726

727727
if (unlikely(check_mul_overflow(n, size, &bytes)))
728728
return NULL;
729-
return __vmalloc(bytes, flags);
729+
return __vmalloc_noprof(bytes, flags);
730730
}
731731
EXPORT_SYMBOL(__vmalloc_array_noprof);
732732

@@ -737,7 +737,7 @@ EXPORT_SYMBOL(__vmalloc_array_noprof);
737737
*/
738738
void *vmalloc_array_noprof(size_t n, size_t size)
739739
{
740-
return __vmalloc_array(n, size, GFP_KERNEL);
740+
return __vmalloc_array_noprof(n, size, GFP_KERNEL);
741741
}
742742
EXPORT_SYMBOL(vmalloc_array_noprof);
743743

@@ -749,7 +749,7 @@ EXPORT_SYMBOL(vmalloc_array_noprof);
749749
*/
750750
void *__vcalloc_noprof(size_t n, size_t size, gfp_t flags)
751751
{
752-
return __vmalloc_array(n, size, flags | __GFP_ZERO);
752+
return __vmalloc_array_noprof(n, size, flags | __GFP_ZERO);
753753
}
754754
EXPORT_SYMBOL(__vcalloc_noprof);
755755

@@ -760,7 +760,7 @@ EXPORT_SYMBOL(__vcalloc_noprof);
760760
*/
761761
void *vcalloc_noprof(size_t n, size_t size)
762762
{
763-
return __vmalloc_array(n, size, GFP_KERNEL | __GFP_ZERO);
763+
return __vmalloc_array_noprof(n, size, GFP_KERNEL | __GFP_ZERO);
764764
}
765765
EXPORT_SYMBOL(vcalloc_noprof);
766766

0 commit comments

Comments
 (0)