All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Overstreet <kmo@daterainc.com>
To: Tejun Heo <tj@kernel.org>
Cc: Christoph Lameter <cl@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2 percpu/for-3.20] percpu_ref: remove unnecessary ACCESS_ONCE() in percpu_ref_tryget_live()
Date: Tue, 6 Jan 2015 18:21:28 -0800	[thread overview]
Message-ID: <20150107022128.GC2433@kmo-pixel> (raw)
In-Reply-To: <20150106152347.GD3077@htj.dyndns.org>

On Tue, Jan 06, 2015 at 10:23:47AM -0500, Tejun Heo wrote:
> __ref_is_percpu() needs the implied ACCESS_ONCE() in
> lockless_dereference() on @ref->percpu_count_ptr because the value is
> tested for !__PERCPU_REF_ATOMIC, which may be set asynchronously, and
> then used as a pointer.  If the compiler generates a separate fetch
> when using it as a pointer, __PERCPU_REF_ATOMIC may be set in between
> contaminating the pointer value.
> 
> percpu_ref_tryget_live() also uses ACCESS_ONCE() to test
> __PERCPU_REF_DEAD; however, there's no reason for this.  I just copied
> ACCESS_ONCE() usage blindly from __ref_is_percpu().  All it does is
> confusing people trying to understand what's going on.
> 
> This patch removes the unnecessary ACCESS_ONCE() usage from
> percpu_ref_tryget_live() and adds a comment explaining why
> __ref_is_percpu() needs it.

lockless_dereference() is new - cool! I've been wanting that without even
realizing it.

Acked-by: Kent Overstreet <kmo@daterainc.com>

      parent reply	other threads:[~2015-01-07  2:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-06 15:23 [PATCH 1/2 percpu/for-3.20] percpu_ref: remove unnecessary ACCESS_ONCE() in percpu_ref_tryget_live() Tejun Heo
2015-01-06 15:24 ` [PATCH 2/2 percpu/for-3.20] percpu_ref: implement percpu_ref_is_dying() Tejun Heo
2015-01-07  2:21   ` Kent Overstreet
2015-01-07  2:21 ` Kent Overstreet [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=20150107022128.GC2433@kmo-pixel \
    --to=kmo@daterainc.com \
    --cc=cl@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.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 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.