Skip to contentSkip to conversation

sched/deadline: Remove if statement before clearing throttle and yielded

RFC PATCH In review Steven Rostedt 4 participants 4 messages May 10, 2017 – May 11, 2017 Scheduler

lore
Share & tools
lore

Steven Rostedt

author reviewer
#0 lore raw

RFC PATCH 1/1 sched/deadline: Remove if statement before clearing throttle and yielded

[
This is an RFC as I didn't run any benchmarks. It just seemed a bit weird to me that we would add such a check instead of just clearing these variables out regardless.
]

The function replenish_dl_entity() clears dl_throttled and dl_yielded, but checks first if they are set before doing so. As these variables are in the same cache locale of other variables being modified, there's no advantage in checking if they are set before clearing them. But having the compare takes slots away from the branch prediction.

---

kernel/sched/deadline.c +2 -4
index a2ce590..9748d33 100644
@@ -423,10 +423,8 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se,
 		dl_se->runtime = pi_se->dl_runtime;
 	}
 
-	if (dl_se->dl_yielded)
-		dl_se->dl_yielded = 0;
-	if (dl_se->dl_throttled)
-		dl_se->dl_throttled = 0;
+	dl_se->dl_yielded = 0;
+	dl_se->dl_throttled = 0;
 }
 
 /*
#1 lore raw

Hi,

Quoted 19 lines · Steven Rostedt

[
This is an RFC as I didn't run any benchmarks. It just seemed a bit weird to me that we would add such a check instead of just clearing these variables out regardless.
]

The function replenish_dl_entity() clears dl_throttled and dl_yielded, but checks first if they are set before doing so. As these variables are in the same cache locale of other variables being modified, there's no advantage in checking if they are set before clearing them. But having the compare takes slots away from the branch prediction.

---

kernel/sched/deadline.c +0 -0
index a2ce590..9748d33 100644

kernel/sched/deadline.c static void replenish_dl_entity(struct sched_dl_entity *dl_se, · line 428

Quoted 10 lines
kernel/sched/deadline.c +2 -4
@@ -423,10 +423,8 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se,
 		dl_se->runtime = pi_se->dl_runtime;
 	}
 
-	if (dl_se->dl_yielded)
-		dl_se->dl_yielded = 0;
-	if (dl_se->dl_throttled)
-		dl_se->dl_throttled = 0;
+	dl_se->dl_yielded = 0;
+	dl_se->dl_throttled = 0;
 }

Looks good to me.

Peter, any particular reason why you wanted to first check the values?

Best,

- Juri

#2 lore raw
Quoted 3 lines · Juri Lelli

Looks good to me.

Peter, any particular reason why you wanted to first check the values?

+1

-- Daniel

maintainer
#3 lore raw
In reply to Juri Lelli
Quoted 11 lines · Juri Lelli

kernel/sched/deadline.c static void replenish_dl_entity(struct sched_dl_entity *dl_se, · line 428

Quoted 7 lines
kernel/sched/deadline.c +2 -4
-	if (dl_se->dl_yielded)
-		dl_se->dl_yielded = 0;
-	if (dl_se->dl_throttled)
-		dl_se->dl_throttled = 0;
+	dl_se->dl_yielded = 0;
+	dl_se->dl_throttled = 0;
 }

Looks good to me.

Peter, any particular reason why you wanted to first check the values?

No idea, could be general paranoia on unconditional writes or something.