From: Ingo Molnar <mingo@kernel.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>,
Waiman Long <longman@redhat.com>, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Davidlohr Bueso <dave@stgolabs.net>,
"Theodore Y. Ts'o" <tytso@mit.edu>,
Amir Goldstein <amir73il@gmail.com>, Jan Kara <jack@suse.cz>
Subject: Re: [PATCH v4 1/2] locking/rwsem: Add a new RWSEM_ANONYMOUSLY_OWNED flag
Date: Fri, 18 May 2018 11:40:52 +0200 [thread overview]
Message-ID: <20180518094052.GA26150@gmail.com> (raw)
In-Reply-To: <20180518084122.GA14307@redhat.com>
* Oleg Nesterov <oleg@redhat.com> wrote:
> On 05/18, Ingo Molnar wrote:
> >
> >
> > * Matthew Wilcox <willy@infradead.org> wrote:
> >
> > > This is confusingly written. I think you mean ...
> > >
> > > if (!owner)
> > > goto done;
> > > if (!is_rwsem_owner_spinnable(owner)) {
> > > ret = false;
> > > goto done;
> > > }
> >
> > Yes, that's cleaner. Waiman, mind sending a followup patch that cleans this up?
>
> Or simply
>
> static inline bool owner_on_cpu(struct task_struct *owner)
> {
> return owner->on_cpu && !vcpu_is_preempted(task_cpu(owner));
> }
>
> static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem)
> {
> struct task_struct *owner;
> bool ret = true;
>
> if (need_resched())
> return false;
>
> rcu_read_lock();
> owner = READ_ONCE(sem->owner);
> if (owner) {
> ret = is_rwsem_owner_spinnable(owner) &&
> owner_on_cpu(owner);
> }
> rcu_read_unlock();
> return ret;
> }
>
> note that rwsem_spin_on_owner() can use the new owner_on_cpu() helper too,
>
> if (need_resched() || !owner_on_cpu(owner)) {
> rcu_read_unlock();
> return false;
> }
>
> looks a bit better than the current code:
>
> if (!owner->on_cpu || need_resched() ||
> vcpu_is_preempted(task_cpu(owner))) {
> rcu_read_unlock();
> return false;
> }
>
> Oleg.
That looks good to me too - mind sending a patch on top of latest -tip?
Thanks,
Ingo
next prev parent reply other threads:[~2018-05-18 9:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-15 21:49 [PATCH v4 0/2] locking/rwsem: Fix DEBUG_RWSEM warning from thaw_super() Waiman Long
2018-05-15 21:49 ` [PATCH v4 1/2] locking/rwsem: Add a new RWSEM_ANONYMOUSLY_OWNED flag Waiman Long
2018-05-16 10:48 ` Oleg Nesterov
2018-05-16 11:59 ` Peter Zijlstra
2018-05-16 13:11 ` Waiman Long
2018-05-16 15:27 ` Oleg Nesterov
2018-05-16 12:19 ` Matthew Wilcox
2018-05-18 7:02 ` Ingo Molnar
2018-05-18 8:41 ` Oleg Nesterov
2018-05-18 9:40 ` Ingo Molnar [this message]
2018-05-18 16:55 ` [PATCH] locking/rwsem: simplify the is-owner-spinnable checks Oleg Nesterov
2018-05-18 17:00 ` Waiman Long
2018-05-15 21:49 ` [PATCH v4 2/2] locking/percpu-rwsem: Annotate rwsem ownership transfer by setting RWSEM_OWNER_UNKNOWN Waiman Long
2018-05-16 5:37 ` Amir Goldstein
2018-05-16 13:17 ` Waiman Long
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=20180518094052.GA26150@gmail.com \
--to=mingo@kernel.org \
--cc=amir73il@gmail.com \
--cc=dave@stgolabs.net \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tytso@mit.edu \
--cc=willy@infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).