linux/fs/netfs
Hao Ge b78b728e21
netfs: Fix missing alloc tagging of direct mempool allocations
Commit 1d78d56c43 ("netfs: Fix folio_queue ENOMEM in writeback by
adding a mempool") added a mempool for the folio_queues and made the
request, subrequest and folio_queue allocations distinguish between
writeback and everything else.  Writeback is part of memory reclaim
and must not fail due to ENOMEM, so it allocates under GFP_NOFS
through mempool_alloc(), which may dip into the pool's reserve and,
if that runs empty, wait for elements to be returned.  The
GFP_KERNEL paths, which can return -ENOMEM to their callers, invoke
the pool's ->alloc() callback directly instead.

The direct call, however, skips the alloc_hooks() wrapper that the
mempool_alloc() macro provides.  The pool callbacks, mempool_alloc_slab()
and mempool_kmalloc(), call kmem_cache_alloc_noprof() and kmalloc_noprof()
and rely on current->alloc_tag having been set by the caller.  With
CONFIG_MEM_ALLOC_PROFILING_DEBUG=y this leads to

    current->alloc_tag not set
    WARNING: ./include/linux/alloc_tag.h:161 at __alloc_tagging_slab_alloc_hook
    alloc_tag was not set
    WARNING: ./include/linux/alloc_tag.h:166 at __alloc_tagging_slab_free_hook

at allocation and free time respectively, as reported when reading
files on a CIFS mount.  The allocations are also missing from
/proc/allocinfo.

Wrap the direct ->alloc() invocations in alloc_hooks() with a new
mempool_alloc_noreserve() helper in include/linux/mempool.h, next to
the other alloc_hooks()-wrapped macros such as mempool_alloc().  The
GFP_KERNEL paths keep their failable allocation semantics, they just
get tagged now.

Fixes: 1d78d56c43 ("netfs: Fix folio_queue ENOMEM in writeback by adding a mempool")
Reported-by: Erhard Furtner <erhard_f@mailbox.org>
Closes: https://lore.kernel.org/all/0b004319-9ef7-437c-a4dd-174d6a9a83db@mailbox.org/
Tested-by: Erhard Furtner <erhard_f@mailbox.org>
Suggested-by: Suren Baghdasaryan <surenb@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Hao Ge <hao.ge@linux.dev>
Link: https://patch.msgid.link/20260923063759.34667-1-hao.ge@linux.dev
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-09-25 17:30:39 +02:00
..
buffered_read.c netfs: Fix netfs_read_gaps() to use separate sink folios 2026-09-17 11:24:05 +02:00
buffered_write.c netfs: Fix decision whether to disallow write-streaming due to fscache use 2026-07-01 15:26:28 +02:00
direct_read.c netfs: Fix cancellation of a DIO and single read subrequests 2026-05-12 14:42:29 +02:00
direct_write.c netfs: break unbuffered write when netfs_alloc_subrequest() fails 2026-08-31 09:54:38 +02:00
fscache_cache.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
fscache_cookie.c
fscache_internal.h
fscache_io.c
fscache_main.c
fscache_proc.c
fscache_stats.c
fscache_volume.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
internal.h netfs: Fix read progress reporting 2026-08-31 09:54:38 +02:00
iterator.c netfs: Fix overrun check in netfs_extract_user_iter() 2026-05-12 14:42:30 +02:00
Kconfig
locking.c netfs: Replace wb_lock with a bit lock for asynchronicity 2026-07-01 15:26:29 +02:00
main.c netfs: Fix folio_queue ENOMEM in writeback by adding a mempool 2026-07-28 15:42:31 +02:00
Makefile
misc.c netfs: Fix readahead synchronisation issues by loading all folios upfront 2026-08-31 09:54:38 +02:00
objects.c netfs: Fix missing alloc tagging of direct mempool allocations 2026-09-25 17:30:39 +02:00
read_collect.c netfs, afs: Fix symlink reading 2026-09-17 12:27:36 +02:00
read_pgpriv2.c netfs: Mark folios with COPY_TO_CACHE whilst issuing subreqs 2026-08-31 09:54:38 +02:00
read_retry.c netfs: Mark folios with COPY_TO_CACHE whilst issuing subreqs 2026-08-31 09:54:38 +02:00
read_single.c netfs: Fix read progress reporting 2026-08-31 09:54:38 +02:00
rolling_buffer.c netfs: Fix missing alloc tagging of direct mempool allocations 2026-09-25 17:30:39 +02:00
stats.c
write_collect.c netfs: Replace wb_lock with a bit lock for asynchronicity 2026-07-01 15:26:29 +02:00
write_issue.c netfs: break unbuffered write when netfs_alloc_subrequest() fails 2026-08-31 09:54:38 +02:00
write_retry.c netfs: Fix barriering when walking subrequest list 2026-07-03 11:52:41 +02:00