lkml.org 
[lkml]   [2013]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/5] sched: Refactor iowait accounting
On Sat, Oct 19, 2013 at 05:35:35PM +0200, Peter Zijlstra wrote:
> On Sat, Oct 19, 2013 at 05:17:20PM +0200, Frederic Weisbecker wrote:
> > +u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)
> > +{
> > + ktime_t iowait, delta = { .tv64 = 0 };
> > + struct rq *rq = cpu_rq(cpu);
> > + ktime_t now = ktime_get();
> > + unsigned int seq;
> > +
> > + do {
> > + seq = read_seqbegin(&rq->iowait_lock);
> > + if (rq->nr_iowait)
> > + delta = ktime_sub(now, rq->iowait_start);
> > + iowait = ktime_add(rq->iowait_time, delta);
> > + } while (read_seqretry(&rq->iowait_lock, seq));
> > +
> > + if (last_update_time)
> > + *last_update_time = ktime_to_us(now);
> > +
> > + return ktime_to_us(iowait);
> > +}
> > +EXPORT_SYMBOL_GPL(get_cpu_iowait_time_us);
> > +
> > +static void cpu_iowait_start(struct rq *rq)
> > +{
> > + write_seqlock(&rq->iowait_lock);
> > + if (!rq->nr_iowait++)
> > + rq->iowait_start = ktime_get();
> > + write_sequnlock(&rq->iowait_lock);
> > +}
> > +
> > +static void cpu_iowait_end(struct rq *rq)
> > +{
> > + ktime_t delta;
> > + write_seqlock(&rq->iowait_lock);
> > + if (!--rq->nr_iowait) {
> > + delta = ktime_sub(ktime_get(), rq->iowait_start);
> > + rq->iowait_time = ktime_add(rq->iowait_time, delta);
> > + }
> > + write_sequnlock(&rq->iowait_lock);
> > +}
>
> Yeah, so using ktime_get() for this is completely insane ;-)

Woops, yeah I clearly overlooked that while moving the code :)
local_clock() should be fine.

>
> I just had a look at delayacct; wth wrote that crap; that too uses
> gtod.

I can't find where it does that. kernel/delayacct.c doesn't seem to at least.


\
 
 \ /
  Last update: 2013-10-19 18:21    [W:0.770 / U:2.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site