Skip to contentSkip to conversation

locking/rwsem: Fix up_read_non_owner() warning with DEBUG_RWSEMS

PATCH In review Waiman Long 4 participants 5 messages May 24, 2018 – Jun 20, 2018

Subsystems (3)
lore
Share & tools
lore

Waiman Long

author reviewer
#0 lore raw

PATCH 1/1 locking/rwsem: Fix up_read_non_owner() warning with DEBUG_RWSEMS

It was found that the use of up_read_non_owner() in NFS was causing the following warning when DEBUG_RWSEMS was configured.

DEBUG_LOCKS_WARN_ON(sem->owner != ((struct task_struct *)(1UL << 0)))

Looking into the rwsem.c file, it was discovered that the corresponding down_read_non_owner() function was not setting the owner field properly. This is fixed now, and the warning should be gone.

---
 kernel/locking/rwsem.c | 1 +
 1 file changed, 1 insertion(+)
kernel/locking/rwsem.c +1 -0
index bc1e507..776308d 100644
@@ -181,6 +181,7 @@ void down_read_non_owner(struct rw_semaphore *sem)
 	might_sleep();
 
 	__down_read(sem);
+	rwsem_set_reader_owned(sem);
 }
 
 EXPORT_SYMBOL(down_read_non_owner);
Signature · 1 line
1.8.3.1
author reviewer
#1 lore raw
Quoted 19 lines · Waiman Long

It was found that the use of up_read_non_owner() in NFS was causing the following warning when DEBUG_RWSEMS was configured.

DEBUG_LOCKS_WARN_ON(sem->owner != ((struct task_struct *)(1UL << 0)))

Looking into the rwsem.c file, it was discovered that the corresponding down_read_non_owner() function was not setting the owner field properly. This is fixed now, and the warning should be gone.

---
 kernel/locking/rwsem.c | 1 +
 1 file changed, 1 insertion(+)
kernel/locking/rwsem.c +0 -0
index bc1e507..776308d 100644

kernel/locking/rwsem.c void down_read_non_owner(struct rw_semaphore *sem) · line 187

Quoted 7 lines
kernel/locking/rwsem.c +1 -0
@@ -181,6 +181,7 @@ void down_read_non_owner(struct rw_semaphore *sem)
 	might_sleep();
 tch
 	__down_read(sem);
+	rwsem_set_reader_owned(sem);
 }
 
 EXPORT_SYMBOL(down_read_non_owner);

Since the 4.18 merge window has been closed. Can that patch be merged upstream?

Cheers,
Longman

Tested-by
#2 lore raw

Hi,

Quoted 11 lines · Waiman Long
Quoted 10 lines · Waiman Long

It was found that the use of up_read_non_owner() in NFS was causing the following warning when DEBUG_RWSEMS was configured.

DEBUG_LOCKS_WARN_ON(sem->owner != ((struct task_struct *)(1UL << 0)))

Looking into the rwsem.c file, it was discovered that the corresponding down_read_non_owner() function was not setting the owner field properly. This is fixed now, and the warning should be gone.

This fixes my reproducible locking splat when booting with nfsroot and changing password. Thank you!

Regards
Gavin Schenk

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Waiman Long
Quoted 10 lines · Waiman Long

It was found that the use of up_read_non_owner() in NFS was causing the following warning when DEBUG_RWSEMS was configured.

DEBUG_LOCKS_WARN_ON(sem->owner != ((struct task_struct *)(1UL << 0)))

Looking into the rwsem.c file, it was discovered that the corresponding down_read_non_owner() function was not setting the owner field properly. This is fixed now, and the warning should be gone.

Quoted 19 lines
---
 kernel/locking/rwsem.c | 1 +
 1 file changed, 1 insertion(+)
kernel/locking/rwsem.c +1 -0
index bc1e507..776308d 100644
@@ -181,6 +181,7 @@ void down_read_non_owner(struct rw_semaphore *sem)
 	might_sleep();
 
 	__down_read(sem);
+	rwsem_set_reader_owned(sem);
 }
 
 EXPORT_SYMBOL(down_read_non_owner);
Signature · 1 line
1.8.3.1
#4 lore raw
In reply to Waiman Long
locking/rwsem: Fix up_read_non_owner() warning with DEBUG_RWSEMS
Commit-ID:  03eeafdd9ab06a770d42c2b264d50dff7e2f4eee
Gitweb:     https://git.kernel.org/tip/03eeafdd9ab06a770d42c2b264d50dff7e2f4eee
Author:     Waiman Long <[email protected]>
AuthorDate: Thu, 24 May 2018 09:26:38 -0400
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Wed, 20 Jun 2018 11:29:23 +0200

locking/rwsem: Fix up_read_non_owner() warning with DEBUG_RWSEMS

It was found that the use of up_read_non_owner() in NFS was causing the following warning when DEBUG_RWSEMS was configured.

DEBUG_LOCKS_WARN_ON(sem->owner != ((struct task_struct *)(1UL << 0)))

Looking into the rwsem.c file, it was discovered that the corresponding down_read_non_owner() function was not setting the owner field properly. This is fixed now, and the warning should be gone.

Fixes 5149cbac4235 ("locking/rwsem: Add DEBUG_RWSEMS to look for lock/unlock mismatches")
Cc Davidlohr Bueso <[email protected]>
Cc Dan Williams <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 kernel/locking/rwsem.c | 1 +
 1 file changed, 1 insertion(+)
kernel/locking/rwsem.c +1 -0
index bc1e507be9ff..776308d2fa9e 100644
@@ -181,6 +181,7 @@ void down_read_non_owner(struct rw_semaphore *sem)
 	might_sleep();
 
 	__down_read(sem);
+	rwsem_set_reader_owned(sem);
 }
 
 EXPORT_SYMBOL(down_read_non_owner);