Skip to contentSkip to conversation

sched/rt: Do not account zero delta_exec in update_curr_rt()

PATCH In review Kirill Tkhai 2 participants 3 messages Jan 30, 2013 – Jan 31, 2013 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/rt: Do not account zero delta_exec in update_curr_rt()

There are several places of consecutive calls of dequeue_task_rt() and put_prev_task_rt() in the scheduler. For example, function rt_mutex_setprio() does it.

The both calls lead to update_curr_rt(), the second of it receives zeroed delta_exec. The only effective action in this case is call of sched_rt_avg_update(), which can change rq->age_stamp and rq->rt_avg. But it is possible in case of ""floating"" rq->clock. This fact is not reasonable to be accounted. Another actions do nothing.

CC Steven Rostedt <[email protected]>
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>
CC linux-rt-users <[email protected]>
---
 kernel/sched/rt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/rt.c +2 -2
index 4e8f0f4..c6d7993 100644
@@ -925,8 +925,8 @@ static void update_curr_rt(struct rq *rq)
 		return;
 
 	delta_exec = rq->clock_task - curr->se.exec_start;
-	if (unlikely((s64)delta_exec < 0))
-		delta_exec = 0;
+	if (unlikely((s64)delta_exec <= 0))
+		return;
 
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Kirill Tkhai

There are several places of consecutive calls of dequeue_task_rt() and put_prev_task_rt() in the scheduler. For example, function rt_mutex_setprio() does it.

The both calls lead to update_curr_rt(), the second of it receives zeroed delta_exec. The only effective action in this case is call of sched_rt_avg_update(), which can change rq->age_stamp and rq->rt_avg. But it is possible in case of ""floating"" rq->clock. This fact is not reasonable to be accounted. Another actions do nothing.

-- Steve

Quoted 21 lines
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>
CC linux-rt-users <[email protected]>
---
 kernel/sched/rt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/rt.c +2 -2
index 4e8f0f4..c6d7993 100644
@@ -925,8 +925,8 @@ static void update_curr_rt(struct rq *rq)
 		return;
 
 	delta_exec = rq->clock_task - curr->se.exec_start;
-	if (unlikely((s64)delta_exec < 0))
-		delta_exec = 0;
+	if (unlikely((s64)delta_exec <= 0))
+		return;
 
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));
#2 lore raw
In reply to Kirill Tkhai
Commit-ID:  fc79e240be5aa379dd36a62158be5a5ee0e4aec7
Gitweb:     http://git.kernel.org/tip/fc79e240be5aa379dd36a62158be5a5ee0e4aec7
Author:     Kirill Tkhai <[email protected]>
AuthorDate: Wed, 30 Jan 2013 16:50:36 +0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 31 Jan 2013 10:31:13 +0100

sched/rt: Do not account zero delta_exec in update_curr_rt()

There are several places of consecutive calls of dequeue_task_rt() and put_prev_task_rt() in the scheduler. For example, function rt_mutex_setprio() does it.

The both calls lead to update_curr_rt(), the second of it receives zeroed delta_exec. The only effective action in this case is call of sched_rt_avg_update(), which can change rq->age_stamp and rq->rt_avg. But it is possible in case of ""floating"" rq->clock. This fact is not reasonable to be accounted. Another actions do nothing.

---
 kernel/sched/rt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/rt.c +2 -2
index 2f69ca9..94abca4 100644
@@ -925,8 +925,8 @@ static void update_curr_rt(struct rq *rq)
 		return;
 
 	delta_exec = rq->clock_task - curr->se.exec_start;
-	if (unlikely((s64)delta_exec < 0))
-		delta_exec = 0;
+	if (unlikely((s64)delta_exec <= 0))
+		return;
 
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));