# 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-8.5.0-nolibc/mips-linux/bin/mips-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-8.5.0-nolibc/mips-linux/bin/mips-linux-ld --version # < git log --format=%s --max-count=1 3840cbe24cf060ea05a585ca497814609f5d47d1 # make -s -j 160 ARCH=mips O=/kisskb/build/linus_64r2_defconfig_mips-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.5.0-nolibc/mips-linux/bin/mips-linux- 64r2_defconfig Using /kisskb/src/arch/mips/configs/generic_defconfig as base Merging /kisskb/src/arch/mips/configs/generic/64r2.config Merging /kisskb/src/arch/mips/configs/generic/eb.config Merging /kisskb/src/arch/mips/configs/generic/board-boston.config Merging /kisskb/src/arch/mips/configs/generic/board-litex.config Merging /kisskb/src/arch/mips/configs/generic/board-marduk.config Merging /kisskb/src/arch/mips/configs/generic/board-ranchu.config Merging /kisskb/src/arch/mips/configs/generic/board-virt.config # < make -s -j 160 ARCH=mips O=/kisskb/build/linus_64r2_defconfig_mips-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.5.0-nolibc/mips-linux/bin/mips-linux- help # make -s -j 160 ARCH=mips O=/kisskb/build/linus_64r2_defconfig_mips-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.5.0-nolibc/mips-linux/bin/mips-linux- olddefconfig # make -s -j 160 ARCH=mips O=/kisskb/build/linus_64r2_defconfig_mips-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.5.0-nolibc/mips-linux/bin/mips-linux- /kisskb/src/arch/mips/boot/dts/img/boston.dts:128.17-178.5: Warning (interrupt_provider): /pci@14000000/pci2_root@0,0: '#interrupt-cells' found, but node is not an interrupt provider /kisskb/src/arch/mips/boot/dts/img/boston.dts:136.23-177.6: Warning (interrupt_provider): /pci@14000000/pci2_root@0,0/eg20t_bridge@1,0,0: '#interrupt-cells' found, but node is not an interrupt provider arch/mips/boot/dts/img/boston.dtb: Warning (interrupt_map): Failed prerequisite 'interrupt_provider' Completed OK # rm -rf /kisskb/build/linus_64r2_defconfig_mips-gcc8 # Build took: 0:02:14.765719