[RFC][PATCH 0/1] sched/cputime: Improve getrusage(RUSAGE_THREAD) with nohz_full
From: Hasegawa Hitomi
Date: Tue Sep 28 2021 - 01:15:50 EST
Frederic, seems busy, so I create the proper patch, would you please add
your Signed-off-by: if this fix is okey.
This patch is a fix proposed in the following thread .
The getrusage(RUSAGE_THREAD) with nohz_full returns shorter utime/stime
than the actual time.
In the current implementation, task_cputime_adjusted() calls task_cputime()
to get the "current" utime and stime, then calls cputime_adjust () to adjust
the sum of utime and stime to be equal to cputime.sum_exec_runtime.
In nohz_full, sum_exec_runtime is not updated regularly, which is the cause
of this discrepancy.
This patch add a process to update sum_exec_runtime after getting
the information from "current" and before adjusting.
This addition applies only when run with nohz_full.
Hasegawa Hitomi (1):
sched/cputime: Improve getrusage(RUSAGE_THREAD) with nohz_full
include/linux/sched/cputime.h | 5 +++--
kernel/sched/cputime.c | 12 +++++++++---
2 files changed, 12 insertions(+), 5 deletions(-)