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: <45E7F92E.7090407@simon.arlott.org.uk>
Date:	Fri, 02 Mar 2007 10:15:10 +0000
From:	Simon Arlott <simon@...e.lp0.eu>
To:	akpm@...ux-foundation.org
CC:	Bill Irwin <bill.irwin@...cle.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	arjan@...ux.intel.com
Subject: Re: [PATCH (update 2)] timer: Run calc_load halfway through each
 round_jiffies second

Whenever jiffies is started at a multiple of 5*HZ or wraps, calc_load is 
run exactly on the second which is when tasks using round_jiffies will 
be scheduled to run. This has a bad effect on the load average, making 
it tend towards 1.00 if a task happens to run every time the load is 
being calculated.

This changes calc_load so that it updates load half a second after any 
tasks scheduled using round_jiffies.

Signed-off-by: Simon Arlott <simon@...e.lp0.eu>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Arjan van de Ven <arjan@...ux.intel.com>
---
This version starts count off at 0, since LOAD_FREQ + HZ/2 is no better 
than LOAD_FREQ, and avoids rounding it to a negative value.

 kernel/timer.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index cb1b86a..11ccfed 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1225,17 +1225,19 @@ EXPORT_SYMBOL(avenrun);
 static inline void calc_load(unsigned long ticks)
 {
 	unsigned long active_tasks; /* fixed-point */
-	static int count = LOAD_FREQ;
+	static int count = 0;
 
 	count -= ticks;
-	if (unlikely(count < 0)) {
+	if (unlikely(count <= 0)) {
 		active_tasks = count_active_tasks();
 		do {
 			CALC_LOAD(avenrun[0], EXP_1, active_tasks);
 			CALC_LOAD(avenrun[1], EXP_5, active_tasks);
 			CALC_LOAD(avenrun[2], EXP_15, active_tasks);
 			count += LOAD_FREQ;
-		} while (count < 0);
+		} while (count < HZ/2);
+
+		count = round_jiffies_relative(count + HZ/2) - HZ/2;
 	}
 }
 
-- 
1.5.0.1

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