lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 24 Sep 2009 18:00:51 +0200
From:	Martin Schwidefsky <schwidefsky@...ibm.com>
To:	Arjan van de Ven <arjan@...radead.org>
Cc:	linux-kernel@...r.kernel.org, mingo@...e.hu, peterz@...radead.org,
	tglx@...x.de
Subject: Re: [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@...radead.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.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ