Re: [PATCH] docs/scheduler: Change unit of cpu_time and rq_time to nanoseconds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
> > 
> > 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.



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux