Skip to contentSkip to conversation

sched/fair: remove the spin_lock operations

PATCH Applied Hui Su 5 participants 7 messages Oct 30, 2020 – Nov 11, 2020 Scheduler

lore
Share & tools
lore

Hui Su

author
#0 lore raw

PATCH 1/1 sched/fair: remove the spin_lock operations

Since 'ab93a4bc955b ("sched/fair: Remove distribute_running fromCFS bandwidth")',there is nothing to protect between raw_spin_lock_irqsave/store() in do_sched_cfs_slack_timer().

So remove it.

---
 kernel/sched/fair.c | 3 ---
 1 file changed, 3 deletions(-)
kernel/sched/fair.c +0 -3
index 290f9e38378c..5ecbf5e63198 100644
@@ -5105,9 +5105,6 @@ static void do_sched_cfs_slack_timer(struct cfs_bandwidth *cfs_b)
 		return;
 
 	distribute_cfs_runtime(cfs_b);
-
-	raw_spin_lock_irqsave(&cfs_b->lock, flags);
-	raw_spin_unlock_irqrestore(&cfs_b->lock, flags);
 }
 
 /*
Signature · 1 line
2.29.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · On Fri, Oct 30, 2020 at 10:46:21PM +0800 Hui Su wrote:

Since 'ab93a4bc955b ("sched/fair: Remove distribute_running fromCFS bandwidth")',there is nothing to protect between raw_spin_lock_irqsave/store() in do_sched_cfs_slack_timer().

So remove it.

---
 kernel/sched/fair.c | 3 ---
 1 file changed, 3 deletions(-)
kernel/sched/fair.c +0 -3
index 290f9e38378c..5ecbf5e63198 100644
@@ -5105,9 +5105,6 @@ static void do_sched_cfs_slack_timer(struct cfs_bandwidth *cfs_b)
 		return;
 
 	distribute_cfs_runtime(cfs_b);
-
-	raw_spin_lock_irqsave(&cfs_b->lock, flags);
-	raw_spin_unlock_irqrestore(&cfs_b->lock, flags);
 }
 
 /*
Signature · 1 line
2.29.0

Nice :)

reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Hui Su
Quoted 6 lines · Hui Su

Since 'ab93a4bc955b ("sched/fair: Remove distribute_running fromCFS bandwidth")',there is nothing to protect between raw_spin_lock_irqsave/store() in do_sched_cfs_slack_timer().

So remove it.

(I might nitpick the subject to be clear that it should be trivial because the lock area is empty, or call them dead or something, but it's not all that important)

Quoted 20 lines
---
 kernel/sched/fair.c | 3 ---
 1 file changed, 3 deletions(-)
kernel/sched/fair.c +0 -3
index 290f9e38378c..5ecbf5e63198 100644
@@ -5105,9 +5105,6 @@ static void do_sched_cfs_slack_timer(struct cfs_bandwidth *cfs_b)
 		return;
 
 	distribute_cfs_runtime(cfs_b);
-
-	raw_spin_lock_irqsave(&cfs_b->lock, flags);
-	raw_spin_unlock_irqrestore(&cfs_b->lock, flags);
 }
 
 /*
#3 lore raw

From: Benjamin Segall

Quoted 9 lines

Sent: 30 October 2020 18:48

Quoted 5 lines · Hui Su

Since 'ab93a4bc955b ("sched/fair: Remove distribute_running fromCFS bandwidth")',there is nothing to protect between raw_spin_lock_irqsave/store() in do_sched_cfs_slack_timer().

Quoted 7 lines
Quoted 1 line

So remove it.

(I might nitpick the subject to be clear that it should be trivial because the lock area is empty, or call them dead or something, but it's not all that important)

I don't know about this case, but a lock+unlock can be used to ensure that nothing else holds the lock when acquiring the lock requires another lock be held.

So if the normal sequence is:

	lock(table)
	# lookup item
	lock(item)
	unlock(table)
	....
	unlock(item)

Then it can make sense to do:

	lock(table)
	lock(item)
	unlock(item)
	....
	unlock(table)

although that ought to deserve a comment.

avid

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#4 lore raw
Quoted 30 lines · On Fri, Oct 30, 2020 at 10:16:29PM +0000 David Laight wrote:

From: Benjamin Segall

Quoted 9 lines

Sent: 30 October 2020 18:48

Quoted 5 lines · Hui Su

Since 'ab93a4bc955b ("sched/fair: Remove distribute_running fromCFS bandwidth")',there is nothing to protect between raw_spin_lock_irqsave/store() in do_sched_cfs_slack_timer().

Quoted 7 lines
Quoted 1 line

So remove it.

(I might nitpick the subject to be clear that it should be trivial because the lock area is empty, or call them dead or something, but it's not all that important)

I don't know about this case, but a lock+unlock can be used to ensure that nothing else holds the lock when acquiring the lock requires another lock be held.

So if the normal sequence is:

	lock(table)
	# lookup item
	lock(item)
	unlock(table)
	....
	unlock(item)
Quoted 9 lines

Then it can make sense to do:

	lock(table)
	lock(item)
	unlock(item)
	....
	unlock(table)

although that ought to deserve a comment.

Nah, this one used to be like this :

        raw_spin_lock_irqsave(&cfs_b->lock, flags);
        lsub_positive(&cfs_b->runtime, runtime);
        cfs_b->distribute_running = 0;
        raw_spin_unlock_irqrestore(&cfs_b->lock, flags);

It's just a leftover. I agree that if it was there for some other purpose that it would really need a comment. In this case, it's an artifact of patch-based development I think.

Cheers,
Phil

Quoted 6 lines

avid

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

author
#5 lore raw
Quoted 48 lines · Phil Auld
Quoted 30 lines · On Fri, Oct 30, 2020 at 10:16:29PM +0000 David Laight wrote:

From: Benjamin Segall

Quoted 9 lines

Sent: 30 October 2020 18:48

Quoted 5 lines · Hui Su

Since 'ab93a4bc955b ("sched/fair: Remove distribute_running fromCFS bandwidth")',there is nothing to protect between raw_spin_lock_irqsave/store() in do_sched_cfs_slack_timer().

Quoted 7 lines
Quoted 1 line

So remove it.

(I might nitpick the subject to be clear that it should be trivial because the lock area is empty, or call them dead or something, but it's not all that important)

I don't know about this case, but a lock+unlock can be used to ensure that nothing else holds the lock when acquiring the lock requires another lock be held.

So if the normal sequence is:

	lock(table)
	# lookup item
	lock(item)
	unlock(table)
	....
	unlock(item)
Quoted 9 lines

Then it can make sense to do:

	lock(table)
	lock(item)
	unlock(item)
	....
	unlock(table)

although that ought to deserve a comment.

Nah, this one used to be like this :

        raw_spin_lock_irqsave(&cfs_b->lock, flags);
        lsub_positive(&cfs_b->runtime, runtime);
        cfs_b->distribute_running = 0;
        raw_spin_unlock_irqrestore(&cfs_b->lock, flags);
Quoted 8 lines

It's just a leftover. I agree that if it was there for some other purpose that it would really need a comment. In this case, it's an artifact of patch-based development I think.

Cheers,
Phil

Yeah, thanks for your explanation, Phil.

It is just a leftover.

merge bot Applied
#6 lore raw

[tip: sched/core] sched/fair: Remove superfluous lock section in do_sched_cfs_slack_timer()

In reply to Hui Su
The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     cdb310474dece99985e4cdd2b96b1324e39c1c9d
Gitweb:        https://git.kernel.org/tip/cdb310474dece99985e4cdd2b96b1324e39c1c9d
Author:        Hui Su <[email protected]>
AuthorDate:    Fri, 30 Oct 2020 22:46:21 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Tue, 10 Nov 2020 18:39:05 +01:00

sched/fair: Remove superfluous lock section in do_sched_cfs_slack_timer()

Since ab93a4bc955b ("sched/fair: Remove distribute_running fromCFS bandwidth"), there is nothing to protect between raw_spin_lock_irqsave/store() in do_sched_cfs_slack_timer().

---
 kernel/sched/fair.c | 3 ---
 1 file changed, 3 deletions(-)
kernel/sched/fair.c +0 -3
index 2755a7e..3e5d98f 100644
@@ -5126,9 +5126,6 @@ static void do_sched_cfs_slack_timer(struct cfs_bandwidth *cfs_b)
 		return;
 
 	distribute_cfs_runtime(cfs_b);
-
-	raw_spin_lock_irqsave(&cfs_b->lock, flags);
-	raw_spin_unlock_irqrestore(&cfs_b->lock, flags);
 }
 
 /*