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] [thread-next>] [day] [month] [year] [list]
Message-ID: <1405931858.4939.30.camel@chaos.site>
Date:	Mon, 21 Jul 2014 10:37:38 +0200
From:	Jean Delvare <jdelvare@...e.de>
To:	Thomas Gleixner <tglx@...utronix.de>,
	"Darrick J. Wong" <darrick.wong@...cle.com>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	John Stultz <john.stultz@...aro.org>,
	Peter Zijlstra <peterz@...radead.org>
Subject: Re: [patch V2 40/64] hwmon: ibmaem: Use ktime_get_ns()

Hi Thomas,

Le Wednesday 16 July 2014 à 21:04 +0000, Thomas Gleixner a écrit :
> Using the wall clock time for delta time calculations is wrong to
> begin with because wall clock time can be set from userspace and NTP.
> Such data wants to be based on clock monotonic.
> 
> The calcuations also are done on a nanosecond basis. Use the

Typo: calculations

> nanoseconds based interface right away.
> 
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> Cc: Jean Delvare <jdelvare@...e.de>
> ---
>  drivers/hwmon/ibmaem.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> Index: tip/drivers/hwmon/ibmaem.c
> ===================================================================
> --- tip.orig/drivers/hwmon/ibmaem.c
> +++ tip/drivers/hwmon/ibmaem.c
> @@ -842,11 +842,10 @@ static ssize_t aem_show_power(struct dev
>  	struct aem_data *data = dev_get_drvdata(dev);
>  	u64 before, after, delta, time;
>  	signed long leftover;
> -	struct timespec b, a;
>  
>  	mutex_lock(&data->lock);
>  	update_aem_energy_one(data, attr->index);
> -	getnstimeofday(&b);
> +	time = ktime_get_ns();
>  	before = data->energy[attr->index];
>  
>  	leftover = schedule_timeout_interruptible(
> @@ -858,11 +857,10 @@ static ssize_t aem_show_power(struct dev
>  	}
>  
>  	update_aem_energy_one(data, attr->index);
> -	getnstimeofday(&a);
> +	time = ktime_get_ns() - time;
>  	after = data->energy[attr->index];
>  	mutex_unlock(&data->lock);
>  
> -	time = timespec_to_ns(&a) - timespec_to_ns(&b);
>  	delta = (after - before) * UJ_PER_MJ;
>  
>  	return sprintf(buf, "%llu\n",

I'm not familiar with the driver and I can't test it, and I'm not
familiar with kernel timekeeping either. All I can say is that the
changes look reasonable and good.

Acked-by: Jean Delvare <jdelvare@...e.de>

Darrick, maybe you want to comment or test?

-- 
Jean Delvare
SUSE L3 Support

--
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