From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965035AbcAUJXc (ORCPT ); Thu, 21 Jan 2016 04:23:32 -0500 Received: from andre.telenet-ops.be ([195.130.132.53]:36388 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756718AbcAUJX3 (ORCPT ); Thu, 21 Jan 2016 04:23:29 -0500 To: a.p.zijlstra@chello.nl Cc: linux-kernel@vger.kernel.org From: Vik Heyndrickx Subject: [PATCH] sched: loadavg 0.00, 0.01, 0.05 on idle Message-ID: <56A0A38D.4040900@veribox.net> Date: Thu, 21 Jan 2016 10:23:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Systems show a minimal load average of 0.00, 0.01, 0.05 even when they have no load at all. Uptime and /proc/loadavg on all systems with kernels released during the last five years up until kernel version 4.4, show a 5- and 15-minute minimum loadavg of 0.01 and 0.05 respectively. This should be 0.00 on idle systems, but the way the kernel calculates this value prevents it from getting lower than the mentioned values. Likewise but not as obviously noticeable, a fully loaded system with no processes waiting, shows a maximum 1/5/15 loadavg of 1.00, 0.99, 0.95 (multiplied by number of cores). By removing the single code line that performed a rounding on the internally kept load value, effectively returning this function calc_load to its state it had before, the visualization problem is completely fixed. The modified code was tested on nohz=off and nohz kernels. It was tested on vanilla kernel 4.4 and on centos 7.1 kernel 3.10.0-327. It was tested on single, dual, and octal cores system. It was tested on virtual hosts and bare hardware. No unwanted effects have been observed, and the problems that the patch intended to fix were indeed gone. The following patch is for kernel version 4.x . In kernel 3.x, the affected code was in core.c instead of loadavg.c Signed-off-by: Vik Heyndrickx --- linux-4.4-org/kernel/sched/loadavg.c 2016-01-21 09:11:15 +0100 +++ linux-4.4/kernel/sched/loadavg.c 2016-01-21 09:11:31 +0100 @@ -101,7 +101,6 @@ calc_load(unsigned long load, unsigned l { load *= exp; load += active * (FIXED_1 - exp); - load += 1UL << (FSHIFT - 1); return load >> FSHIFT; }