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: de-typedef

Switch all uses of the deprecated mempool_t typedef in the core mempool
code to use struct mempool instead.

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

authored by

Christoph Hellwig and committed by
Vlastimil Babka
0cab6873 8b41fb80

+45 -44
+19 -20
include/linux/mempool.h
··· 27 27 wait_queue_head_t wait; 28 28 } mempool_t; 29 29 30 - static inline bool mempool_initialized(mempool_t *pool) 30 + static inline bool mempool_initialized(struct mempool *pool) 31 31 { 32 32 return pool->elements != NULL; 33 33 } 34 34 35 - static inline bool mempool_is_saturated(mempool_t *pool) 35 + static inline bool mempool_is_saturated(struct mempool *pool) 36 36 { 37 37 return READ_ONCE(pool->curr_nr) >= pool->min_nr; 38 38 } 39 39 40 - void mempool_exit(mempool_t *pool); 41 - int mempool_init_node(mempool_t *pool, int min_nr, mempool_alloc_t *alloc_fn, 42 - mempool_free_t *free_fn, void *pool_data, 43 - gfp_t gfp_mask, int node_id); 44 - 45 - int mempool_init_noprof(mempool_t *pool, int min_nr, mempool_alloc_t *alloc_fn, 46 - mempool_free_t *free_fn, void *pool_data); 40 + void mempool_exit(struct mempool *pool); 41 + int mempool_init_node(struct mempool *pool, int min_nr, 42 + mempool_alloc_t *alloc_fn, mempool_free_t *free_fn, 43 + void *pool_data, gfp_t gfp_mask, int node_id); 44 + int mempool_init_noprof(struct mempool *pool, int min_nr, 45 + mempool_alloc_t *alloc_fn, mempool_free_t *free_fn, 46 + void *pool_data); 47 47 #define mempool_init(...) \ 48 48 alloc_hooks(mempool_init_noprof(__VA_ARGS__)) 49 49 50 - extern mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn, 51 - mempool_free_t *free_fn, void *pool_data); 52 - 53 - extern mempool_t *mempool_create_node_noprof(int min_nr, mempool_alloc_t *alloc_fn, 54 - mempool_free_t *free_fn, void *pool_data, 55 - gfp_t gfp_mask, int nid); 50 + struct mempool *mempool_create(int min_nr, mempool_alloc_t *alloc_fn, 51 + mempool_free_t *free_fn, void *pool_data); 52 + struct mempool *mempool_create_node_noprof(int min_nr, 53 + mempool_alloc_t *alloc_fn, mempool_free_t *free_fn, 54 + void *pool_data, gfp_t gfp_mask, int nid); 56 55 #define mempool_create_node(...) \ 57 56 alloc_hooks(mempool_create_node_noprof(__VA_ARGS__)) 58 57 ··· 59 60 mempool_create_node(_min_nr, _alloc_fn, _free_fn, _pool_data, \ 60 61 GFP_KERNEL, NUMA_NO_NODE) 61 62 62 - extern int mempool_resize(mempool_t *pool, int new_min_nr); 63 - extern void mempool_destroy(mempool_t *pool); 63 + int mempool_resize(struct mempool *pool, int new_min_nr); 64 + void mempool_destroy(struct mempool *pool); 64 65 65 - extern void *mempool_alloc_noprof(mempool_t *pool, gfp_t gfp_mask) __malloc; 66 + void *mempool_alloc_noprof(struct mempool *pool, gfp_t gfp_mask) __malloc; 66 67 #define mempool_alloc(...) \ 67 68 alloc_hooks(mempool_alloc_noprof(__VA_ARGS__)) 68 69 int mempool_alloc_bulk_noprof(struct mempool *pool, void **elem, ··· 70 71 #define mempool_alloc_bulk(...) \ 71 72 alloc_hooks(mempool_alloc_bulk_noprof(__VA_ARGS__)) 72 73 73 - extern void *mempool_alloc_preallocated(mempool_t *pool) __malloc; 74 - extern void mempool_free(void *element, mempool_t *pool); 74 + void *mempool_alloc_preallocated(struct mempool *pool) __malloc; 75 + void mempool_free(void *element, struct mempool *pool); 75 76 unsigned int mempool_free_bulk(struct mempool *pool, void **elem, 76 77 unsigned int count); 77 78
+26 -24
mm/mempool.c
··· 40 40 late_initcall(mempool_faul_inject_init); 41 41 42 42 #ifdef CONFIG_SLUB_DEBUG_ON 43 - static void poison_error(mempool_t *pool, void *element, size_t size, 43 + static void poison_error(struct mempool *pool, void *element, size_t size, 44 44 size_t byte) 45 45 { 46 46 const int nr = pool->curr_nr; ··· 57 57 dump_stack(); 58 58 } 59 59 60 - static void __check_element(mempool_t *pool, void *element, size_t size) 60 + static void __check_element(struct mempool *pool, void *element, size_t size) 61 61 { 62 62 u8 *obj = element; 63 63 size_t i; ··· 73 73 memset(obj, POISON_INUSE, size); 74 74 } 75 75 76 - static void check_element(mempool_t *pool, void *element) 76 + static void check_element(struct mempool *pool, void *element) 77 77 { 78 78 /* Skip checking: KASAN might save its metadata in the element. */ 79 79 if (kasan_enabled()) ··· 102 102 obj[size - 1] = POISON_END; 103 103 } 104 104 105 - static void poison_element(mempool_t *pool, void *element) 105 + static void poison_element(struct mempool *pool, void *element) 106 106 { 107 107 /* Skip poisoning: KASAN might save its metadata in the element. */ 108 108 if (kasan_enabled()) ··· 123 123 } 124 124 } 125 125 #else /* CONFIG_SLUB_DEBUG_ON */ 126 - static inline void check_element(mempool_t *pool, void *element) 126 + static inline void check_element(struct mempool *pool, void *element) 127 127 { 128 128 } 129 - static inline void poison_element(mempool_t *pool, void *element) 129 + static inline void poison_element(struct mempool *pool, void *element) 130 130 { 131 131 } 132 132 #endif /* CONFIG_SLUB_DEBUG_ON */ 133 133 134 - static __always_inline bool kasan_poison_element(mempool_t *pool, void *element) 134 + static __always_inline bool kasan_poison_element(struct mempool *pool, 135 + void *element) 135 136 { 136 137 if (pool->alloc == mempool_alloc_slab || pool->alloc == mempool_kmalloc) 137 138 return kasan_mempool_poison_object(element); ··· 142 141 return true; 143 142 } 144 143 145 - static void kasan_unpoison_element(mempool_t *pool, void *element) 144 + static void kasan_unpoison_element(struct mempool *pool, void *element) 146 145 { 147 146 if (pool->alloc == mempool_kmalloc) 148 147 kasan_mempool_unpoison_object(element, (size_t)pool->pool_data); ··· 154 153 (unsigned long)pool->pool_data); 155 154 } 156 155 157 - static __always_inline void add_element(mempool_t *pool, void *element) 156 + static __always_inline void add_element(struct mempool *pool, void *element) 158 157 { 159 158 BUG_ON(pool->min_nr != 0 && pool->curr_nr >= pool->min_nr); 160 159 poison_element(pool, element); ··· 162 161 pool->elements[pool->curr_nr++] = element; 163 162 } 164 163 165 - static void *remove_element(mempool_t *pool) 164 + static void *remove_element(struct mempool *pool) 166 165 { 167 166 void *element = pool->elements[--pool->curr_nr]; 168 167 ··· 183 182 * May be called on a zeroed but uninitialized mempool (i.e. allocated with 184 183 * kzalloc()). 185 184 */ 186 - void mempool_exit(mempool_t *pool) 185 + void mempool_exit(struct mempool *pool) 187 186 { 188 187 while (pool->curr_nr) { 189 188 void *element = remove_element(pool); ··· 202 201 * Free all reserved elements in @pool and @pool itself. This function 203 202 * only sleeps if the free_fn() function sleeps. 204 203 */ 205 - void mempool_destroy(mempool_t *pool) 204 + void mempool_destroy(struct mempool *pool) 206 205 { 207 206 if (unlikely(!pool)) 208 207 return; ··· 212 211 } 213 212 EXPORT_SYMBOL(mempool_destroy); 214 213 215 - int mempool_init_node(mempool_t *pool, int min_nr, mempool_alloc_t *alloc_fn, 216 - mempool_free_t *free_fn, void *pool_data, 217 - gfp_t gfp_mask, int node_id) 214 + int mempool_init_node(struct mempool *pool, int min_nr, 215 + mempool_alloc_t *alloc_fn, mempool_free_t *free_fn, 216 + void *pool_data, gfp_t gfp_mask, int node_id) 218 217 { 219 218 spin_lock_init(&pool->lock); 220 219 pool->min_nr = min_nr; ··· 264 263 * 265 264 * Return: %0 on success, negative error code otherwise. 266 265 */ 267 - int mempool_init_noprof(mempool_t *pool, int min_nr, mempool_alloc_t *alloc_fn, 268 - mempool_free_t *free_fn, void *pool_data) 266 + int mempool_init_noprof(struct mempool *pool, int min_nr, 267 + mempool_alloc_t *alloc_fn, mempool_free_t *free_fn, 268 + void *pool_data) 269 269 { 270 270 return mempool_init_node(pool, min_nr, alloc_fn, free_fn, 271 271 pool_data, GFP_KERNEL, NUMA_NO_NODE); ··· 292 290 * 293 291 * Return: pointer to the created memory pool object or %NULL on error. 294 292 */ 295 - mempool_t *mempool_create_node_noprof(int min_nr, mempool_alloc_t *alloc_fn, 296 - mempool_free_t *free_fn, void *pool_data, 297 - gfp_t gfp_mask, int node_id) 293 + struct mempool *mempool_create_node_noprof(int min_nr, 294 + mempool_alloc_t *alloc_fn, mempool_free_t *free_fn, 295 + void *pool_data, gfp_t gfp_mask, int node_id) 298 296 { 299 - mempool_t *pool; 297 + struct mempool *pool; 300 298 301 299 pool = kmalloc_node_noprof(sizeof(*pool), gfp_mask | __GFP_ZERO, node_id); 302 300 if (!pool) ··· 330 328 * 331 329 * Return: %0 on success, negative error code otherwise. 332 330 */ 333 - int mempool_resize(mempool_t *pool, int new_min_nr) 331 + int mempool_resize(struct mempool *pool, int new_min_nr) 334 332 { 335 333 void *element; 336 334 void **new_elements; ··· 532 530 * an element. Allocation failure can only happen when @gfp_mask does not 533 531 * include %__GFP_DIRECT_RECLAIM. 534 532 */ 535 - void *mempool_alloc_noprof(mempool_t *pool, gfp_t gfp_mask) 533 + void *mempool_alloc_noprof(struct mempool *pool, gfp_t gfp_mask) 536 534 { 537 535 gfp_t gfp_temp = mempool_adjust_gfp(&gfp_mask); 538 536 void *element; ··· 584 582 * Return: pointer to the allocated element or %NULL if no elements are 585 583 * available. 586 584 */ 587 - void *mempool_alloc_preallocated(mempool_t *pool) 585 + void *mempool_alloc_preallocated(struct mempool *pool) 588 586 { 589 587 void *element = NULL; 590 588