Skip to contentSkip to conversation

sched_rt: don't start timer when rt bandwidth disabled

PATCH Superseded Hiroshi Shimamoto 2 participants 5 messages Feb 5, 2009 – Feb 6, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 sched_rt: don't start timer when rt bandwidth disabled

From: Hiroshi Shimamoto <[email protected]>

Impact: fix incorrect condition check

No need to start rt bandwidth timer when rt bandwidth is disabled.

---
 kernel/sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched.c +1 -1
index 1e965b7..4c03c88 100644
@@ -223,7 +223,7 @@ static void start_rt_bandwidth(struct rt_bandwidth *rt_b)
 {
 	ktime_t now;
 
-	if (rt_bandwidth_enabled() && rt_b->rt_runtime == RUNTIME_INF)
+	if (!rt_bandwidth_enabled() || rt_b->rt_runtime == RUNTIME_INF)
 		return;
 
 	if (hrtimer_active(&rt_b->rt_period_timer))
Signature · 1 line
1.6.1.2
#1 lore raw

PATCH 2/2 sched_rt: protect rt_rq->rt_time by rt_runtime_lock

From: Hiroshi Shimamoto <[email protected]>

Impact: fix possible race condition

rt_rq->rt_time should be protected.

---
 kernel/sched_rt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched_rt.c +2 -2
index 299d012..d7654a3 100644
@@ -496,10 +496,10 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
 		struct rq *rq = rq_of_rt_rq(rt_rq);
 
 		spin_lock(&rq->lock);
+		spin_lock(&rt_rq->rt_runtime_lock);
 		if (rt_rq->rt_time) {
 			u64 runtime;
 
-			spin_lock(&rt_rq->rt_runtime_lock);
 			if (rt_rq->rt_throttled)
 				balance_runtime(rt_rq);
 			runtime = rt_rq->rt_runtime;
@@ -510,9 +510,9 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
 			}
 			if (rt_rq->rt_time || rt_rq->rt_nr_running)
 				idle = 0;
-			spin_unlock(&rt_rq->rt_runtime_lock);
 		} else if (rt_rq->rt_nr_running)
 			idle = 0;
+		spin_unlock(&rt_rq->rt_runtime_lock);
 
 		if (enqueue)
 			sched_rt_rq_enqueue(rt_rq);
Signature · 1 line
1.6.1.2
#2 lore raw

Re: [PATCH 2/2] sched_rt: protect rt_rq->rt_time by rt_runtime_lock

Quoted 5 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: fix possible race condition

rt_rq->rt_time should be protected.

Don't think so, all we do is check the value for non-zero outside the lock, that should be ok.

If there's still a race, your changelog utterly fails to mention the race scenario.

Quoted 32 lines
---
 kernel/sched_rt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched_rt.c +2 -2
index 299d012..d7654a3 100644
@@ -496,10 +496,10 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
 		struct rq *rq = rq_of_rt_rq(rt_rq);
 
 		spin_lock(&rq->lock);
+		spin_lock(&rt_rq->rt_runtime_lock);
 		if (rt_rq->rt_time) {
 			u64 runtime;
 
-			spin_lock(&rt_rq->rt_runtime_lock);
 			if (rt_rq->rt_throttled)
 				balance_runtime(rt_rq);
 			runtime = rt_rq->rt_runtime;
@@ -510,9 +510,9 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
 			}
 			if (rt_rq->rt_time || rt_rq->rt_nr_running)
 				idle = 0;
-			spin_unlock(&rt_rq->rt_runtime_lock);
 		} else if (rt_rq->rt_nr_running)
 			idle = 0;
+		spin_unlock(&rt_rq->rt_runtime_lock);
 
 		if (enqueue)
 			sched_rt_rq_enqueue(rt_rq);
#3 lore raw

Re: [PATCH 2/2] sched_rt: protect rt_rq->rt_time by rt_runtime_lock

Quoted 5 lines · Peter Zijlstra
Quoted 4 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: fix possible race condition

Quoted 7 lines
Quoted 1 line

rt_rq->rt_time should be protected.

Don't think so, all we do is check the value for non-zero outside the lock, that should be ok.

If there's still a race, your changelog utterly fails to mention the race scenario.

OK. I just noticed rt_time is accessed with rt_runtime_lock held except this point. Will look at this again.

Thanks,
Hiroshi

Quoted 40 lines
Quoted 23 lines
---
 kernel/sched_rt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched_rt.c +1 -1
index 299d012..d7654a3 100644
@@ -496,10 +496,10 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
 		struct rq *rq = rq_of_rt_rq(rt_rq);
 
 		spin_lock(&rq->lock);
+		spin_lock(&rt_rq->rt_runtime_lock);
 		if (rt_rq->rt_time) {
 			u64 runtime;
 
-			spin_lock(&rt_rq->rt_runtime_lock);
 			if (rt_rq->rt_throttled)
 				balance_runtime(rt_rq);
 			runtime = rt_rq->rt_runtime;

kernel/sched_rt.c static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun) · line 518

Quoted 10 lines
kernel/sched_rt.c +1 -1
@@ -510,9 +510,9 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
 			}
 			if (rt_rq->rt_time || rt_rq->rt_nr_running)
 				idle = 0;
-			spin_unlock(&rt_rq->rt_runtime_lock);
 		} else if (rt_rq->rt_nr_running)
 			idle = 0;
+		spin_unlock(&rt_rq->rt_runtime_lock);
 
 		if (enqueue)
 			sched_rt_rq_enqueue(rt_rq);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw

Re: [PATCH 2/2] sched_rt: protect rt_rq->rt_time by rt_runtime_lock

Quoted 9 lines · Hiroshi Shimamoto
Quoted 8 lines · Peter Zijlstra
Quoted 5 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: fix possible race condition

rt_rq->rt_time should be protected.

Don't think so, all we do is check the value for non-zero outside the lock, that should be ok.

OK, now I see. I didn't find any real race.

Thanks,
Hiroshi