From: Viresh Kumar <viresh.kumar@linaro.org>
To: tglx@linutronix.de
Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org,
fweisbec@gmail.com, arvind.chauhan@arm.com,
preeti@linux.vnet.ibm.com, khilman@linaro.org,
Viresh Kumar <viresh.kumar@linaro.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: [RFC 4/7] sched: don't check for active hrtimer after adding it
Date: Wed, 9 Jul 2014 12:25:36 +0530 [thread overview]
Message-ID: <9c72a8d137cfca4e67848a7bf9dc9942eea7452b.1404888801.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1404888801.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1404888801.git.viresh.kumar@linaro.org>
hrtimer_start*() family never fails to enqueue a hrtimer to a clock-base. The
only special case is when the hrtimer was in past. If it is getting enqueued to
local CPUs's clock-base, we raise a softirq and exit, else we handle that on
next interrupt on remote CPU.
At several places in the kernel, we try to make sure if hrtimer was added
properly or not by calling hrtimer_active(), like:
hrtimer_start(timer, expires, mode);
if (hrtimer_active(timer)) {
/* Added successfully */
} else {
/* Was added in the past */
}
As hrtimer_start*() never fails, hrtimer_active() is guaranteed to return '1'.
So, there is no point calling hrtimer_active().
Also this is done in while loop at several places, which isn't required anymore.
This patch updates sched core to get this fixed.
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
kernel/sched/core.c | 20 +++++++++-----------
kernel/sched/deadline.c | 2 +-
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3bdf01b..4a6ef8d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -111,19 +111,17 @@ void start_bandwidth_timer(struct hrtimer *period_timer, ktime_t period)
unsigned long delta;
ktime_t soft, hard, now;
- for (;;) {
- if (hrtimer_active(period_timer))
- break;
+ if (hrtimer_active(period_timer))
+ return;
- now = hrtimer_cb_get_time(period_timer);
- hrtimer_forward(period_timer, now, period);
+ now = hrtimer_cb_get_time(period_timer);
+ hrtimer_forward(period_timer, now, period);
- soft = hrtimer_get_softexpires(period_timer);
- hard = hrtimer_get_expires(period_timer);
- delta = ktime_to_ns(ktime_sub(hard, soft));
- __hrtimer_start_range_ns(period_timer, soft, delta,
- HRTIMER_MODE_ABS_PINNED, 0);
- }
+ soft = hrtimer_get_softexpires(period_timer);
+ hard = hrtimer_get_expires(period_timer);
+ delta = ktime_to_ns(ktime_sub(hard, soft));
+ __hrtimer_start_range_ns(period_timer, soft, delta,
+ HRTIMER_MODE_ABS_PINNED, 0);
}
DEFINE_MUTEX(sched_domains_mutex);
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index fc4f98b1..eeb6786 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -484,7 +484,7 @@ static int start_dl_timer(struct sched_dl_entity *dl_se, bool boosted)
__hrtimer_start_range_ns(&dl_se->dl_timer, soft,
range, HRTIMER_MODE_ABS, 0);
- return hrtimer_active(&dl_se->dl_timer);
+ return 1;
}
/*
--
2.0.0.rc2
next prev parent reply other threads:[~2014-07-09 6:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-09 6:55 [RFC 0/7] hrtimer: drop active hrtimer checks " Viresh Kumar
2014-07-09 6:55 ` [RFC 1/7] hrtimer: Warn if hrtimer_start*() failed to enqueue hrtimer Viresh Kumar
2014-07-09 22:21 ` Frederic Weisbecker
2014-07-09 23:58 ` Thomas Gleixner
2014-07-09 6:55 ` [RFC 2/7] hrtimer: don't check for active hrtimer after adding it Viresh Kumar
2014-07-09 10:34 ` Chris Redpath
2014-07-09 15:25 ` Viresh Kumar
2014-07-09 6:55 ` [RFC 3/7] tick: " Viresh Kumar
2014-07-09 6:55 ` Viresh Kumar [this message]
2014-07-09 6:55 ` [RFC 5/7] futex: " Viresh Kumar
2014-07-09 6:55 ` [RFC 6/7] rtmutex: " Viresh Kumar
2014-07-09 6:55 ` [RFC 7/7] net: " Viresh Kumar
2014-07-09 10:32 ` Chris Redpath
2014-07-09 10:44 ` Viresh Kumar
2014-07-09 10:48 ` Chris Redpath
2014-07-09 15:23 ` Viresh Kumar
2014-07-09 21:30 ` [RFC 0/7] hrtimer: drop active hrtimer checks " Thomas Gleixner
2014-07-10 1:34 ` Frederic Weisbecker
2014-07-14 4:41 ` Viresh Kumar
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=9c72a8d137cfca4e67848a7bf9dc9942eea7452b.1404888801.git.viresh.kumar@linaro.org \
--to=viresh.kumar@linaro.org \
--cc=arvind.chauhan@arm.com \
--cc=fweisbec@gmail.com \
--cc=khilman@linaro.org \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=preeti@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/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®