Skip to contentSkip to conversation

locking/rwsem-rt: Remove might_sleep() in __up_read()

PATCH In review Andrew Halaney 2 participants 5 messages Apr 6, 2021 – Jul 9, 2021 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 locking/rwsem-rt: Remove might_sleep() in __up_read()

There's no chance of sleeping here, the reader is giving up the lock and possibly waking up the writer who is waiting on it.

---
Hello,

I ran into a warning caused by this, and I think the warning is incorrect. Please let me know if I'm wrong!
I'm working off of linux-5.12.y-rt, but this applies cleanly to older stable branches as well.

Thanks,
Andrew

 kernel/locking/rwsem-rt.c | 1 -
 1 file changed, 1 deletion(-)
kernel/locking/rwsem-rt.c +0 -1
index 274172d5bb3a..b61edc4dcb73 100644
@@ -198,7 +198,6 @@ void __up_read(struct rw_semaphore *sem)
 	if (!atomic_dec_and_test(&sem->readers))
 		return;
 
-	might_sleep();
 	raw_spin_lock_irq(&m->wait_lock);
 	/*
 	 * Wake the writer, i.e. the rtmutex owner. It might release the
Signature · 1 line
2.30.2
#1 lore raw
Quoted 34 lines · Andrew Halaney

There's no chance of sleeping here, the reader is giving up the lock and possibly waking up the writer who is waiting on it.

---
Hello,

I ran into a warning caused by this, and I think the warning is incorrect. Please let me know if I'm wrong!
I'm working off of linux-5.12.y-rt, but this applies cleanly to older stable branches as well.

Thanks,
Andrew

 kernel/locking/rwsem-rt.c | 1 -
 1 file changed, 1 deletion(-)
kernel/locking/rwsem-rt.c +0 -1
index 274172d5bb3a..b61edc4dcb73 100644
@@ -198,7 +198,6 @@ void __up_read(struct rw_semaphore *sem)
 	if (!atomic_dec_and_test(&sem->readers))
 		return;
 
-	might_sleep();
 	raw_spin_lock_irq(&m->wait_lock);
 	/*
 	 * Wake the writer, i.e. the rtmutex owner. It might release the
Signature · 1 line
2.30.2

Just a gentle follow up, any feedback?

Thanks,
Andrew

#2 lore raw
Quoted 28 lines · Andrew Halaney
Quoted 27 lines · Andrew Halaney

There's no chance of sleeping here, the reader is giving up the lock and possibly waking up the writer who is waiting on it.

---
Hello,

I ran into a warning caused by this, and I think the warning is incorrect. Please let me know if I'm wrong!
I'm working off of linux-5.12.y-rt, but this applies cleanly to older stable branches as well.

Thanks,
Andrew

 kernel/locking/rwsem-rt.c | 1 -
 1 file changed, 1 deletion(-)
kernel/locking/rwsem-rt.c +0 -0
index 274172d5bb3a..b61edc4dcb73 100644
@@ -198,7 +198,6 @@ void __up_read(struct rw_semaphore *sem)
 	if (!atomic_dec_and_test(&sem->readers))
 		return;
 
Quoted 8 lines
Quoted 6 lines
kernel/locking/rwsem-rt.c +0 -1
-	might_sleep();
 	raw_spin_lock_irq(&m->wait_lock);
 	/*
 	 * Wake the writer, i.e. the rtmutex owner. It might release the
Signature · 1 line
2.30.2

Just a gentle follow up, any feedback?

Looks correct. Will go into the next rt-release.

Thanks,

tglx

#3 lore raw
Quoted 38 lines · Thomas Gleixner
Quoted 28 lines · Andrew Halaney
Quoted 27 lines · Andrew Halaney

There's no chance of sleeping here, the reader is giving up the lock and possibly waking up the writer who is waiting on it.

---
Hello,

I ran into a warning caused by this, and I think the warning is incorrect. Please let me know if I'm wrong!
I'm working off of linux-5.12.y-rt, but this applies cleanly to older stable branches as well.

Thanks,
Andrew

 kernel/locking/rwsem-rt.c | 1 -
 1 file changed, 1 deletion(-)
kernel/locking/rwsem-rt.c +0 -0
index 274172d5bb3a..b61edc4dcb73 100644
@@ -198,7 +198,6 @@ void __up_read(struct rw_semaphore *sem)
 	if (!atomic_dec_and_test(&sem->readers))
 		return;
 
Quoted 8 lines
Quoted 6 lines
kernel/locking/rwsem-rt.c +0 -1
-	might_sleep();
 	raw_spin_lock_irq(&m->wait_lock);
 	/*
 	 * Wake the writer, i.e. the rtmutex owner. It might release the
Signature · 1 line
2.30.2

Just a gentle follow up, any feedback?

Quoted 6 lines

Looks correct. Will go into the next rt-release.

Thanks,

tglx

Hi Thomas,

I see a new release (v5.13-rt1) was created, and with it rwsem was overhauled entirely making this patch pointless for linux-rt-devel.

That being said, it's a little unclear to me how RT only patches make their way to the maintained branches over in linux-stable-rt. I think it should be applied to:
v4.9-rt
v4.14-rt
v4.19-rt
v5.4-rt
v5.10-rt
to remove the incorrect warning, unless those branches plan to backport the latest RT patchset with the new rwsem implementation. Is there a proper way for me signal that?

Thanks,
Andrew

#4 lore raw

Andrew,

On Thu, Jul 08 2021 at 14:51, Andrew Halaney wrote:

Cc+ stable-rt folks and leave context untrimmed.

Quoted 51 lines · Thomas Gleixner
Quoted 38 lines · Andrew Halaney
Quoted 28 lines · Andrew Halaney
Quoted 27 lines

There's no chance of sleeping here, the reader is giving up the lock and possibly waking up the writer who is waiting on it.

---
Hello,

I ran into a warning caused by this, and I think the warning is incorrect. Please let me know if I'm wrong!
I'm working off of linux-5.12.y-rt, but this applies cleanly to older stable branches as well.

Thanks,
Andrew

 kernel/locking/rwsem-rt.c | 1 -
 1 file changed, 1 deletion(-)
kernel/locking/rwsem-rt.c +0 -0
index 274172d5bb3a..b61edc4dcb73 100644
@@ -198,7 +198,6 @@ void __up_read(struct rw_semaphore *sem)
 	if (!atomic_dec_and_test(&sem->readers))
 		return;
 
Quoted 8 lines
Quoted 6 lines
kernel/locking/rwsem-rt.c +0 -1
-	might_sleep();
 	raw_spin_lock_irq(&m->wait_lock);
 	/*
 	 * Wake the writer, i.e. the rtmutex owner. It might release the
Signature · 1 line
2.30.2

Just a gentle follow up, any feedback?

Quoted 6 lines

Looks correct. Will go into the next rt-release.

Thanks,

tglx

Hi Thomas,

I see a new release (v5.13-rt1) was created, and with it rwsem was overhauled entirely making this patch pointless for linux-rt-devel.

Quoted 11 lines

That being said, it's a little unclear to me how RT only patches make their way to the maintained branches over in linux-stable-rt. I think it should be applied to:
v4.9-rt
v4.14-rt
v4.19-rt
v5.4-rt
v5.10-rt
to remove the incorrect warning, unless those branches plan to backport the latest RT patchset with the new rwsem implementation. Is there a proper way for me signal that?

See Cc.

Thanks,

tglx