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.
 
 Signed-off-by: Ingo Molnar <mingo@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCgAvFiEEBpT5eoXrXCwVQwEKEnMQ0APhK1gFAmk0E/wRHG1pbmdvQGtl
 cm5lbC5vcmcACgkQEnMQ0APhK1j10A/9GFzapX2e4SjyzTUeScdEbVM9cp7cb4lo
 PdPXtmq+Nsh+aw/I+hFBj1bGOnV+xRfoU/wc2a3CfFa1CwekRuzTcbCMU60wfJJr
 CYTf1e390J+6XG588JasjykN9TePDY+TZPIv9rO1Eczsgf6AlXQ8m3Q2tAax8CoN
 8AwMBLZFDmP6WjykeqADXOw4MWU/qS/6vESy65LN11n4jzp7dU4VCTF/Cb8ISEvj
 DMPByPwl/Kv9ioKwKf8xEMHvwboa3wwaE8OI8hxvcdB/VjUk0aSTSN/+6EFefX09
 XM2+2EmDr0E2lLutdsBccD7Yy9PK9vlekWSTDqGY5UcTWYRc0mo20nnUrHyu9QF5
 Yk+mr3jyYnPxKgUYu2d2mfeHXDidW0Yo60fvsO7Y1yfxBPQLMyr+MdYiq86IUvcc
 6pTJhw33N5pd+1zM2tRJclUAyiXSD89/XftBrF/USKB0SAS8dLz/fYJ3ApjEJzfz
 xdbIOz8jOMGum1wF8ss1wqjIhWvw3ICZhdMo+6032eR5Gr5SNGpM1lPu7cQQJ4pI
 tRvATuu5lXsxPEM4l/gb1BqlZImUGCaG4wgiQ1xcwMrsyqLoqWUmumdF3A84+wBa
 J6N+3NFALuce6vxABUOyx/oqfaBITndbnWQlC4uGgtNzlqjGABsyqBQL+svp2j2m
 O2jhqGfW4J8=
 =+H27
 -----END PGP SIGNATURE-----

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()
pull/1354/merge
Linus Torvalds 2025-12-06 11:31:49 -08:00
commit 92fc1f16e2
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))
wchan = !task_is_running(task);
scoped_seqlock_read (&sig->stats_lock, ss_lock_irqsave) {
cmin_flt = sig->cmin_flt;
cmaj_flt = sig->cmaj_flt;
cutime = sig->cutime;
cstime = sig->cstime;
cgtime = sig->cgtime;
scoped_guard(rcu) {
scoped_seqlock_read (&sig->stats_lock, ss_lock_irqsave) {
cmin_flt = sig->cmin_flt;
cmaj_flt = sig->cmaj_flt;
cutime = sig->cutime;
cstime = sig->cstime;
cgtime = sig->cgtime;
if (whole) {
struct task_struct *t;
if (whole) {
struct task_struct *t;
min_flt = sig->min_flt;
maj_flt = sig->maj_flt;
gtime = sig->gtime;
min_flt = sig->min_flt;
maj_flt = sig->maj_flt;
gtime = sig->gtime;
rcu_read_lock();
__for_each_thread(sig, t) {
min_flt += t->min_flt;
maj_flt += t->maj_flt;
gtime += task_gtime(t);
__for_each_thread(sig, t) {
min_flt += t->min_flt;
maj_flt += t->maj_flt;
gtime += task_gtime(t);
}
}
rcu_read_unlock();
}
}

View File

@ -1224,7 +1224,7 @@ struct ss_tmp {
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)
spin_unlock(sst->lock);
@ -1252,7 +1252,7 @@ static inline void __scoped_seqlock_bug(void) { }
extern void __scoped_seqlock_bug(void);
#endif
static inline void
static __always_inline void
__scoped_seqlock_next(struct ss_tmp *sst, seqlock_t *lock, enum ss_state target)
{
switch (sst->state) {