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.

Merge tag 'cgroup-for-6.16-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup

Pull cgroup fix from Tejun Heo:
"The rstat per-subsystem split change skipped per-cpu allocation on UP
configs; however even on UP, depending on config options, the size of
the percpu struct may not be zero leading to crashes.

Fix it by conditionalizing the per-cpu area allocation and usage on
the size of the per-cpu struct"

* tag 'cgroup-for-6.16-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
cgroup: adjust criteria for rstat subsystem cpu lock access

+16 -9
+16 -9
kernel/cgroup/rstat.c
··· 47 47 48 48 static raw_spinlock_t *ss_rstat_cpu_lock(struct cgroup_subsys *ss, int cpu) 49 49 { 50 - if (ss) 50 + if (ss) { 51 + /* 52 + * Depending on config, the subsystem per-cpu lock type may be an 53 + * empty struct. In enviromnents where this is the case, allocation 54 + * of this field is not performed in ss_rstat_init(). Avoid a 55 + * cpu-based offset relative to NULL by returning early. When the 56 + * lock type is zero in size, the corresponding lock functions are 57 + * no-ops so passing them NULL is acceptable. 58 + */ 59 + if (sizeof(*ss->rstat_ss_cpu_lock) == 0) 60 + return NULL; 61 + 51 62 return per_cpu_ptr(ss->rstat_ss_cpu_lock, cpu); 63 + } 52 64 53 65 return per_cpu_ptr(&rstat_base_cpu_lock, cpu); 54 66 } ··· 522 510 { 523 511 int cpu; 524 512 525 - #ifdef CONFIG_SMP 526 513 /* 527 - * On uniprocessor machines, arch_spinlock_t is defined as an empty 528 - * struct. Avoid allocating a size of zero by having this block 529 - * excluded in this case. It's acceptable to leave the subsystem locks 530 - * unitialized since the associated lock functions are no-ops in the 531 - * non-smp case. 514 + * Depending on config, the subsystem per-cpu lock type may be an empty 515 + * struct. Avoid allocating a size of zero in this case. 532 516 */ 533 - if (ss) { 517 + if (ss && sizeof(*ss->rstat_ss_cpu_lock)) { 534 518 ss->rstat_ss_cpu_lock = alloc_percpu(raw_spinlock_t); 535 519 if (!ss->rstat_ss_cpu_lock) 536 520 return -ENOMEM; 537 521 } 538 - #endif 539 522 540 523 spin_lock_init(ss_rstat_lock(ss)); 541 524 for_each_possible_cpu(cpu)