Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mempool: factor out a mempool_adjust_gfp helper

Add a helper to better isolate and document the gfp flags adjustments.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20251113084022.1255121-6-hch@lst.de
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

authored by

Christoph Hellwig and committed by
Vlastimil Babka
3d249240 b77fc08e

+14 -7
+14 -7
mm/mempool.c
··· 380 380 } 381 381 EXPORT_SYMBOL(mempool_resize); 382 382 383 + /* 384 + * Adjust the gfp flags for mempool allocations, as we never want to dip into 385 + * the global emergency reserves or retry in the page allocator. 386 + * 387 + * The first pass also doesn't want to go reclaim, but the next passes do, so 388 + * return a separate subset for that first iteration. 389 + */ 390 + static inline gfp_t mempool_adjust_gfp(gfp_t *gfp_mask) 391 + { 392 + *gfp_mask |= __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN; 393 + return *gfp_mask & ~(__GFP_DIRECT_RECLAIM | __GFP_IO); 394 + } 395 + 383 396 /** 384 397 * mempool_alloc - allocate an element from a memory pool 385 398 * @pool: pointer to the memory pool ··· 411 398 */ 412 399 void *mempool_alloc_noprof(mempool_t *pool, gfp_t gfp_mask) 413 400 { 401 + gfp_t gfp_temp = mempool_adjust_gfp(&gfp_mask); 414 402 void *element; 415 403 unsigned long flags; 416 404 wait_queue_entry_t wait; 417 - gfp_t gfp_temp; 418 405 419 406 VM_WARN_ON_ONCE(gfp_mask & __GFP_ZERO); 420 407 might_alloc(gfp_mask); 421 - 422 - gfp_mask |= __GFP_NOMEMALLOC; /* don't allocate emergency reserves */ 423 - gfp_mask |= __GFP_NORETRY; /* don't loop in __alloc_pages */ 424 - gfp_mask |= __GFP_NOWARN; /* failures are OK */ 425 - 426 - gfp_temp = gfp_mask & ~(__GFP_DIRECT_RECLAIM|__GFP_IO); 427 408 428 409 repeat_alloc: 429 410 if (should_fail_ex(&fail_mempool_alloc, 1, FAULT_NOWARN)) {