All of lore.kernel.org
 help / color / mirror / Atom feed
* Utime and stime are less when getrusage (RUSAGE_THREAD) is executed on a tickless CPU.
@ 2021-05-12  3:28 hasegawa-hitomi
  2021-05-18  7:59 ` hasegawa-hitomi
  0 siblings, 1 reply; 16+ messages in thread
From: hasegawa-hitomi @ 2021-05-12  3:28 UTC (permalink / raw)
  To: 'fweisbec@gmail.com', 'tglx@linutronix.de',
	'mingo@kernel.org', 'peterz@infradead.org',
	'juri.lelli@redhat.com',
	'vincent.guittot@linaro.org'
  Cc: 'dietmar.eggemann@arm.com', 'rostedt@goodmis.org',
	'bsegall@google.com', 'mgorman@suse.de',
	'bristot@redhat.com',
	'linux-kernel@vger.kernel.org'

Hello.

I found that when I run getrusage(RUSAGE_THREAD) on a tickless CPU, the utime and stime I get are less than the actual time, unlike when I run getrusage(RUSAGE_SELF) on a single thread.
This problem seems to be caused by the fact that se.sum_exec_runtime is not updated just before getting the information from 'current'.
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. On a tickless CPU, sum_exec_runtime is not updated periodically, so there seems to be a discrepancy with the actual time.
Therefore, I think I should include a process to update se.sum_exec_runtime just before getting the information from 'current' (as in other processes except RUSAGE_THREAD). I'm thinking of the following improvement.

@@ void getrusage(struct task_struct *p, int who, struct rusage *r)
        if (who == RUSAGE_THREAD) {
+               task_sched_runtime(current);
                task_cputime_adjusted(current, &utime, &stime);

Is there any possible problem with this?

Thanks.
Hitomi Hasegawa

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-08-31  4:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12  3:28 Utime and stime are less when getrusage (RUSAGE_THREAD) is executed on a tickless CPU hasegawa-hitomi
2021-05-18  7:59 ` hasegawa-hitomi
2021-05-18  8:23   ` Peter Zijlstra
2021-05-19  6:30     ` hasegawa-hitomi
2021-05-19  9:24       ` Peter Zijlstra
2021-05-19  9:28         ` Peter Zijlstra
2021-05-21  6:40           ` hasegawa-hitomi
2021-05-21  8:41             ` Mel Gorman
2021-06-16  2:27               ` hasegawa-hitomi
2021-06-16 12:31         ` Frederic Weisbecker
2021-06-16 12:54         ` Frederic Weisbecker
2021-06-22  6:49           ` hasegawa-hitomi
2021-06-28  2:36             ` hasegawa-hitomi
2021-06-28 14:13               ` Frederic Weisbecker
2021-07-21  8:24                 ` hasegawa-hitomi
2021-08-31  4:18                 ` hasegawa-hitomi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.