Skip to contentSkip to conversation

sched_fair: test list head instead of list entry in throttle_cfs_rq()

PATCH In review Cong Wang 4 participants 6 messages Jun 24, 2015 – Jul 6, 2015 Scheduler

lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 sched_fair: test list head instead of list entry in throttle_cfs_rq()

According to the comments, we need to test if this is the first throttled task, however, list_empty() tests on the entry cfs_rq->throttled_list, not the head, this is wrong.

This is a bug because we don't re-init the list entry after removing it from the list, so list_empty() could return false even if the list is really empty.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index 40a7fcb..ee91917 100644
@@ -3683,7 +3683,7 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq)
 	cfs_rq->throttled = 1;
 	cfs_rq->throttled_clock = rq_clock(rq);
 	raw_spin_lock(&cfs_b->lock);
-	empty = list_empty(&cfs_rq->throttled_list);
+	empty = list_empty(&cfs_b->throttled_cfs_rq);
 
 	/*
 	 * Add to the _head_ of the list, so that an already-started
Signature · 1 line
1.8.3.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Cong Wang

According to the comments, we need to test if this is the first throttled task, however, list_empty() tests on the entry cfs_rq->throttled_list, not the head, this is wrong.

Quoted 8 lines

This is a bug because we don't re-init the list entry after removing it from the list, so list_empty() could return false even if the list is really empty.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>

Agreed.

Quoted 17 lines
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index 40a7fcb..ee91917 100644
@@ -3683,7 +3683,7 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq)
 	cfs_rq->throttled = 1;
 	cfs_rq->throttled_clock = rq_clock(rq);
 	raw_spin_lock(&cfs_b->lock);
-	empty = list_empty(&cfs_rq->throttled_list);
+	empty = list_empty(&cfs_b->throttled_cfs_rq);
 
 	/*
 	 * Add to the _head_ of the list, so that an already-started
author
#2 lore raw
In reply to Cong Wang
Quoted 4 lines · Cong Wang

According to the comments, we need to test if this is the first throttled task, however, list_empty() tests on the entry cfs_rq->throttled_list, not the head, this is wrong.

Quoted 8 lines

This is a bug because we don't re-init the list entry after removing it from the list, so list_empty() could return false even if the list is really empty.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>

ping.

What's the status of this patch?

maintainer
#3 lore raw
Quoted 9 lines · Cong Wang
Quoted 8 lines · Cong Wang

According to the comments, we need to test if this is the first throttled task, however, list_empty() tests on the entry cfs_rq->throttled_list, not the head, this is wrong.

This is a bug because we don't re-init the list entry after removing it from the list, so list_empty() could return false even if the list is really empty.

Quoted 8 lines
Quoted 4 lines
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>

ping.

What's the status of this patch?

Queued, will likely hit tip after the merge window etc has settled.

author
#4 lore raw
Quoted 2 lines · Peter Zijlstra

Queued, will likely hit tip after the merge window etc has settled.

Great.

Thanks!

#5 lore raw

[tip:sched/core] sched/fair: Test list head instead of list entry in throttle_cfs_rq()

In reply to Cong Wang
sched/fair: Test list head instead of list entry in throttle_cfs_rq()
Commit-ID:  d49db342f0e276b354383b3281c5668b6b80f5c2
Gitweb:     http://git.kernel.org/tip/d49db342f0e276b354383b3281c5668b6b80f5c2
Author:     Cong Wang <[email protected]>
AuthorDate: Wed, 24 Jun 2015 12:41:47 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 6 Jul 2015 14:15:08 +0200

sched/fair: Test list head instead of list entry in throttle_cfs_rq()

According to the comments, we need to test if this is the first throttled task, however, list_empty() tests on the entry cfs_rq->throttled_list, not the head, this is wrong.

This is a bug because we don't re-init the list entry after removing it from the list, so list_empty() could return false even if the list is really empty.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index 65c8f3e..d113c3b 100644
@@ -3683,7 +3683,7 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq)
 	cfs_rq->throttled = 1;
 	cfs_rq->throttled_clock = rq_clock(rq);
 	raw_spin_lock(&cfs_b->lock);
-	empty = list_empty(&cfs_rq->throttled_list);
+	empty = list_empty(&cfs_b->throttled_cfs_rq);
 
 	/*
 	 * Add to the _head_ of the list, so that an already-started