All of lore.kernel.org
 help / color / mirror / Atom feed
From: Waiman Long <waiman.long@hpe.com>
To: Jason Low <jason.low2@hp.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, <linux-kernel@vger.kernel.org>,
	Scott J Norton <scott.norton@hpe.com>,
	Douglas Hatch <doug.hatch@hpe.com>, <jason.low2@hpe.com>
Subject: Re: [PATCH] locking/rwsem: Add reader owned state to the owner field
Date: Wed, 4 May 2016 14:33:03 -0400	[thread overview]
Message-ID: <572A405F.6000401@hpe.com> (raw)
In-Reply-To: <1462384355.3933.26.camel@j-VirtualBox>

On 05/04/2016 01:52 PM, Jason Low wrote:
> On Wed, 2016-05-04 at 13:27 -0400, Waiman Long wrote:
>> On 05/03/2016 08:21 PM, Davidlohr Bueso wrote:
>>> On Wed, 27 Apr 2016, Waiman Long wrote:
>>>> static bool rwsem_optimistic_spin(struct rw_semaphore *sem)
>>>> @@ -378,7 +367,8 @@ static bool rwsem_optimistic_spin(struct
>>>> rw_semaphore *sem)
>>>>
>>>>      while (true) {
>>>>          owner = READ_ONCE(sem->owner);
>>>> -        if (owner&&  !rwsem_spin_on_owner(sem, owner))
>>>> +        if (rwsem_is_writer_owned(owner)&&
>>>> +           !rwsem_spin_on_owner(sem, owner))
>>>>              break;
>>>>
>>>>          /* wait_lock will be acquired if write_lock is obtained */
>>>> @@ -391,9 +381,11 @@ static bool rwsem_optimistic_spin(struct
>>>> rw_semaphore *sem)
>>>>           * When there's no owner, we might have preempted between the
>>>>           * owner acquiring the lock and setting the owner field. If
>>>>           * we're an RT task that will live-lock because we won't let
>>>> -         * the owner complete.
>>>> +         * the owner complete. We also quit if the lock is owned by
>>>> +         * readers.
>>>>           */
>>>> -        if (!owner&&  (need_resched() || rt_task(current)))
>>>> +        if ((owner == RWSEM_READER_OWNED) ||
> It would be good to provide and use a rwsem_is_reader_owned() function
> like we do with rwsem_is_writer_owned(), especially if we're going to
> add in the additional cast.
>

Yes, sure I can certainly add the rwsem_is_reader_owned() helper function.

Cheers,
Longman

      reply	other threads:[~2016-05-04 18:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27 18:28 [PATCH] locking/rwsem: Add reader-owned state to the owner field Waiman Long
2016-05-04  0:21 ` Davidlohr Bueso
2016-05-04 17:27   ` Waiman Long
2016-05-04 17:52     ` [PATCH] locking/rwsem: Add reader owned " Jason Low
2016-05-04 18:33       ` Waiman Long [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=572A405F.6000401@hpe.com \
    --to=waiman.long@hpe.com \
    --cc=dave@stgolabs.net \
    --cc=doug.hatch@hpe.com \
    --cc=jason.low2@hp.com \
    --cc=jason.low2@hpe.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=scott.norton@hpe.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.