lkml.org 
[lkml]   [2002]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: idle time & iowait accounting
William Lee Irwin III wrote:
>
> ...
>
> +unsigned long nr_iowait(void)
> +{
> + unsigned long i, sum = 0;
> +
> + for (i = 0; i < NR_CPUS; ++i)
> + sum += atomic_read(&cpu_rq(i)->nr_iowait);
> +
> + return sum;
> +}
> +

We need to make a habit of checking cpu_online(i) in here. I'd rather
this consume 4 cachelines than 32, thanks ;)

Also, if we decide to allocate each CPU's per-cpu memory separately
any for-all-CPUs loop which uses per-cpu data MUST make this check,
else it'll oops.

Not applicable in this case, and alas the cpu iterator helper macros
(for_each_online_cpu(), etc) are currently AWOL, but...

> +void io_schedule(void)
> +{
> + struct runqueue *rq;
> + preempt_disable();
> + rq = this_rq();
> + atomic_inc(&rq->nr_iowait);
> + schedule();
> + atomic_dec(&rq->nr_iowait);
> + preempt_enable();
> +}

"scheduling while atomic". You'll need to reacquire the runqueue pointer
on waking up.

> +
> +void io_schedule_timeout(long timeout)
> +{
> + struct runqueue *rq;
> + preempt_disable();
> + rq = this_rq();
> + atomic_inc(&rq->nr_iowait);
> + schedule_timeout(timeout);
> + atomic_dec(&rq->nr_iowait);
> + preempt_enable();
> +}

And here too.

Apart from that, looks very good, thanks.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:30    [W:0.048 / U:0.868 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site