Skip to content

Commit b244358

Browse files
committed
slab: separate struct freelist_tid from kmem_cache_cpu
In kmem_cache_cpu we currently have a union of the freelist+tid pair with freelist_aba_t, relying implicitly on the type compatibility with the freelist+counters pair used in freelist_aba_t. To allow further changes to freelist_aba_t, we can instead define a separate struct freelist_tid (instead of a typedef, per the coding style) for kmem_cache_cpu, as that affects only a single helper __update_cpu_freelist_fast(). We can add the resulting struct freelist_tid to kmem_cache_cpu as unnamed field thanks to -fms-extensions, so that freelist and tid fields can still be accessed directly. Reviewed-by: Harry Yoo <harry.yoo@oracle.com> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
1 parent c99f969 commit b244358

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

mm/slub.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,22 @@ enum stat_item {
411411
};
412412

413413
#ifndef CONFIG_SLUB_TINY
414-
/*
415-
* When changing the layout, make sure freelist and tid are still compatible
416-
* with this_cpu_cmpxchg_double() alignment requirements.
417-
*/
418-
struct kmem_cache_cpu {
414+
struct freelist_tid {
419415
union {
420416
struct {
421-
void **freelist; /* Pointer to next available object */
417+
void *freelist; /* Pointer to next available object */
422418
unsigned long tid; /* Globally unique transaction id */
423419
};
424-
freelist_aba_t freelist_tid;
420+
freelist_full_t freelist_tid;
425421
};
422+
};
423+
424+
/*
425+
* When changing the layout, make sure freelist and tid are still compatible
426+
* with this_cpu_cmpxchg_double() alignment requirements.
427+
*/
428+
struct kmem_cache_cpu {
429+
struct freelist_tid;
426430
struct slab *slab; /* The slab from which we are allocating */
427431
#ifdef CONFIG_SLUB_CPU_PARTIAL
428432
struct slab *partial; /* Partially allocated slabs */
@@ -4367,11 +4371,11 @@ __update_cpu_freelist_fast(struct kmem_cache *s,
43674371
void *freelist_old, void *freelist_new,
43684372
unsigned long tid)
43694373
{
4370-
freelist_aba_t old = { .freelist = freelist_old, .counter = tid };
4371-
freelist_aba_t new = { .freelist = freelist_new, .counter = next_tid(tid) };
4374+
struct freelist_tid old = { .freelist = freelist_old, .tid = tid };
4375+
struct freelist_tid new = { .freelist = freelist_new, .tid = next_tid(tid) };
43724376

4373-
return this_cpu_try_cmpxchg_freelist(s->cpu_slab->freelist_tid.full,
4374-
&old.full, new.full);
4377+
return this_cpu_try_cmpxchg_freelist(s->cpu_slab->freelist_tid,
4378+
&old.freelist_tid, new.freelist_tid);
43754379
}
43764380

43774381
/*

0 commit comments

Comments
 (0)