* Re: [PATCH] docs/scheduler: Change unit of cpu_time and rq_time to nanoseconds
[not found] <1649410266-32360-1-git-send-email-brookxu.cn@gmail.com>
@ 2022-04-08 12:45 ` Matthew Wilcox
2022-04-08 13:43 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2022-04-08 12:45 UTC (permalink / raw)
To: brookxu.cn
Cc: corbet, linux-doc, linux-kernel, Ingo Molnar, Peter Zijlstra,
Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Daniel Bristot de Oliveira
On Fri, Apr 08, 2022 at 05:31:06PM +0800, brookxu.cn wrote:
> From: Chunguang Xu <brookxu@tencent.com>
>
> In the current implementation, cpu_time and rq_time should be
> in nanoseconds, so this document needs to be modified.
I agree that this is wrong, but we shouldn't be changing the units
of measurement reported to userspace without changing the schedstats
version. I suspect this was an inadvertent change, and we should be
converting from sched_clock() time (~= ns) to jiffies in show_schedstat().
Adding scheduler experts.
> Signed-off-by: Chunguang Xu <brookxu@tencent.com>
> ---
> Documentation/scheduler/sched-stats.rst | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/scheduler/sched-stats.rst b/Documentation/scheduler/sched-stats.rst
> index dd9b99a..9078a27 100644
> --- a/Documentation/scheduler/sched-stats.rst
> +++ b/Documentation/scheduler/sched-stats.rst
> @@ -56,9 +56,9 @@ Next two are try_to_wake_up() statistics:
>
> Next three are statistics describing scheduling latency:
>
> - 7) sum of all time spent running by tasks on this processor (in jiffies)
> + 7) sum of all time spent running by tasks on this processor (in nanoseconds)
> 8) sum of all time spent waiting to run by tasks on this processor (in
> - jiffies)
> + nanoseconds)
> 9) # of timeslices run on this cpu
>
>
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] docs/scheduler: Change unit of cpu_time and rq_time to nanoseconds
2022-04-08 12:45 ` [PATCH] docs/scheduler: Change unit of cpu_time and rq_time to nanoseconds Matthew Wilcox
@ 2022-04-08 13:43 ` Peter Zijlstra
2022-04-16 8:36 ` Jonathan Corbet
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2022-04-08 13:43 UTC (permalink / raw)
To: Matthew Wilcox
Cc: brookxu.cn, corbet, linux-doc, linux-kernel, Ingo Molnar,
Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Daniel Bristot de Oliveira
On Fri, Apr 08, 2022 at 01:45:35PM +0100, Matthew Wilcox wrote:
> On Fri, Apr 08, 2022 at 05:31:06PM +0800, brookxu.cn wrote:
> > From: Chunguang Xu <brookxu@tencent.com>
> >
> > In the current implementation, cpu_time and rq_time should be
> > in nanoseconds, so this document needs to be modified.
>
> I agree that this is wrong, but we shouldn't be changing the units
> of measurement reported to userspace without changing the schedstats
> version. I suspect this was an inadvertent change, and we should be
> converting from sched_clock() time (~= ns) to jiffies in show_schedstat().
> Adding scheduler experts.
Seems to have happend at 425e0968a25f ("sched: move code into
kernel/sched_stats.h").
Before that we have:
-static inline void
-rq_sched_info_depart(struct rq *rq, unsigned long delta_jiffies)
-{
- if (rq)
- rq->rq_sched_info.cpu_time += delta_jiffies;
-}
-static inline void sched_info_depart(struct task_struct *t)
-{
- unsigned long delta_jiffies = jiffies - t->sched_info.last_arrival;
-
- t->sched_info.cpu_time += delta_jiffies;
- rq_sched_info_depart(task_rq(t), delta_jiffies);
-}
afterwards we have:
+static inline void sched_info_depart(struct task_struct *t)
+{
+ unsigned long long delta = sched_clock() - t->sched_info.last_arrival;
+
+ t->sched_info.cpu_time += delta;
+ rq_sched_info_depart(task_rq(t), delta);
+}
And that's 15 years and at least one SCHEDSTAT_VERSION ago (although
this change itself didn't bump the version).
So I'm thinking we can update the documentation and forget about this.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] docs/scheduler: Change unit of cpu_time and rq_time to nanoseconds
2022-04-08 13:43 ` Peter Zijlstra
@ 2022-04-16 8:36 ` Jonathan Corbet
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Corbet @ 2022-04-16 8:36 UTC (permalink / raw)
To: Peter Zijlstra, Matthew Wilcox
Cc: brookxu.cn, linux-doc, linux-kernel, Ingo Molnar, Juri Lelli,
Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
Mel Gorman, Daniel Bristot de Oliveira
Peter Zijlstra <peterz@infradead.org> writes:
> And that's 15 years and at least one SCHEDSTAT_VERSION ago (although
> this change itself didn't bump the version).
>
> So I'm thinking we can update the documentation and forget about this.
OK, I've applied the patch, thanks.
jon
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-16 8:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1649410266-32360-1-git-send-email-brookxu.cn@gmail.com>
2022-04-08 12:45 ` [PATCH] docs/scheduler: Change unit of cpu_time and rq_time to nanoseconds Matthew Wilcox
2022-04-08 13:43 ` Peter Zijlstra
2022-04-16 8:36 ` Jonathan Corbet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox