lkml.org 
[lkml]   [2018]   [Apr]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] locking/rwsem: Add up_write_non_owner() for percpu_up_write()
On 04/04, Waiman Long wrote:
>
> --- a/kernel/locking/percpu-rwsem.c
> +++ b/kernel/locking/percpu-rwsem.c
> @@ -179,8 +179,10 @@ void percpu_up_write(struct percpu_rw_semaphore *sem)
>
> /*
> * Release the write lock, this will allow readers back in the game.
> + * percpu_up_write() may be called from a task different from the one
> + * taking the lock.
> */
> - up_write(&sem->rw_sem);
> + up_write_non_owner(&sem->rw_sem);
>
> /*
> * Once this completes (at least one RCU-sched grace period hence) the
> diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
> index 30465a2..140d5ef 100644
> --- a/kernel/locking/rwsem.c
> +++ b/kernel/locking/rwsem.c
> @@ -222,4 +222,17 @@ void up_read_non_owner(struct rw_semaphore *sem)
>
> #endif
>
> +#ifdef CONFIG_DEBUG_RWSEMS
> +/*
> + * release a write lock from a different task
> + */
> +void up_write_non_owner(struct rw_semaphore *sem)
> +{
> + rwsem_release(&sem->dep_map, 1, _RET_IP_);
> + DEBUG_RWSEMS_WARN_ON(!sem->owner || (sem->owner == RWSEM_READER_OWNED));
>
> + rwsem_clear_owner(sem);
> + __up_write(sem);
> +}

Hmm. Can you look at lockdep_sb_freeze_release() and lockdep_sb_freeze_acquire()?

At first glance, it would be much better to set sem->owner = current in
percpu_rwsem_acquire(), no?

Oleg.

\
 
 \ /
  Last update: 2018-04-09 13:20    [W:0.107 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site