lkml.org 
[lkml]   [2016]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] locking/rwsem: Add reader-owned state to the owner field
On 05/12/2016 05:27 PM, Peter Hurley wrote:
>>> Arguably, this check should be bumped out to the optimistic spin and
>>> reload/check the owner there?
>>>
>>> Or better yet; don't pass the owner in as a parameter at all, but
>>> instead snapshot the owner and check its ownership on entry.
>> That will make the main optimistic spinning loop more complex.
> ??
>
> Simpler.
>
> while (rwsem_spin_on_owner(sem)) {
> if (rwsem_try_write_lock_unqueued(sem)) {
> taken = true;
> break;
> }
>
> if (!sem->owner&& (need_resched() || rt_task(current)))
> break;
>
> cpu_relax_lowlatency();
> }
>
>
>
>
> bool rwsem_spin_on_owner(struct rw_semaphore *sem)
> {
> struct task_struct *owner = READ_ONCE(sem->owner);
>
> if (!rwsem_is_writer_owned(owner))
> return false;
>
> rcu_read_lock();
> while (sem->owner == owner) {
> ....
> }
> rcu_read_unlock();
>
> return !rwsem_is_reader_owned(sem->owner);
> }
>

I have been thinking about something like that, but my inclination is to
make as few changes as possible to the existing patch. I did add a new
patch to streamline the code as suggested.

Cheers,
Longman

\
 
 \ /
  Last update: 2016-05-13 01:21    [W:0.065 / U:2.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site