public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* A question on RCU vs. preempt-RCU
@ 2013-06-16  2:36 Tejun Heo
  2013-06-16  6:46 ` Rusty Russell
  2013-06-16 14:13 ` Paul E. McKenney
  0 siblings, 2 replies; 7+ messages in thread
From: Tejun Heo @ 2013-06-16  2:36 UTC (permalink / raw)
  To: Paul E. McKenney, Rusty Russell, Kent Overstreet
  Cc: linux-kernel, Linus Torvalds, Andrew Morton

Hello, guys.

Kent recently implemented a generic percpu reference counter.  It's
scheduled to be merged in the coming merge window and some part of
cgroup refcnting is already converted to it.

 https://git.kernel.org/cgit/linux/kernel/git/tj/percpu.git/tree/include/linux/percpu-refcount.h?h=for-3.11

 https://git.kernel.org/cgit/linux/kernel/git/tj/percpu.git/tree/lib/percpu-refcount.c?h=for-3.11

It's essentially a generalized form of module refcnting but uses
regular RCU instead of toggling preemption for local atomicity.

I've been running some performance tests with different preemption
levels and, with CONFIG_PREEMPT, the percpu ref could be slower by
around 10% or at the worst contrived case maybe even close to 20% when
compared to simple atomic_t on a single CPU (when hit by multiple CPUs
concurrently, it of course destroys atomic_t).  Most of the slow down
seems to come from the preempt tree RCU calls and there no longer
seems to be a way to opt out of that RCU implementation when
CONFIG_PREEMPT.

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.

We can convert the percpu-refcount to use preempt_disable/enable()
paired with call_rcu_sched() but IIUC that would have latency
implications from the callback processing side, right?  Given that
module ref killing would be very low-frequency, it shouldn't
contribute significant amount of callbacks but I'd like to avoid
providing two separate implementations if at all possible.

So, what would be the right thing to do here?  How bad would
converting percpu-refcount to sched-RCU by default be?  Would the
extra overhead on module ref be acceptable when CONFIG_PREEMPT?
What do you guys think?

Thanks!

-- 
tejun

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-06-20  3:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-16  2:36 A question on RCU vs. preempt-RCU Tejun Heo
2013-06-16  6:46 ` Rusty Russell
2013-06-17 18:20   ` Tejun Heo
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox