# git rev-parse -q --verify 3840cbe24cf060ea05a585ca497814609f5d47d1^{commit} 3840cbe24cf060ea05a585ca497814609f5d47d1 already have revision, skipping fetch # git checkout -q -f -B kisskb 3840cbe24cf060ea05a585ca497814609f5d47d1 # git clean -qxdf # < git log -1 # commit 3840cbe24cf060ea05a585ca497814609f5d47d1 # Author: Johannes Weiner # Date: Thu Oct 3 07:29:05 2024 -0400 # # sched: psi: fix bogus pressure spikes from aggregation race # # Brandon reports sporadic, non-sensical spikes in cumulative pressure # time (total=) when reading cpu.pressure at a high rate. This is due to # a race condition between reader aggregation and tasks changing states. # # While it affects all states and all resources captured by PSI, in # practice it most likely triggers with CPU pressure, since scheduling # events are so frequent compared to other resource events. # # The race context is the live snooping of ongoing stalls during a # pressure read. The read aggregates per-cpu records for stalls that # have concluded, but will also incorporate ad-hoc the duration of any # active state that hasn't been recorded yet. This is important to get # timely measurements of ongoing stalls. Those ad-hoc samples are # calculated on-the-fly up to the current time on that CPU; since the # stall hasn't concluded, it's expected that this is the minimum amount # of stall time that will enter the per-cpu records once it does. # # The problem is that the path that concludes the state uses a CPU clock # read that is not synchronized against aggregators; the clock is read # outside of the seqlock protection. This allows aggregators to race and # snoop a stall with a longer duration than will actually be recorded. # # With the recorded stall time being less than the last snapshot # remembered by the aggregator, a subsequent sample will underflow and # observe a bogus delta value, resulting in an erratic jump in pressure. # # Fix this by moving the clock read of the state change into the seqlock # protection. This ensures no aggregation can snoop live stalls past the # time that's recorded when the state concludes. # # Reported-by: Brandon Duffany # Link: https://bugzilla.kernel.org/show_bug.cgi?id=219194 # Link: https://lore.kernel.org/lkml/20240827121851.GB438928@cmpxchg.org/ # Fixes: df77430639c9 ("psi: Reduce calls to sched_clock() in psi") # Cc: stable@vger.kernel.org # Signed-off-by: Johannes Weiner # Reviewed-by: Chengming Zhou # Signed-off-by: Linus Torvalds # < /opt/cross/kisskb/korg/gcc-13.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-13.1.0-nolibc/sh4-linux/bin/sh4-linux-ld --version # < git log --format=%s --max-count=1 3840cbe24cf060ea05a585ca497814609f5d47d1 # make -s -j 160 ARCH=sh O=/kisskb/build/linus_allyesconfig_sh4-gcc13 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-13.1.0-nolibc/sh4-linux/bin/sh4-linux- allyesconfig # Added to kconfig CONFIG_BUILD_DOCSRC=n # Added to kconfig CONFIG_MODULE_SIG=n # < make -s -j 160 ARCH=sh O=/kisskb/build/linus_allyesconfig_sh4-gcc13 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-13.1.0-nolibc/sh4-linux/bin/sh4-linux- help # make -s -j 160 ARCH=sh O=/kisskb/build/linus_allyesconfig_sh4-gcc13 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-13.1.0-nolibc/sh4-linux/bin/sh4-linux- olddefconfig # make -s -j 160 ARCH=sh O=/kisskb/build/linus_allyesconfig_sh4-gcc13 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-13.1.0-nolibc/sh4-linux/bin/sh4-linux- Generating include/generated/machtypes.h :1519:2: warning: #warning syscall clone3 not implemented [-Wcpp] /kisskb/src/arch/sh/kernel/cpu/sh2/../../entry-common.S: Assembler messages: /kisskb/src/arch/sh/kernel/cpu/sh2/../../entry-common.S:85: Warning: overflow in branch to __restore_all; converted into longer instruction sequence /kisskb/src/arch/sh/kernel/cpu/sh2/../../entry-common.S:357: Warning: overflow in branch to syscall_exit_work; converted into longer instruction sequence /kisskb/src/arch/sh/kernel/cpu/sh2/../../entry-common.S:360: Warning: overflow in branch to syscall_exit_work; converted into longer instruction sequence /kisskb/src/kernel/fork.c: In function '__do_sys_clone3': /kisskb/src/kernel/fork.c:3078:2: error: #warning clone3() entry point is missing, please fix [-Werror=cpp] 3078 | #warning clone3() entry point is missing, please fix | ^~~~~~~ cc1: all warnings being treated as errors make[4]: *** [/kisskb/src/scripts/Makefile.build:229: kernel/fork.o] Error 1 make[4]: *** Waiting for unfinished jobs.... make[3]: *** [/kisskb/src/scripts/Makefile.build:478: kernel] Error 2 make[3]: *** Waiting for unfinished jobs.... {standard input}: Assembler messages: {standard input}: Warning: end of file not at end of a line; newline inserted {standard input}:1111: Error: unknown pseudo-op: `.l18' {standard input}: Error: open CFI at the end of file; missing .cfi_endproc directive {standard input}:1070: Error: displacement to undefined symbol .L142 overflows 8-bit field {standard input}:1075: Error: displacement to undefined symbol .L161 overflows 8-bit field {standard input}:1059: Error: pcrel too far {standard input}:1060: Error: pcrel too far {standard input}:1061: Error: pcrel too far sh4-linux-gcc: internal compiler error: Segmentation fault signal terminated program cc1 Please submit a full bug report, with preprocessed source (by using -freport-bug). See for instructions. make[6]: *** [/kisskb/src/scripts/Makefile.build:229: drivers/net/pcs/pcs-xpcs.o] Error 4 make[5]: *** [/kisskb/src/scripts/Makefile.build:478: drivers/net/pcs] Error 2 make[5]: *** Waiting for unfinished jobs.... {standard input}: Assembler messages: {standard input}: Warning: end of file not at end of a line; newline inserted {standard input}: Error: .size expression for mp2975_driver_exit does not evaluate to a constant sh4-linux-gcc: internal compiler error: Segmentation fault signal terminated program cc1 Please submit a full bug report, with preprocessed source (by using -freport-bug). See for instructions. make[6]: *** [/kisskb/src/scripts/Makefile.build:229: drivers/hwmon/pmbus/mp2975.o] Error 4 make[5]: *** [/kisskb/src/scripts/Makefile.build:478: drivers/hwmon/pmbus] Error 2 make[5]: *** Waiting for unfinished jobs.... make[4]: *** [/kisskb/src/scripts/Makefile.build:478: drivers/hwmon] Error 2 make[4]: *** Waiting for unfinished jobs.... make[4]: *** [/kisskb/src/scripts/Makefile.build:478: drivers/net] Error 2 make[3]: *** [/kisskb/src/scripts/Makefile.build:478: drivers] Error 2 make[2]: *** [/kisskb/src/Makefile:1936: .] Error 2 make[1]: *** [/kisskb/src/Makefile:224: __sub-make] Error 2 make: *** [Makefile:224: __sub-make] Error 2 Command 'make -s -j 160 ARCH=sh O=/kisskb/build/linus_allyesconfig_sh4-gcc13 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-13.1.0-nolibc/sh4-linux/bin/sh4-linux- ' returned non-zero exit status 2. # rm -rf /kisskb/build/linus_allyesconfig_sh4-gcc13 # Build took: 0:04:09.029423