summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorHungyu Lin <dennylin0707@gmail.com>2026-10-30 05:42:27 +0000
committerThomas Gleixner <tglx@kernel.org>2026-11-09 20:15:58 +0100
commitc49b3c20a2d0b22700e2100a527e68e829ece7f0 (patch)
tree8b1b6512e836ee00a05572c033c5f890a3e4e602 /tools/perf/scripts/python
parent385b5ec1f31dd39297578eed42be74b07ae74017 (diff)
tsacct: Keep task begin times stable across suspend
bacct_add_tsk() derives ac_btime and ac_btime64 by subtracting a CLOCK_MONOTONIC elapsed duration from CLOCK_REALTIME. MONOTONIC stops during suspend while REALTIME continues, so querying an existing task after resume moves its reported begin time forward by the time spent suspended. Calculate the begin time from the wall-clock boot timestamp and the task's CLOCK_BOOTTIME start timestamp instead. This accounts for suspend and adds the nanoseconds before truncating to seconds. Keep ac_etime and ac_tgetime on CLOCK_MONOTONIC and retain the existing rebasing when the wall clock is adjusted. The new begin time can be negative: setting CLOCK_REALTIME is bounded by CLOCK_MONOTONIC, which excludes suspend, rather than CLOCK_BOOTTIME. A permitted backward clock adjustment after suspend can therefore put the task's begin time before the epoch. Clamp ac_btime64 at zero too, instead of wrapping in the unsigned field, and retain its positive range. Fixes: f3cef7a99469 ("[PATCH] csa: basic accounting over taskstats") Reported-by: Oleg Nesterov <oleg@redhat.com> Suggested-by: Thomas Gleixner <tglx@kernel.org> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20130611200600.GA15168@redhat.com Link: https://lore.kernel.org/r/alpine.DEB.2.21.1911071335320.4256@nanos.tec.linutronix.de Link: https://patch.msgid.link/20261030054227.35453-3-dennylin0707@gmail.com
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions