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: <D958900912E20642BCBC71664EFECE3E6D123A0AFF@BGMAIL02.nvidia.com>
Date:	Thu, 27 Oct 2011 23:12:37 +0530
From:	Venu Byravarasu <vbyravarasu@...dia.com>
To:	"Rafael J. Wysocki" <rjw@...k.pl>
CC:	"pavel@....cz" <pavel@....cz>,
	"len.brown@...el.com" <len.brown@...el.com>,
	"gregkh@...e.de" <gregkh@...e.de>,
	"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Alan Stern <stern@...land.harvard.edu>,
	Peter De Schrijver <pdeschrijver@...dia.com>
Subject: RE: [PATCH] PM: fix calculation mistake in roll-over cases

-----Original Message-----
From: Rafael J. Wysocki [mailto:rjw@...k.pl] 
Sent: Tuesday, October 25, 2011 6:39 PM
To: Venu Byravarasu
Cc: pavel@....cz; len.brown@...el.com; gregkh@...e.de; linux-pm@...r.kernel.org; linux-kernel@...r.kernel.org; Alan Stern
Subject: Re: [PATCH] PM: fix calculation mistake in roll-over cases

On Tuesday, October 25, 2011, vbyravarasu@...dia.com wrote:
> From: venu byravarasu <vbyravarasu@...dia.com>
> 
> In case of jiffies roll over, delta is made zero.
> Hence fixing it, after taking roll over into consideration.
> 
> Signed-off-by: venu byravarasu <vbyravarasu@...dia.com>
> ---
> When jiffies roll over, calculation of time spent in the
> current state (stored in variable 'delta') is incorrect.
> Hence fixing it, after taking roll over into consideration.
> 
>  drivers/base/power/runtime.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> index 1079e03..bd93fb0 100644
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -30,12 +30,13 @@ static int rpm_suspend(struct device *dev, int rpmflags);
>  void update_pm_runtime_accounting(struct device *dev)
>  {
>  	unsigned long now = jiffies;
> -	int delta;
> +	unsigned long delta;
> +	unsigned long max_num = ~0;
>  
>  	delta = now - dev->power.accounting_timestamp;
>  
> -	if (delta < 0)
> -		delta = 0;
> +	if (now < dev->power.accounting_timestamp)
> +		delta = max_num - dev->power.accounting_timestamp + now;
>  
>  	dev->power.accounting_timestamp = now;

> I'm not sure how this is supposed to improve things.  Care to give more
> details?
Below two items were taken care with this change:
1. Value of now is jiffies which is unsigned long.
As it is being stored in delta of 'int' type, for all values of now > 0x80000000,
Delta will be made 0 with the original if condition.
By changing delta to unsigned long, this is taken care.

2. Even if delta is made unsigned, in cases of jiffies roll over, delta will be zero.
That is also being taken care with the code added as part of if condition.

Plz let me know if you still have any questions.
> Rafael
Thanks,
Venu
--
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