From: Tejun Heo <tj@kernel.org>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Kent Overstreet <koverstreet@google.com>,
linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: A question on RCU vs. preempt-RCU
Date: Mon, 17 Jun 2013 11:20:23 -0700 [thread overview]
Message-ID: <20130617182023.GH32663@mtj.dyndns.org> (raw)
In-Reply-To: <8761xer1s8.fsf@rustcorp.com.au>
Hello, Rusty.
On Sun, Jun 16, 2013 at 04:16:15PM +0930, Rusty Russell wrote:
> > For most use cases, the trade-off should be fine. With any kind of
> > cross-cpu traffic, which there usually will be, it should be an easy
> > win for the percpu-refcount even when CONFIG_PREEMPT; however, I've
> > been looking to replace the module ref with the generic one and the
> > performance degradation there has low but existing possibility of
> > being noticeable in some edge use cases.
>
> I'm confused: is it actually 10% slower than the existing module
> refcount code, or 10% slower than atomic inc?
Heh, sorry about the confusion. I was comparing percpu_ref to
atomic_t and then worrying about the rcu flipping overhead as it
definitely seemed higher than flipping preemption. As I wrote in a
reply to Paul, if I compare perpcu-ref with normal RCU against
RCU-sched, the performance difference is around 18% in favor of
RCU-sched.
> CONFIG_PREEMPT, now with more preempt! Sure, that has a cost, but
> you're arguably fixing a bug.
It seems that using RCU-sched is the right flavor for perpcu_ref. In
theory, we shouldn't see any performance degradation when converting
module ref to percpu_ref.
> If we want to improve CONFIG_PREEMPT performance, we can probably use a
> trick I wanted to try long ago:
So, this is a slight digression.
> 1) Use a per-cpu counter rather than a per-task counter for preempt.
> 2) Lay out preempt_counter so it covers NR_CPU pages, one per page.
> 3) When you want to preempt a CPU and counter isn't zero, make the page RO.
> 4) Handle preemption enable in the fault handler.
>
> Then there's no branch in preempt_enable().
Buth yeah, interesting trick. We'll be doing IPIs, flushing TLB and
taking faults until it hits zero. It'll all depend on the frequency
of preemption but given that branches don't tend to be too expensive
on modern processors, maybe it'd be a bit too hairy for possibly
marginal gain?
Thanks.
--
tejun
next prev parent reply other threads:[~2013-06-17 18:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-16 2:36 Tejun Heo
2013-06-16 6:46 ` Rusty Russell
2013-06-17 18:20 ` Tejun Heo [this message]
2013-06-18 5:21 ` Rusty Russell
2013-06-20 3:23 ` Steven Rostedt
2013-06-16 14:13 ` Paul E. McKenney
2013-06-16 21:40 ` 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=20130617182023.GH32663@mtj.dyndns.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=koverstreet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®