From: Andrew Morton <akpm@digeo.com>
To: William Lee Irwin III <wli@holomorphy.com>
Cc: linux-kernel@vger.kernel.org, riel@surriel.com, mingo@elte.hu,
pbadari@us.ibm.com
Subject: Re: idle time & iowait accounting
Date: Fri, 01 Nov 2002 19:35:36 -0800 [thread overview]
Message-ID: <3DC34808.A8FE6FAC@digeo.com> (raw)
In-Reply-To: 20021102031810.GA12891@holomorphy.com
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.
next prev parent reply other threads:[~2002-11-02 3:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-02 3:18 idle time & iowait accounting William Lee Irwin III
2002-11-02 3:35 ` Andrew Morton [this message]
2002-11-02 3:44 ` Rik van Riel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DC34808.A8FE6FAC@digeo.com \
--to=akpm@digeo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=pbadari@us.ibm.com \
--cc=riel@surriel.com \
--cc=wli@holomorphy.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.