mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joel Fernandes <joelaf@google.com>
To: linux-kernel@vger.kernel.org
Cc: Joel Fernandes <joelaf@google.com>, Paul Turner <pjt@google.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Juri Lelli <Juri.Lelli@arm.com>,
	Patrick Bellasi <patrick.bellasi@arm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: [PATCH] sched: fair: Improve PELT decay_load calculation comments
Date: Fri, 10 Mar 2017 12:23:41 -0800	[thread overview]
Message-ID: <20170310202341.11449-1-joelaf@google.com> (raw)

The PELT decay_load comments are a bit confusing, first of all
the 1/2^N should be (1/2)^N so that the reader doesn't get confused.
Secondly, the y^N splitting into a 2-part decay factor deserves
a better explanation. This patch improves the comments.

Cc: Paul Turner <pjt@google.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Juri Lelli <Juri.Lelli@arm.com>
Cc: Patrick Bellasi <patrick.bellasi@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Joel Fernandes <joelaf@google.com>
---
 kernel/sched/fair.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6559d197e08a..1e1f2d77751e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2761,11 +2761,15 @@ static __always_inline u64 decay_load(u64 val, u64 n)
 	local_n = n;
 
 	/*
-	 * As y^PERIOD = 1/2, we can combine
-	 *    y^n = 1/2^(n/PERIOD) * y^(n%PERIOD)
-	 * With a look-up table which covers y^n (n<PERIOD)
-	 *
-	 * To achieve constant time decay_load.
+	 * As y^PERIOD = 1/2, we can decay the load by 1/2
+	 * for n/PERIOD number of PERIOD sized instances. Then
+	 * we decay by the remaining windows in the final PERIOD,
+	 * that is n%PERIOD. In other words, the decay factor
+	 * y^N in terms of PERIOD becomes:
+	 *    y^n = (1/2)^(n/PERIOD) * y^(n%PERIOD).
+	 * Since now we only need to compute powers of y where
+	 * n < PERIOD, we use a look-up table for y^N (N<PERIOD).
+	 * This helps achieve constant time decay_load.
 	 */
 	if (unlikely(local_n >= LOAD_AVG_PERIOD)) {
 		val >>= local_n / LOAD_AVG_PERIOD;
-- 
2.12.0.246.ga2ecc84866-goog

             reply	other threads:[~2017-03-10 20:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10 20:23 Joel Fernandes [this message]
2017-03-22 14:16 ` Peter Zijlstra
2017-03-22 16:35   ` Joel Fernandes
2017-03-22 17:02     ` Peter Zijlstra
2017-03-22 19:19       ` Joel Fernandes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170310202341.11449-1-joelaf@google.com \
    --to=joelaf@google.com \
    --cc=Juri.Lelli@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=patrick.bellasi@arm.com \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®