Skip to contentSkip to conversation

sched/core: Remove useless hrtimer_active check

PATCH In review Daniel Lezcano 1 participant 2 messages Jun 19, 2018 – Jul 10, 2018 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/core: Remove useless hrtimer_active check

The function tick_clear() checks if the timer is active and in this case cancels the timer. However, hrtimer_cancel does the same check.

Perhaps, this test is made on purpose to skip some function calls for efficiency reasons but if it is not the case we can safely remove it.

---
 kernel/sched/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/sched/core.c +1 -2
index d155518..aa46aa6 100644
@@ -218,8 +218,7 @@ void update_rq_clock(struct rq *rq)
 
 static void hrtick_clear(struct rq *rq)
 {
-	if (hrtimer_active(&rq->hrtick_timer))
-		hrtimer_cancel(&rq->hrtick_timer);
+	hrtimer_cancel(&rq->hrtick_timer);
 }
 
 /*
Signature · 1 line
2.7.4
#1 lore raw
Quoted 16 lines · Daniel Lezcano

The function tick_clear() checks if the timer is active and in this case cancels the timer. However, hrtimer_cancel does the same check.

Perhaps, this test is made on purpose to skip some function calls for efficiency reasons but if it is not the case we can safely remove it.

---
 kernel/sched/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/sched/core.c +0 -0
index d155518..aa46aa6 100644

kernel/sched/core.c void update_rq_clock(struct rq *rq) · line 224

Quoted 9 lines
kernel/sched/core.c +1 -2
@@ -218,8 +218,7 @@ void update_rq_clock(struct rq *rq)
 
 static void hrtick_clear(struct rq *rq)
 {
-	if (hrtimer_active(&rq->hrtick_timer))
-		hrtimer_cancel(&rq->hrtick_timer);
+	hrtimer_cancel(&rq->hrtick_timer);
 }
 
 /*

May be not the patch of the century but just a gentle bump if it was lost by more important patchset review.

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog