lkml.org 
[lkml]   [2013]   [Oct]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/4] nohz: Synchronize sleep time stats with seqlock
On Tue, Oct 01, 2013 at 05:56:33PM +0200, Peter Zijlstra wrote:
>
> So what's wrong with something like:
>
> struct cpu_idletime {
> seqlock_t seqlock;
> unsigned long nr_iowait;
> u64 start;
> u64 idle_time,
> u64 iowait_time,
> } __cacheline_aligned_in_smp;
>
> DEFINE_PER_CPU(struct cpu_idletime, cpu_idletime);
>
> void io_schedule(void)
> {
> struct cpu_idletime *it = __raw_get_cpu_var(cpu_idletime);
>
> write_seqlock(&it->seqlock);
> if (!it->nr_iowait++)
> it->start = local_clock();
> write_sequnlock(&it->seqlock);
>
> current->in_iowait = 1;
> schedule();
> current->in_iowait = 0;
>
> write_seqlock(&it->seqlock);
> if (!--it->nr_iowait)
> it->iowait_time += local_clock() - it->start;
> write_sequnlock(&it->seqlock);
> }
>
> Afaict you don't need the preempt disable and atomic muck at all.

Yeah thinking more about it, the preempt disable was probably not
necessary. Now that's trading 2 atomics + 1 Lock/Unlock with 2 Lock/Unlock.

OTOH it computes iowait time seperately from idle time, so we probably don't
need to lock the idle time anymore.

Plus this solution is much much more simple. So if nobody sees a flaw there,
I'll try this.

Thanks.

>
> It will all get a little more complicated to deal with overlapping idle
> and iowait times, but the idea is the same.

Probably no big deal.


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