slab.h (d754ed2821fd9675d203cb73c4afcd593e28b7d0) | slab.h (67f2df3b82d091ed095d0e47e1f3a9d3e18e4e41) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef MM_SLAB_H 3#define MM_SLAB_H 4 5#include <linux/reciprocal_div.h> 6#include <linux/list_lru.h> 7#include <linux/local_lock.h> 8#include <linux/random.h> --- 152 unchanged lines hidden (view full) --- 161#define slab_page(s) folio_page(slab_folio(s), 0) 162 163/* 164 * If network-based swap is enabled, sl*b must keep track of whether pages 165 * were allocated from pfmemalloc reserves. 166 */ 167static inline bool slab_test_pfmemalloc(const struct slab *slab) 168{ | 1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef MM_SLAB_H 3#define MM_SLAB_H 4 5#include <linux/reciprocal_div.h> 6#include <linux/list_lru.h> 7#include <linux/local_lock.h> 8#include <linux/random.h> --- 152 unchanged lines hidden (view full) --- 161#define slab_page(s) folio_page(slab_folio(s), 0) 162 163/* 164 * If network-based swap is enabled, sl*b must keep track of whether pages 165 * were allocated from pfmemalloc reserves. 166 */ 167static inline bool slab_test_pfmemalloc(const struct slab *slab) 168{ |
169 return folio_test_active((struct folio *)slab_folio(slab)); | 169 return folio_test_active(slab_folio(slab)); |
170} 171 172static inline void slab_set_pfmemalloc(struct slab *slab) 173{ 174 folio_set_active(slab_folio(slab)); 175} 176 177static inline void slab_clear_pfmemalloc(struct slab *slab) --- 28 unchanged lines hidden (view full) --- 206 if (!folio_test_slab(folio)) 207 return NULL; 208 209 return folio_slab(folio); 210} 211 212static inline int slab_order(const struct slab *slab) 213{ | 170} 171 172static inline void slab_set_pfmemalloc(struct slab *slab) 173{ 174 folio_set_active(slab_folio(slab)); 175} 176 177static inline void slab_clear_pfmemalloc(struct slab *slab) --- 28 unchanged lines hidden (view full) --- 206 if (!folio_test_slab(folio)) 207 return NULL; 208 209 return folio_slab(folio); 210} 211 212static inline int slab_order(const struct slab *slab) 213{ |
214 return folio_order((struct folio *)slab_folio(slab)); | 214 return folio_order(slab_folio(slab)); |
215} 216 217static inline size_t slab_size(const struct slab *slab) 218{ 219 return PAGE_SIZE << slab_order(slab); 220} 221 222#ifdef CONFIG_SLUB_CPU_PARTIAL --- 175 unchanged lines hidden (view full) --- 398/* 399 * Find the kmem_cache structure that serves a given size of 400 * allocation 401 * 402 * This assumes size is larger than zero and not larger than 403 * KMALLOC_MAX_CACHE_SIZE and the caller must check that. 404 */ 405static inline struct kmem_cache * | 215} 216 217static inline size_t slab_size(const struct slab *slab) 218{ 219 return PAGE_SIZE << slab_order(slab); 220} 221 222#ifdef CONFIG_SLUB_CPU_PARTIAL --- 175 unchanged lines hidden (view full) --- 398/* 399 * Find the kmem_cache structure that serves a given size of 400 * allocation 401 * 402 * This assumes size is larger than zero and not larger than 403 * KMALLOC_MAX_CACHE_SIZE and the caller must check that. 404 */ 405static inline struct kmem_cache * |
406kmalloc_slab(size_t size, gfp_t flags, unsigned long caller) | 406kmalloc_slab(size_t size, kmem_buckets *b, gfp_t flags, unsigned long caller) |
407{ 408 unsigned int index; 409 | 407{ 408 unsigned int index; 409 |
410 if (!b) 411 b = &kmalloc_caches[kmalloc_type(flags, caller)]; |
|
410 if (size <= 192) 411 index = kmalloc_size_index[size_index_elem(size)]; 412 else 413 index = fls(size - 1); 414 | 412 if (size <= 192) 413 index = kmalloc_size_index[size_index_elem(size)]; 414 else 415 index = fls(size - 1); 416 |
415 return kmalloc_caches[kmalloc_type(flags, caller)][index]; | 417 return (*b)[index]; |
416} 417 418gfp_t kmalloc_fix_flags(gfp_t flags); 419 420/* Functions provided by the slab allocators */ 421int __kmem_cache_create(struct kmem_cache *, slab_flags_t flags); 422 423void __init kmem_cache_init(void); --- 260 unchanged lines hidden --- | 418} 419 420gfp_t kmalloc_fix_flags(gfp_t flags); 421 422/* Functions provided by the slab allocators */ 423int __kmem_cache_create(struct kmem_cache *, slab_flags_t flags); 424 425void __init kmem_cache_init(void); --- 260 unchanged lines hidden --- |