All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Kent Overstreet <koverstreet@google.com>, linux-kernel@vger.kernel.org
Cc: Kent Overstreet <koverstreet@google.com>,
	Zach Brown <zab@redhat.com>, Felipe Balbi <balbi@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mark Fasheh <mfasheh@suse.com>, Joel Becker <jlbec@evilplan.org>,
	Jens Axboe <axboe@kernel.dk>,
	Asai Thambi S P <asamymuthupa@micron.com>,
	Selvan Mani <smani@micron.com>,
	Sam Bradshaw <sbradshaw@micron.com>,
	Jeff Moyer <jmoyer@redhat.com>, Al Viro <viro@zeniv.linux.org.uk>,
	Benjamin LaHaise <bcrl@kvack.org>, Tejun Heo <tj@kernel.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Christoph Lameter <cl@linux-foundation.org>,
	Ingo Molnar <mingo@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Paul McKenney" <paul.mckenney@us.ibm.com>
Subject: Re: [PATCH] Generic percpu refcounting
Date: Wed, 05 Jun 2013 17:05:09 +0930	[thread overview]
Message-ID: <87d2s1rowi.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1370039205-14071-1-git-send-email-koverstreet@google.com>

Kent Overstreet <koverstreet@google.com> writes:

> This implements a refcount with similar semantics to
> atomic_get()/atomic_dec_and_test() - but percpu.
>
> It also implements two stage shutdown, as we need it to tear down the
> percpu counts.  Before dropping the initial refcount, you must call
> percpu_ref_kill(); this puts the refcount in "shutting down mode" and
> switches back to a single atomic refcount with the appropriate barriers
> (synchronize_rcu()).
>
> It's also legal to call percpu_ref_kill() multiple times - it only returns
> true once, so callers don't have to reimplement shutdown synchronization.

> +static inline void percpu_ref_get(struct percpu_ref *ref)
> +{
> +	unsigned __percpu *pcpu_count;
> +
> +	preempt_disable();
> +
> +	pcpu_count = ACCESS_ONCE(ref->pcpu_count);
> +
> +	if (likely(REF_STATUS(pcpu_count) == PCPU_REF_PTR))
> +		__this_cpu_inc(*pcpu_count);
> +	else
> +		atomic_inc(&ref->count);
> +
> +	preempt_enable();
> +}

I think this should be rcu_read_lock(), which is currently equivalent
but theoretically different.

Does your percpu_ref_kill() *really* need to be nonblocking?  (I'd have
to read your other patches which use this to be sure).  Otherwise, just
use synchronize_rcu(), and get rid of the release function...

Cheers,
Rusty.

  parent reply	other threads:[~2013-06-05  7:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-31 22:26 [PATCH] Generic percpu refcounting Kent Overstreet
2013-06-03 22:39 ` Tejun Heo
2013-06-03 23:02 ` [PATCH] percpu-refcount: Don't use silly cmpxchg() Kent Overstreet
2013-06-03 23:09   ` Tejun Heo
2013-06-05  7:35 ` Rusty Russell [this message]
2013-06-05  7:44   ` [PATCH] Generic percpu refcounting Tejun Heo

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=87d2s1rowi.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@linux-foundation.org \
    --cc=asamymuthupa@micron.com \
    --cc=axboe@kernel.dk \
    --cc=balbi@ti.com \
    --cc=bcrl@kvack.org \
    --cc=cl@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jlbec@evilplan.org \
    --cc=jmoyer@redhat.com \
    --cc=koverstreet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mfasheh@suse.com \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=paul.mckenney@us.ibm.com \
    --cc=sbradshaw@micron.com \
    --cc=smani@micron.com \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zab@redhat.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.