public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Boqun Feng <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org,
	hpa@zytor.com, torvalds@linux-foundation.org,
	boqun.feng@gmail.com, linux-kernel@vger.kernel.org,
	srikar@linux.vnet.ibm.com
Subject: [tip:sched/core] sched/fair: Clean up the __sched_period() code
Date: Mon, 6 Jul 2015 23:49:43 -0700	[thread overview]
Message-ID: <tip-8e2b0bf397279878babcb39b021edcafe7c945eb@git.kernel.org> (raw)
In-Reply-To: <1435847152-29543-1-git-send-email-boqun.feng@gmail.com>

Commit-ID:  8e2b0bf397279878babcb39b021edcafe7c945eb
Gitweb:     http://git.kernel.org/tip/8e2b0bf397279878babcb39b021edcafe7c945eb
Author:     Boqun Feng <boqun.feng@gmail.com>
AuthorDate: Thu, 2 Jul 2015 22:25:52 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 7 Jul 2015 08:46:10 +0200

sched/fair: Clean up the __sched_period() code

Since commit:

  4bf0b77158 ("sched: remove do_div() from __sched_slice()")

... the logic of __sched_period() can be implemented as a single if-else
without any local variables, so this patch cleans it up with an if-else
statement, which expresses the function's logic straightforwardly.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1435847152-29543-1-git-send-email-boqun.feng@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/fair.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a53a610..03ea05b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -616,15 +616,10 @@ static inline u64 calc_delta_fair(u64 delta, struct sched_entity *se)
  */
 static u64 __sched_period(unsigned long nr_running)
 {
-	u64 period = sysctl_sched_latency;
-	unsigned long nr_latency = sched_nr_latency;
-
-	if (unlikely(nr_running > nr_latency)) {
-		period = sysctl_sched_min_granularity;
-		period *= nr_running;
-	}
-
-	return period;
+	if (unlikely(nr_running > sched_nr_latency))
+		return nr_running * sysctl_sched_min_granularity;
+	else
+		return sysctl_sched_latency;
 }
 
 /*

      parent reply	other threads:[~2015-07-07  6:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-02 14:25 [PATCH] sched/fair: code clean up for __sched_period() Boqun Feng
2015-07-06 12:41 ` Boqun Feng
2015-07-06 12:49   ` Peter Zijlstra
2015-07-06 12:53     ` Ingo Molnar
2015-07-06 13:47       ` Boqun Feng
2015-07-06 13:37     ` Boqun Feng
2015-07-06 15:51 ` [tip:sched/core] sched/fair: Clean up the __sched_period() code tip-bot for Boqun Feng
2015-07-07  6:49 ` tip-bot for Boqun Feng [this message]

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=tip-8e2b0bf397279878babcb39b021edcafe7c945eb@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=boqun.feng@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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