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: <52DE1883.2070304@linux.vnet.ibm.com>
Date:	Tue, 21 Jan 2014 14:49:39 +0800
From:	Michael wang <wangyun@...ux.vnet.ibm.com>
To:	Alex Shi <alex.shi@...aro.org>, mingo@...hat.com,
	peterz@...radead.org, morten.rasmussen@....com,
	vincent.guittot@...aro.org, daniel.lezcano@...aro.org,
	efault@....de
CC:	linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH 1/2] sched/update_avg: avoid negative time

Hi, Alex

On 01/21/2014 01:33 PM, Alex Shi wrote:
> rq->avg_idle try to reflect the average idle time between the cpu idle
> and first wakeup. But in the function, it maybe get a negative value
> if old avg_idle is too small. Then this negative value will be double
> counted in next time calculation. Guess that is not the original purpose,
> so recalibrate it to zero.
> 
> Signed-off-by: Alex Shi <alex.shi@...aro.org>
> ---
>  kernel/sched/core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 30eb011..af9121c6 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1358,6 +1358,9 @@ static void update_avg(u64 *avg, u64 sample)
>  {
>  	s64 diff = sample - *avg;
>  	*avg += diff >> 3;
> +
> +	if (*avg < 0)
> +		*avg = 0;

This seems like won't happen...

if 'diff' is negative, it's absolute value won't bigger than '*avg', not
to mention we only use 1/8 of it.

Regards,
Michael Wang

>  }
>  #endif
> 

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