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()
This commit is contained in:
Linus Torvalds
2025-12-06 11:31:49 -08:00
2 changed files with 19 additions and 19 deletions

View File

@@ -537,27 +537,27 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
if (permitted && (!whole || num_threads < 2)) if (permitted && (!whole || num_threads < 2))
wchan = !task_is_running(task); wchan = !task_is_running(task);
scoped_seqlock_read (&sig->stats_lock, ss_lock_irqsave) { scoped_guard(rcu) {
cmin_flt = sig->cmin_flt; scoped_seqlock_read (&sig->stats_lock, ss_lock_irqsave) {
cmaj_flt = sig->cmaj_flt; cmin_flt = sig->cmin_flt;
cutime = sig->cutime; cmaj_flt = sig->cmaj_flt;
cstime = sig->cstime; cutime = sig->cutime;
cgtime = sig->cgtime; cstime = sig->cstime;
cgtime = sig->cgtime;
if (whole) { if (whole) {
struct task_struct *t; struct task_struct *t;
min_flt = sig->min_flt; min_flt = sig->min_flt;
maj_flt = sig->maj_flt; maj_flt = sig->maj_flt;
gtime = sig->gtime; gtime = sig->gtime;
rcu_read_lock(); __for_each_thread(sig, t) {
__for_each_thread(sig, t) { min_flt += t->min_flt;
min_flt += t->min_flt; maj_flt += t->maj_flt;
maj_flt += t->maj_flt; gtime += task_gtime(t);
gtime += task_gtime(t); }
} }
rcu_read_unlock();
} }
} }

View File

@@ -1224,7 +1224,7 @@ struct ss_tmp {
spinlock_t *lock_irqsave; spinlock_t *lock_irqsave;
}; };
static inline void __scoped_seqlock_cleanup(struct ss_tmp *sst) static __always_inline void __scoped_seqlock_cleanup(struct ss_tmp *sst)
{ {
if (sst->lock) if (sst->lock)
spin_unlock(sst->lock); spin_unlock(sst->lock);
@@ -1252,7 +1252,7 @@ static inline void __scoped_seqlock_bug(void) { }
extern void __scoped_seqlock_bug(void); extern void __scoped_seqlock_bug(void);
#endif #endif
static inline void static __always_inline void
__scoped_seqlock_next(struct ss_tmp *sst, seqlock_t *lock, enum ss_state target) __scoped_seqlock_next(struct ss_tmp *sst, seqlock_t *lock, enum ss_state target)
{ {
switch (sst->state) { switch (sst->state) {