lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <db033cf3-1931-1821-61ad-5a46f3af5b30@redhat.com>
Date:   Tue, 15 May 2018 09:57:44 -0400
From:   Waiman Long <longman@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        Davidlohr Bueso <dave@...olabs.net>,
        "Theodore Y. Ts'o" <tytso@....edu>,
        Oleg Nesterov <oleg@...hat.com>,
        Amir Goldstein <amir73il@...il.com>, Jan Kara <jack@...e.cz>
Subject: Re: [RFC PATCH v2 2/2] locking/percpu-rwsem: Mark rwsem as
 non-spinnable in percpu_rwsem_release()

On 05/15/2018 04:51 AM, Peter Zijlstra wrote:
> On Mon, May 14, 2018 at 03:31:07PM -0400, Waiman Long wrote:
>> The percpu_rwsem_release() is called when the ownership of the embedded
>> rwsem is to be transferred to another task. The new owner, however, may
>> take a while to get the ownership of the lock via percpu_rwsem_acquire().
>> During that period, the rwsem is now marked as writer-owned with no
>> optimistic spinning.
>>
>> Signed-off-by: Waiman Long <longman@...hat.com>
>> ---
>>  include/linux/percpu-rwsem.h | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h
>> index b1f37a8..dd37102 100644
>> --- a/include/linux/percpu-rwsem.h
>> +++ b/include/linux/percpu-rwsem.h
>> @@ -131,16 +131,16 @@ static inline void percpu_rwsem_release(struct percpu_rw_semaphore *sem,
>>  					bool read, unsigned long ip)
>>  {
>>  	lock_release(&sem->rw_sem.dep_map, 1, ip);
>> -#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
>>  	if (!read)
>> -		sem->rw_sem.owner = NULL;
>> -#endif
>> +		rwsem_set_writer_owned_nospin(&sem->rw_sem);
>>  }
>>  
>>  static inline void percpu_rwsem_acquire(struct percpu_rw_semaphore *sem,
>>  					bool read, unsigned long ip)
>>  {
>>  	lock_acquire(&sem->rw_sem.dep_map, 0, 1, read, 1, NULL, ip);
>> +	if (!read)
>> +		rwsem_set_writer_owned(&sem->rw_sem, current);
>>  }
> So what's wrong with adding:
>
> 	if (!read)
> 		sem->rw_sem.owner = current;
>
> ?

Yes, we can certainly do that within a "#ifdef" block.

>
> Afaict the whole .owner=NULL thing in release already stops the spinners
> dead, and the above 'fixes' the debug splat. And this avoids exposing
> that horrible interface and keeps the mucking private to
> rwsem/percpu_rwsem.

Actually setting owner to NULL does not stop spinning. The code just
assume that the lock is going to be freed and spin in the outer loop. We
need some special value to indicate that spinning should be stopped. How
about just exposing a special value for that in linux/rwsem.h? Any
suggestion for a good name?

Cheers,
Longman




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ