Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1170286

Re: [RFC][PATCH 06/13] percpu-rwsem: Provide percpu_down_read_trylock()

From Oleg Nesterov <oleg@redhat.com>
Newsgroups linux.kernel
Subject Re: [RFC][PATCH 06/13] percpu-rwsem: Provide percpu_down_read_trylock()
Date 2015-06-23 01:20 +0200
Message-ID <pEjap-1zV-3@gated-at.bofh.it> (permalink)
References <pE91n-3zX-3@gated-at.bofh.it> <pE91o-3zX-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 06/22, Peter Zijlstra wrote:
>
> +static inline bool percpu_down_read_trylock(struct percpu_rw_semaphore *sem)
> +{
> +	bool ret = true;
> +
> +	preempt_disable();
> +	__this_cpu_inc(*sem->refcount);
> +	if (unlikely(!rcu_sync_is_idle(&sem->rss)))
> +		ret = __percpu_down_read_trylock(sem);
> +	preempt_enable();
> +
> +	if (ret)
> +		rwsem_acquire_read(&sem->rw_sem.dep_map, 0, 1, _RET_IP_);
> +
> +	return ret;
> +}
...
> +bool __percpu_down_read_trylock(struct percpu_rw_semaphore *sem)
> +{
> +	smp_mb(); /* A matches D */
> +
> +	if (likely(smp_load_acquire(&sem->state) != readers_block))
> +		return true;
> +
> +	__percpu_up_read(sem);
> +
> +	return false;
> +}

Looks like we can slightly refactor this code to avoid the code
duplication. But this is minor too and we can do this later.

Reviewed-by: Oleg Nesterov <oleg@redhat.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[RFC][PATCH 06/13] percpu-rwsem: Provide percpu_down_read_trylock() Peter Zijlstra <peterz@infradead.org> - 2015-06-22 14:30 +0200
  Re: [RFC][PATCH 06/13] percpu-rwsem: Provide  percpu_down_read_trylock() Oleg Nesterov <oleg@redhat.com> - 2015-06-23 01:20 +0200

csiph-web