2018-05-24 23:21:25

by Waiman Long

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Waiman Long <[email protected]>
---
kernel/locking/rwsem.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
index bc1e507..776308d 100644
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -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);
--
1.8.3.1



2018-06-19 23:11:18

by Waiman Long

[permalink] [raw]
Subject: Re: [PATCH] locking/rwsem: Fix up_read_non_owner() warning with DEBUG_RWSEMS

On 05/24/2018 09:26 PM, Waiman Long wrote:
> 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.
>
> Signed-off-by: Waiman Long <[email protected]>
> ---
> kernel/locking/rwsem.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
> index bc1e507..776308d 100644
> --- a/kernel/locking/rwsem.c
> +++ b/kernel/locking/rwsem.c
> @@ -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


2018-06-20 05:50:51

by Schenk, Gavin

[permalink] [raw]
Subject: Re: [Customers.Eckelmann] [PATCH] locking/rwsem: Fix up_read_non_owner() warning with DEBUG_RWSEMS

Hi,

On Wed, 2018-06-20 at 07:09 +0800, Waiman Long wrote:
> On 05/24/2018 09:26 PM, Waiman Long wrote:
> > 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.
> >
> > Signed-off-by: Waiman Long <[email protected]>
Tested-by: Gavin Schenk <[email protected]>

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

Regards
Gavin Schenk

2018-06-20 09:19:11

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH] locking/rwsem: Fix up_read_non_owner() warning with DEBUG_RWSEMS

On Thu, May 24, 2018 at 09:26:38AM -0400, Waiman Long wrote:
> 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.
>
> Signed-off-by: Waiman Long <[email protected]>

Acked-by: Peter Zijlstra (Intel) <[email protected]>

> ---
> kernel/locking/rwsem.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
> index bc1e507..776308d 100644
> --- a/kernel/locking/rwsem.c
> +++ b/kernel/locking/rwsem.c
> @@ -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);
> --
> 1.8.3.1
>

Subject: [tip:locking/urgent] 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")
Signed-off-by: Waiman Long <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Tested-by: Gavin Schenk <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected]

---
kernel/locking/rwsem.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
index bc1e507be9ff..776308d2fa9e 100644
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -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);