lkml.org 
[lkml]   [2009]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH] timer: provide microaccounting for iowait in addition to idle time
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.



\
 
 \ /
  Last update: 2009-09-24 18:03    [W:0.040 / U:0.532 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site