From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: Arjan van de Ven <arjan@infradead.org>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
peterz@infradead.org, tglx@tglx.de
Subject: Re: [RFC PATCH] timer: provide microaccounting for iowait in addition to idle time
Date: Thu, 24 Sep 2009 18:00:51 +0200 [thread overview]
Message-ID: <20090924180051.7792f285@mschwide.boeblingen.de.ibm.com> (raw)
In-Reply-To: <20090924133938.6d71db13@infradead.org>
On Thu, 24 Sep 2009 13:39:38 +0200
Arjan van de Ven <arjan@infradead.org> wrote:
> @@ -190,19 +195,61 @@ static ktime_t tick_nohz_start_idle(struct tick_sched *ts)
> u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time)
> {
> struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
> + ktime_t now, delta;
>
> if (!tick_nohz_enabled)
> return -1;
>
> - if (ts->idle_active)
> - *last_update_time = ktime_to_us(ts->idle_lastupdate);
> - else
> - *last_update_time = ktime_to_us(ktime_get());
> + now = ktime_get();
> + if (ts->idle_active) {
> + delta = ktime_sub(now, ts->idle_entrytime);
> + ts->idle_lastupdate = now;
> + ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
> + if (nr_iowait_cpu()>0)
> + ts->iowait_sleeptime = ktime_add(ts->iowait_sleeptime, delta);
> + ts->idle_entrytime = now;
> + }
> +
> + if (last_update_time) {
> + if (ts->idle_active)
> + *last_update_time = ktime_to_us(ts->idle_lastupdate);
> + else
> + *last_update_time = ktime_to_us(ktime_get());
> + }
>
> return ktime_to_us(ts->idle_sleeptime);
> }
> EXPORT_SYMBOL_GPL(get_cpu_idle_time_us);
Is the second ktime_get() call really necessary? Why can't "now" be reused?
> +u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)
> +{
> + struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
> + ktime_t now, delta;
> +
> + if (!tick_nohz_enabled)
> + return -1;
> +
> + now = ktime_get();
> + if (ts->idle_active) {
> + delta = ktime_sub(now, ts->idle_entrytime);
> + ts->idle_lastupdate = now;
> + ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
> + if (nr_iowait_cpu()>0)
> + ts->iowait_sleeptime = ktime_add(ts->iowait_sleeptime, delta);
> + ts->idle_entrytime = now;
> + }
> +
> + if (last_update_time) {
> + if (ts->idle_active)
> + *last_update_time = ktime_to_us(ts->idle_lastupdate);
> + else
> + *last_update_time = ktime_to_us(ktime_get());
> + }
> +
> + return ktime_to_us(ts->iowait_sleeptime);
> +}
> +EXPORT_SYMBOL_GPL(get_cpu_iowait_time_us);
Same here.
But except for the superfluous ktime_gets I have no objections.
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
prev parent reply other threads:[~2009-09-24 16:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-24 11:39 Arjan van de Ven
2009-09-24 16:00 ` Martin Schwidefsky [this message]
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=20090924180051.7792f285@mschwide.boeblingen.de.ibm.com \
--to=schwidefsky@de.ibm.com \
--cc=arjan@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=tglx@tglx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®