48
48
* 1. slab_mutex (Global Mutex)
49
49
* 2. node->list_lock (Spinlock)
50
50
* 3. kmem_cache->cpu_slab->lock (Local lock)
51
- * 4. slab_lock(page ) (Only on some arches or for debugging)
51
+ * 4. slab_lock(slab ) (Only on some arches or for debugging)
52
52
* 5. object_map_lock (Only for debugging)
53
53
*
54
54
* slab_mutex
64
64
*
65
65
* The slab_lock is only used for debugging and on arches that do not
66
66
* have the ability to do a cmpxchg_double. It only protects:
67
- * A. page ->freelist -> List of object free in a page
68
- * B. page ->inuse -> Number of objects in use
69
- * C. page ->objects -> Number of objects in page
70
- * D. page ->frozen -> frozen state
67
+ * A. slab ->freelist -> List of free objects in a slab
68
+ * B. slab ->inuse -> Number of objects in use
69
+ * C. slab ->objects -> Number of objects in slab
70
+ * D. slab ->frozen -> frozen state
71
71
*
72
72
* Frozen slabs
73
73
*
74
74
* If a slab is frozen then it is exempt from list management. It is not
75
75
* on any list except per cpu partial list. The processor that froze the
76
- * slab is the one who can perform list operations on the page . Other
76
+ * slab is the one who can perform list operations on the slab . Other
77
77
* processors may put objects onto the freelist but the processor that
78
78
* froze the slab is the only one that can retrieve the objects from the
79
- * page 's freelist.
79
+ * slab 's freelist.
80
80
*
81
81
* list_lock
82
82
*
135
135
* minimal so we rely on the page allocators per cpu caches for
136
136
* fast frees and allocs.
137
137
*
138
- * page ->frozen The slab is frozen and exempt from list processing.
138
+ * slab ->frozen The slab is frozen and exempt from list processing.
139
139
* This means that the slab is dedicated to a purpose
140
140
* such as satisfying allocations for a specific
141
141
* processor. Objects may be freed in the slab while
@@ -250,7 +250,7 @@ static inline bool kmem_cache_has_cpu_partial(struct kmem_cache *s)
250
250
251
251
#define OO_SHIFT 16
252
252
#define OO_MASK ((1 << OO_SHIFT) - 1)
253
- #define MAX_OBJS_PER_PAGE 32767 /* since page .objects is u15 */
253
+ #define MAX_OBJS_PER_PAGE 32767 /* since slab .objects is u15 */
254
254
255
255
/* Internal SLUB flags */
256
256
/* Poison object */
@@ -423,8 +423,8 @@ static void slub_set_cpu_partial(struct kmem_cache *s, unsigned int nr_objects)
423
423
424
424
/*
425
425
* We take the number of objects but actually limit the number of
426
- * pages on the per cpu partial list, in order to limit excessive
427
- * growth of the list. For simplicity we assume that the pages will
426
+ * slabs on the per cpu partial list, in order to limit excessive
427
+ * growth of the list. For simplicity we assume that the slabs will
428
428
* be half-full.
429
429
*/
430
430
nr_slabs = DIV_ROUND_UP (nr_objects * 2 , oo_objects (s -> oo ));
@@ -594,9 +594,9 @@ static inline bool slab_add_kunit_errors(void) { return false; }
594
594
#endif
595
595
596
596
/*
597
- * Determine a map of object in use on a page .
597
+ * Determine a map of objects in use in a slab .
598
598
*
599
- * Node listlock must be held to guarantee that the page does
599
+ * Node listlock must be held to guarantee that the slab does
600
600
* not vanish from under us.
601
601
*/
602
602
static unsigned long * get_map (struct kmem_cache * s , struct slab * slab )
@@ -1139,7 +1139,7 @@ static int check_slab(struct kmem_cache *s, struct slab *slab)
1139
1139
}
1140
1140
1141
1141
/*
1142
- * Determine if a certain object on a page is on the freelist. Must hold the
1142
+ * Determine if a certain object in a slab is on the freelist. Must hold the
1143
1143
* slab lock to guarantee that the chains are in a consistent state.
1144
1144
*/
1145
1145
static int on_freelist (struct kmem_cache * s , struct slab * slab , void * search )
@@ -2184,7 +2184,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n,
2184
2184
}
2185
2185
2186
2186
/*
2187
- * Get a page from somewhere. Search in increasing NUMA distances.
2187
+ * Get a slab from somewhere. Search in increasing NUMA distances.
2188
2188
*/
2189
2189
static void * get_any_partial (struct kmem_cache * s , gfp_t flags ,
2190
2190
struct slab * * ret_slab )
@@ -2248,7 +2248,7 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags,
2248
2248
}
2249
2249
2250
2250
/*
2251
- * Get a partial page , lock it and return it.
2251
+ * Get a partial slab , lock it and return it.
2252
2252
*/
2253
2253
static void * get_partial (struct kmem_cache * s , gfp_t flags , int node ,
2254
2254
struct slab * * ret_slab )
@@ -2340,7 +2340,7 @@ static void init_kmem_cache_cpus(struct kmem_cache *s)
2340
2340
}
2341
2341
2342
2342
/*
2343
- * Finishes removing the cpu slab. Merges cpu's freelist with page 's freelist,
2343
+ * Finishes removing the cpu slab. Merges cpu's freelist with slab 's freelist,
2344
2344
* unfreezes the slabs and puts it on the proper list.
2345
2345
* Assumes the slab has been already safely taken away from kmem_cache_cpu
2346
2346
* by the caller.
@@ -2387,18 +2387,18 @@ static void deactivate_slab(struct kmem_cache *s, struct slab *slab,
2387
2387
}
2388
2388
2389
2389
/*
2390
- * Stage two: Unfreeze the page while splicing the per-cpu
2391
- * freelist to the head of page 's freelist.
2390
+ * Stage two: Unfreeze the slab while splicing the per-cpu
2391
+ * freelist to the head of slab 's freelist.
2392
2392
*
2393
- * Ensure that the page is unfrozen while the list presence
2393
+ * Ensure that the slab is unfrozen while the list presence
2394
2394
* reflects the actual number of objects during unfreeze.
2395
2395
*
2396
2396
* We setup the list membership and then perform a cmpxchg
2397
- * with the count. If there is a mismatch then the page
2398
- * is not unfrozen but the page is on the wrong list.
2397
+ * with the count. If there is a mismatch then the slab
2398
+ * is not unfrozen but the slab is on the wrong list.
2399
2399
*
2400
2400
* Then we restart the process which may have to remove
2401
- * the page from the list that we just put it on again
2401
+ * the slab from the list that we just put it on again
2402
2402
* because the number of objects in the slab may have
2403
2403
* changed.
2404
2404
*/
@@ -2426,9 +2426,8 @@ static void deactivate_slab(struct kmem_cache *s, struct slab *slab,
2426
2426
if (!lock ) {
2427
2427
lock = 1 ;
2428
2428
/*
2429
- * Taking the spinlock removes the possibility
2430
- * that acquire_slab() will see a slab page that
2431
- * is frozen
2429
+ * Taking the spinlock removes the possibility that
2430
+ * acquire_slab() will see a slab that is frozen
2432
2431
*/
2433
2432
spin_lock_irqsave (& n -> list_lock , flags );
2434
2433
}
@@ -2569,8 +2568,8 @@ static void unfreeze_partials_cpu(struct kmem_cache *s,
2569
2568
}
2570
2569
2571
2570
/*
2572
- * Put a page that was just frozen (in __slab_free|get_partial_node) into a
2573
- * partial page slot if available.
2571
+ * Put a slab that was just frozen (in __slab_free|get_partial_node) into a
2572
+ * partial slab slot if available.
2574
2573
*
2575
2574
* If we did not find a slot then simply move all the partials to the
2576
2575
* per node partial list.
@@ -2841,12 +2840,12 @@ static inline bool pfmemalloc_match(struct slab *slab, gfp_t gfpflags)
2841
2840
}
2842
2841
2843
2842
/*
2844
- * Check the page ->freelist of a page and either transfer the freelist to the
2845
- * per cpu freelist or deactivate the page .
2843
+ * Check the slab ->freelist and either transfer the freelist to the
2844
+ * per cpu freelist or deactivate the slab .
2846
2845
*
2847
- * The page is still frozen if the return value is not NULL.
2846
+ * The slab is still frozen if the return value is not NULL.
2848
2847
*
2849
- * If this function returns NULL then the page has been unfrozen.
2848
+ * If this function returns NULL then the slab has been unfrozen.
2850
2849
*/
2851
2850
static inline void * get_freelist (struct kmem_cache * s , struct slab * slab )
2852
2851
{
@@ -2902,7 +2901,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
2902
2901
2903
2902
stat (s , ALLOC_SLOWPATH );
2904
2903
2905
- reread_page :
2904
+ reread_slab :
2906
2905
2907
2906
slab = READ_ONCE (c -> slab );
2908
2907
if (!slab ) {
@@ -2939,11 +2938,11 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
2939
2938
if (unlikely (!pfmemalloc_match (slab , gfpflags )))
2940
2939
goto deactivate_slab ;
2941
2940
2942
- /* must check again c->page in case we got preempted and it changed */
2941
+ /* must check again c->slab in case we got preempted and it changed */
2943
2942
local_lock_irqsave (& s -> cpu_slab -> lock , flags );
2944
2943
if (unlikely (slab != c -> slab )) {
2945
2944
local_unlock_irqrestore (& s -> cpu_slab -> lock , flags );
2946
- goto reread_page ;
2945
+ goto reread_slab ;
2947
2946
}
2948
2947
freelist = c -> freelist ;
2949
2948
if (freelist )
@@ -2966,8 +2965,8 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
2966
2965
2967
2966
/*
2968
2967
* freelist is pointing to the list of objects to be used.
2969
- * page is pointing to the page from which the objects are obtained.
2970
- * That page must be frozen for per cpu allocations to work.
2968
+ * slab is pointing to the slab from which the objects are obtained.
2969
+ * That slab must be frozen for per cpu allocations to work.
2971
2970
*/
2972
2971
VM_BUG_ON (!c -> slab -> frozen );
2973
2972
c -> freelist = get_freepointer (s , freelist );
@@ -2980,7 +2979,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
2980
2979
local_lock_irqsave (& s -> cpu_slab -> lock , flags );
2981
2980
if (slab != c -> slab ) {
2982
2981
local_unlock_irqrestore (& s -> cpu_slab -> lock , flags );
2983
- goto reread_page ;
2982
+ goto reread_slab ;
2984
2983
}
2985
2984
freelist = c -> freelist ;
2986
2985
c -> slab = NULL ;
@@ -2994,7 +2993,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
2994
2993
local_lock_irqsave (& s -> cpu_slab -> lock , flags );
2995
2994
if (unlikely (c -> slab )) {
2996
2995
local_unlock_irqrestore (& s -> cpu_slab -> lock , flags );
2997
- goto reread_page ;
2996
+ goto reread_slab ;
2998
2997
}
2999
2998
if (unlikely (!slub_percpu_partial (c ))) {
3000
2999
local_unlock_irqrestore (& s -> cpu_slab -> lock , flags );
@@ -3013,7 +3012,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
3013
3012
3014
3013
freelist = get_partial (s , gfpflags , node , & slab );
3015
3014
if (freelist )
3016
- goto check_new_page ;
3015
+ goto check_new_slab ;
3017
3016
3018
3017
slub_put_cpu_ptr (s -> cpu_slab );
3019
3018
slab = new_slab (s , gfpflags , node );
@@ -3025,15 +3024,15 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
3025
3024
}
3026
3025
3027
3026
/*
3028
- * No other reference to the page yet so we can
3027
+ * No other reference to the slab yet so we can
3029
3028
* muck around with it freely without cmpxchg
3030
3029
*/
3031
3030
freelist = slab -> freelist ;
3032
3031
slab -> freelist = NULL ;
3033
3032
3034
3033
stat (s , ALLOC_SLAB );
3035
3034
3036
- check_new_page :
3035
+ check_new_slab :
3037
3036
3038
3037
if (kmem_cache_debug (s )) {
3039
3038
if (!alloc_debug_processing (s , slab , freelist , addr )) {
@@ -3055,7 +3054,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
3055
3054
*/
3056
3055
goto return_single ;
3057
3056
3058
- retry_load_page :
3057
+ retry_load_slab :
3059
3058
3060
3059
local_lock_irqsave (& s -> cpu_slab -> lock , flags );
3061
3060
if (unlikely (c -> slab )) {
@@ -3072,7 +3071,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
3072
3071
3073
3072
stat (s , CPUSLAB_FLUSH );
3074
3073
3075
- goto retry_load_page ;
3074
+ goto retry_load_slab ;
3076
3075
}
3077
3076
c -> slab = slab ;
3078
3077
@@ -3169,9 +3168,9 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s,
3169
3168
/*
3170
3169
* Irqless object alloc/free algorithm used here depends on sequence
3171
3170
* of fetching cpu_slab's data. tid should be fetched before anything
3172
- * on c to guarantee that object and page associated with previous tid
3171
+ * on c to guarantee that object and slab associated with previous tid
3173
3172
* won't be used with current tid. If we fetch tid first, object and
3174
- * page could be one associated with next tid and our alloc/free
3173
+ * slab could be one associated with next tid and our alloc/free
3175
3174
* request will be failed. In this case, we will retry. So, no problem.
3176
3175
*/
3177
3176
barrier ();
@@ -3295,7 +3294,7 @@ EXPORT_SYMBOL(kmem_cache_alloc_node_trace);
3295
3294
* have a longer lifetime than the cpu slabs in most processing loads.
3296
3295
*
3297
3296
* So we still attempt to reduce cache line usage. Just take the slab
3298
- * lock and free the item. If there is no additional partial page
3297
+ * lock and free the item. If there is no additional partial slab
3299
3298
* handling required then we can return immediately.
3300
3299
*/
3301
3300
static void __slab_free (struct kmem_cache * s , struct slab * slab ,
@@ -3373,7 +3372,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab,
3373
3372
stat (s , FREE_FROZEN );
3374
3373
} else if (new .frozen ) {
3375
3374
/*
3376
- * If we just froze the page then put it onto the
3375
+ * If we just froze the slab then put it onto the
3377
3376
* per cpu partial list.
3378
3377
*/
3379
3378
put_cpu_partial (s , slab , 1 );
@@ -3427,7 +3426,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab,
3427
3426
* with all sorts of special processing.
3428
3427
*
3429
3428
* Bulk free of a freelist with several objects (all pointing to the
3430
- * same page ) possible by specifying head and tail ptr, plus objects
3429
+ * same slab ) possible by specifying head and tail ptr, plus objects
3431
3430
* count (cnt). Bulk free indicated by tail pointer being set.
3432
3431
*/
3433
3432
static __always_inline void do_slab_free (struct kmem_cache * s ,
@@ -4213,7 +4212,7 @@ static int kmem_cache_open(struct kmem_cache *s, slab_flags_t flags)
4213
4212
#endif
4214
4213
4215
4214
/*
4216
- * The larger the object size is, the more pages we want on the partial
4215
+ * The larger the object size is, the more slabs we want on the partial
4217
4216
* list to avoid pounding the page allocator excessively.
4218
4217
*/
4219
4218
set_min_partial (s , ilog2 (s -> size ) / 2 );
@@ -4598,12 +4597,12 @@ static int __kmem_cache_do_shrink(struct kmem_cache *s)
4598
4597
* Build lists of slabs to discard or promote.
4599
4598
*
4600
4599
* Note that concurrent frees may occur while we hold the
4601
- * list_lock. page ->inuse here is the upper limit.
4600
+ * list_lock. slab ->inuse here is the upper limit.
4602
4601
*/
4603
4602
list_for_each_entry_safe (slab , t , & n -> partial , slab_list ) {
4604
4603
int free = slab -> objects - slab -> inuse ;
4605
4604
4606
- /* Do not reread page ->inuse */
4605
+ /* Do not reread slab ->inuse */
4607
4606
barrier ();
4608
4607
4609
4608
/* We do not keep full slabs on the list */
@@ -5482,7 +5481,7 @@ static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf)
5482
5481
slabs += slab -> slabs ;
5483
5482
}
5484
5483
5485
- /* Approximate half-full pages , see slub_set_cpu_partial() */
5484
+ /* Approximate half-full slabs , see slub_set_cpu_partial() */
5486
5485
objects = (slabs * oo_objects (s -> oo )) / 2 ;
5487
5486
len += sysfs_emit_at (buf , len , "%d(%d)" , objects , slabs );
5488
5487
0 commit comments