lkml.org 
[lkml]   [2015]   [Apr]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] locking/rwsem: Use a return variable in rwsem_spin_on_owner()

* Jason Low <jason.low2@hp.com> wrote:

> +static inline bool owner_running(struct rw_semaphore *sem, struct task_struct *owner)
> +{
> + bool ret;
> +
> +#ifdef CONFIG_DEBUG_PAGEALLOC
> + rcu_read_lock();
> +#endif
> + if (READ_ONCE(sem->owner) == owner) {
> + /*
> + * Ensure we emit the owner->on_cpu dereference
> + * after checking sem->owner still matches owner.
> + */
> + barrier();
> + ret = owner->on_cpu;
> + } else {
> + /* Owner changed. */
> + ret = false;
> + }
> +
> +#ifdef CONFIG_DEBUG_PAGEALLOC
> + rcu_read_unlock();
> +#endif
> + return ret;
> +}

So I really don't like this due to the assymetric RCU pattern. (Also,
the fact that we might read from already freed kernel memory here
needs big honking comments.)

But, I think we can do this differently, see the patch I just sent:

[PATCH] mutex: Speed up mutex_spin_on_owner() by not taking the RCU lock

that should I think work just as well, without having to introduce
owner_running() as the whole mutex_spin_on_owner() logic is kept
pretty simple.

Thanks,

Ingo


\
 
 \ /
  Last update: 2015-04-10 11:41    [W:0.212 / U:1.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site