summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mm/percpu.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/mm/percpu.c b/mm/percpu.c
index 4d89965cba16..a802d72c116f 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1726,9 +1726,8 @@ static void pcpu_alloc_tag_free_hook(struct pcpu_chunk *chunk, int off, size_t s
* @gfp: allocation flags
*
* Allocate percpu area of @size bytes aligned at @align. If @gfp doesn't
- * contain %GFP_KERNEL, the allocation is atomic. If @gfp has __GFP_NOWARN
- * then no warning will be triggered on invalid or failed allocation
- * requests.
+ * allow blocking, the allocation is atomic. If @gfp has __GFP_NOWARN then no
+ * warning will be triggered on invalid or failed allocation requests.
*
* RETURNS:
* Percpu pointer to the allocated area on success, NULL on failure.
@@ -1749,8 +1748,17 @@ void __percpu *pcpu_alloc_noprof(size_t size, size_t align, bool reserved,
size_t bits, bit_align;
gfp = current_gfp_context(gfp);
- /* whitelisted flags that can be passed to the backing allocators */
- pcpu_gfp = gfp & (GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
+ /*
+ * Allowlisted flags that can be passed to the backing allocators.
+ * Backing allocations under pcpu_alloc_mutex must not recurse into
+ * IO/FS reclaim. Otherwise a GFP_KERNEL caller holding the mutex can
+ * block on reclaim while a GFP_NOIO/NOFS caller holding an IO/FS lock
+ * waits for the same mutex.
+ *
+ * Do not pass __GFP_NOFAIL. A small percpu allocation may need many
+ * backing pages, making nofail reclaim too costly under NOIO/NOFS.
+ */
+ pcpu_gfp = gfp & (GFP_NOIO | __GFP_NORETRY | __GFP_NOWARN);
is_atomic = !gfpflags_allow_blocking(gfp);
do_warn = !(gfp & __GFP_NOWARN);