Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'locking-urgent-2025-12-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull locking fixes from Ingo Molnar:
"Two fixes related to recent introduction of scoped_seqlock_read():

- Fix compiler build failures when a particular .config and compiler
build options variant doesn't result in the expected removal of
unused, catch-bugs portions of scoped_seqlock_read() by the inliner
at build time, and cause a linker fail even in correct code

- Match read-locking order in do_task_stat() and do_io_accounting().
The inconsistency here was harmless but unnecessary"

* tag 'locking-urgent-2025-12-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
seqlock: Cure some more scoped_seqlock() optimization fails
seqlock, procfs: Match scoped_seqlock_read() critical section vs. RCU ordering in do_task_stat() to do_io_accounting()

+19 -19
+17 -17
fs/proc/array.c
··· 537 537 if (permitted && (!whole || num_threads < 2)) 538 538 wchan = !task_is_running(task); 539 539 540 - scoped_seqlock_read (&sig->stats_lock, ss_lock_irqsave) { 541 - cmin_flt = sig->cmin_flt; 542 - cmaj_flt = sig->cmaj_flt; 543 - cutime = sig->cutime; 544 - cstime = sig->cstime; 545 - cgtime = sig->cgtime; 540 + scoped_guard(rcu) { 541 + scoped_seqlock_read (&sig->stats_lock, ss_lock_irqsave) { 542 + cmin_flt = sig->cmin_flt; 543 + cmaj_flt = sig->cmaj_flt; 544 + cutime = sig->cutime; 545 + cstime = sig->cstime; 546 + cgtime = sig->cgtime; 546 547 547 - if (whole) { 548 - struct task_struct *t; 548 + if (whole) { 549 + struct task_struct *t; 549 550 550 - min_flt = sig->min_flt; 551 - maj_flt = sig->maj_flt; 552 - gtime = sig->gtime; 551 + min_flt = sig->min_flt; 552 + maj_flt = sig->maj_flt; 553 + gtime = sig->gtime; 553 554 554 - rcu_read_lock(); 555 - __for_each_thread(sig, t) { 556 - min_flt += t->min_flt; 557 - maj_flt += t->maj_flt; 558 - gtime += task_gtime(t); 555 + __for_each_thread(sig, t) { 556 + min_flt += t->min_flt; 557 + maj_flt += t->maj_flt; 558 + gtime += task_gtime(t); 559 + } 559 560 } 560 - rcu_read_unlock(); 561 561 } 562 562 } 563 563
+2 -2
include/linux/seqlock.h
··· 1224 1224 spinlock_t *lock_irqsave; 1225 1225 }; 1226 1226 1227 - static inline void __scoped_seqlock_cleanup(struct ss_tmp *sst) 1227 + static __always_inline void __scoped_seqlock_cleanup(struct ss_tmp *sst) 1228 1228 { 1229 1229 if (sst->lock) 1230 1230 spin_unlock(sst->lock); ··· 1252 1252 extern void __scoped_seqlock_bug(void); 1253 1253 #endif 1254 1254 1255 - static inline void 1255 + static __always_inline void 1256 1256 __scoped_seqlock_next(struct ss_tmp *sst, seqlock_t *lock, enum ss_state target) 1257 1257 { 1258 1258 switch (sst->state) {