linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: "Paul E. McKenney" <paulmck@us.ibm.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	Linus Torvalds <torvalds@osdl.org>,
	Thomas Gleixner <tglx@timesys.com>, Ingo Molnar <mingo@elte.hu>,
	LKML <linux-kernel@vger.kernel.org>,
	john stultz <johnstul@us.ibm.com>,
	David Miller <davem@davemloft.net>,
	Arjan van de Ven <arjan@infradead.org>,
	Andrew Morton <akpm@osdl.org>, Andi Kleen <ak@suse.de>,
	manfred@colorfullife.com, oleg@tv-sign.ru
Subject: Re: [patch] cpufreq: mark cpufreq_tsc() as core_initcall_sync
Date: Fri, 17 Nov 2006 10:29:25 +0100	[thread overview]
Message-ID: <20061117092925.GT7164@kernel.dk> (raw)
In-Reply-To: <20061117065128.GA5452@us.ibm.com>

On Thu, Nov 16 2006, Paul E. McKenney wrote:
> On Thu, Nov 16, 2006 at 10:06:25PM -0500, Alan Stern wrote:
> > On Thu, 16 Nov 2006, Linus Torvalds wrote:
> > 
> > > 
> > > 
> > > On Thu, 16 Nov 2006, Alan Stern wrote:
> > > > On Thu, 16 Nov 2006, Linus Torvalds wrote:
> > > > >
> > > > > Paul, it would be _really_ nice to have some way to just initialize 
> > > > > that SRCU thing statically. This kind of crud is just crazy.
> > > > 
> > > > I looked into this back when SRCU was first added.  It's essentially 
> > > > impossible to do it, because the per-cpu memory allocation & usage APIs 
> > > > are completely different for the static and the dynamic cases.
> > > 
> > > I don't think that's how you'd want to do it.
> > > 
> > > There's no way to do an initialization of a percpu allocation statically. 
> > > That's pretty obvious.
> > 
> > Hmmm...  What about DEFINE_PER_CPU in include/asm-generic/percpu.h 
> > combined with setup_per_cpu_areas() in init/main.c?  So long as you want 
> > all the CPUs to start with the same initial values, it should work.
> > 
> > > What I'd suggest instead, is to make the allocation dynamic, and make it 
> > > inside the srcu functions (kind of like I did now, but I did it at a 
> > > higher level).
> > > 
> > > Doing it at the high level was trivial right now, but we may well end up 
> > > hitting this problem again if people start using SRCU more. Right now I 
> > > suspect the cpufreq notifier is the only thing that uses SRCU, and it 
> > > already showed this problem with SRCU initializers.
> > > 
> > > So I was more thinking about moving my "one special case high level hack" 
> > > down lower, down to the SRCU level, so that we'll never see _more_ of 
> > > those horrible hacks. We'll still have the hacky thing, but at least it 
> > > will be limited to a single place - the SRCU code itself.
> > 
> > Another possible approach (but equally disgusting) is to use this static 
> > allocation approach, and have the SRCU structure include both a static and 
> > a dynamic percpu pointer together with a flag indicating which should be 
> > used.
> 
> I am actually taking some suggestions you made some months ago.  At the
> time, I rejected them because they injected extra branches into the
> fastpath.  However, recent experience indicates that you (Alan Stern)
> were right and I was wrong -- turns out that the update-side overhead
> cannot be so lightly disregarded, which forces memory barriers (but
> neither atomics nor cache misses) into the fastpath.  If some application
> ends up being provably inconvenienced by the read-side overhead, they old
> implementation can be re-introduced under a different name or some such.
> 
> So, here is my current plan:
> 
> o	Add NULL checks on srcu_struct_array to srcu_read_lock(),
> 	srcu_read_unlock(), and synchronize_srcu.  These will
> 	acquire the mutex and attempt to initialize.  If out
> 	of memory, they will use the new hardluckref field.
> 
> o	Add memory barriers to srcu_read_lock() and srcu_read_unlock().
> 
> o	Also add a memory barrier or two to synchronize_srcu(), which,
> 	in combination with those in srcu_read_lock() and srcu_read_unlock(),
> 	permit removing two of the three synchronize_sched() calls
> 	in synchronize_srcu(), decreasing its latency by roughly
> 	a factor of three.
> 
> 	This change should have the added benefit of making
> 	synchronize_srcu() much easier to understand.
> 
> o	I left out the super-fastpath synchronize_srcu() because
> 	after sleeping on it, it scared me silly.  Might be OK,
> 	but needs careful thought.  The fastpath is of the form:
> 
> 	if (srcu_readers_active(sp) == 0) {
> 		smp_mb();
> 		return;
> 	}
> 
> 	prior to the mutex_lock() in synchronize_srcu().

It works for me, but the overhead is still large. Before it would take
8-12 jiffies for a synchronize_srcu() to complete without there actually
being any reader locks active, now it takes 2-3 jiffies. So it's
definitely faster, and as suspected the loss of two of three
synchronize_sched() cut down the overhead to a third.

It's still too heavy for me, by far the most calls I do to
synchronize_srcu() doesn't have any reader locks pending. I'm still a
big advocate of the fastpath srcu_readers_active() check. I can
understand the reluctance to make it the default, but for my case it's
"safe enough", so if we could either export srcu_readers_active() or
export a synchronize_srcu_fast() (or something like that), then SRCU
would be a good fit for barrier vs plug rework.

> Attached is a patch that compiles, but probably goes down in flames
> otherwise.

Works here :-)

-- 
Jens Axboe


  reply	other threads:[~2006-11-17  9:29 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-16 20:00 BUG: cpufreq notification broken Thomas Gleixner
2006-11-16 20:15 ` [patch] cpufreq: mark cpufreq_tsc() as core_initcall_sync Ingo Molnar
2006-11-16 20:45   ` Thomas Gleixner
2006-11-16 21:47     ` Linus Torvalds
2006-11-16 22:03       ` Alan Stern
2006-11-16 22:21         ` Linus Torvalds
2006-11-17  3:06           ` Alan Stern
2006-11-17  6:51             ` Paul E. McKenney
2006-11-17  9:29               ` Jens Axboe [this message]
2006-11-17 18:39                 ` Oleg Nesterov
2006-11-18  0:28                   ` Paul E. McKenney
2006-11-18 16:15                     ` Alan Stern
2006-11-18 17:14                       ` Paul E. McKenney
2006-11-18 19:34                         ` Oleg Nesterov
2006-11-19 21:26                           ` Paul E. McKenney
2006-11-18 21:00                         ` Alan Stern
2006-11-18 21:25                           ` Oleg Nesterov
2006-11-18 22:13                             ` Alan Stern
2006-11-18 22:46                               ` Oleg Nesterov
2006-11-19 20:12                                 ` Alan Stern
2006-11-19 21:43                           ` Paul E. McKenney
2006-11-20 17:19                             ` Alan Stern
2006-11-20 17:58                               ` Jens Axboe
2006-11-20 19:39                                 ` Alan Stern
2006-11-20 20:13                                   ` Jens Axboe
2006-11-20 21:39                                     ` Alan Stern
2006-11-21  7:39                                       ` Jens Axboe
2006-11-20 18:57                               ` Oleg Nesterov
2006-11-20 20:01                                 ` Alan Stern
2006-11-20 20:51                                   ` Paul E. McKenney
2006-11-21 20:04                                   ` Oleg Nesterov
2006-11-21 20:54                                     ` Alan Stern
2006-11-21 22:07                                     ` Paul E. McKenney
2006-11-20 20:38                                 ` Paul E. McKenney
2006-11-21 16:44                                   ` Oleg Nesterov
2006-11-21 19:56                                     ` Paul E. McKenney
2006-11-21 20:26                                       ` Alan Stern
2006-11-21 23:03                                         ` Paul E. McKenney
2006-11-22  2:17                                           ` Alan Stern
2006-11-22 17:01                                             ` Paul E. McKenney
2006-11-26 22:25                                 ` Oleg Nesterov
2006-11-27 21:10                                   ` Alan Stern
2006-11-28  1:47                                     ` Paul E. McKenney
2006-11-20 19:17                               ` Paul E. McKenney
2006-11-20 20:22                                 ` Alan Stern
2006-11-21 17:55                                   ` Paul E. McKenney
2006-11-21 17:56                             ` Alan Stern
2006-11-21 19:13                               ` Paul E. McKenney
2006-11-21 20:40                                 ` Alan Stern
2006-11-22 18:08                                   ` Paul E. McKenney
2006-11-21 21:01                                 ` Oleg Nesterov
2006-11-22  0:51                                   ` Paul E. McKenney
2006-11-18 18:46                     ` Oleg Nesterov
2006-11-19 21:07                       ` Paul E. McKenney
2006-11-20  7:15                         ` Jens Axboe
2006-11-20 16:59                           ` Paul E. McKenney
2006-11-20 17:55                             ` Jens Axboe
2006-11-20 20:09                               ` Paul E. McKenney
2006-11-20 20:21                                 ` Jens Axboe
2006-11-18 19:02                     ` Oleg Nesterov
2006-11-19 21:23                       ` Paul E. McKenney
2006-11-17 19:15                 ` Paul E. McKenney
2006-11-17 19:27                   ` Alan Stern
2006-11-18  0:38                     ` Paul E. McKenney
2006-11-18  4:33                       ` Alan Stern
2006-11-18  4:51                         ` Andrew Morton
2006-11-18  5:57                           ` Paul E. McKenney
2006-11-19 19:00                 ` Oleg Nesterov
2006-11-19 20:21                   ` Alan Stern
2006-11-19 20:55                     ` Oleg Nesterov
2006-11-19 21:09                       ` Alan Stern
2006-11-19 21:17                         ` Oleg Nesterov
2006-11-19 21:54                           ` Paul E. McKenney
2006-11-19 22:28                             ` Oleg Nesterov
2006-11-20  5:47                               ` Paul E. McKenney
2006-11-19 21:20                       ` Paul E. McKenney
2006-11-19 21:50                         ` Oleg Nesterov
2006-11-19 22:04                           ` Paul E. McKenney
2006-11-23 14:59                   ` Oleg Nesterov
2006-11-23 20:40                     ` Paul E. McKenney
2006-11-23 21:34                       ` Oleg Nesterov
2006-11-23 21:49                       ` Oleg Nesterov
2006-11-27  4:33                         ` Paul E. McKenney
2006-11-24 18:21                     ` Oleg Nesterov
2006-11-24 20:04                       ` Jens Axboe
2006-11-24 20:47                       ` Alan Stern
2006-11-24 21:13                         ` Oleg Nesterov
2006-11-25  3:24                           ` Alan Stern
2006-11-25 17:14                             ` Oleg Nesterov
2006-11-25 22:06                               ` Alan Stern
2006-11-26 21:34                                 ` Oleg Nesterov
2006-11-27  5:02                       ` Paul E. McKenney
2006-11-27 16:11                         ` Oleg Nesterov
2006-11-27 16:56                           ` Oleg Nesterov
2006-11-29 19:29                           ` Paul E. McKenney
2006-11-29 20:16                             ` Oleg Nesterov
2006-11-29 23:08                               ` Paul E. McKenney
2006-11-30  0:01                                 ` Oleg Nesterov
2006-11-17  2:33       ` Paul E. McKenney
2006-11-16 20:52   ` Peter Zijlstra
2006-11-16 21:20   ` Andrew Morton
2006-11-16 21:27     ` Thomas Gleixner
2006-11-20 19:57   ` Linus Torvalds
2006-11-16 20:27 ` BUG: cpufreq notification broken Alan Stern
2006-11-16 21:09   ` Thomas Gleixner
2006-11-16 21:26     ` Alan Stern
2006-11-16 21:36       ` Thomas Gleixner
2006-11-16 21:56         ` Alan Stern

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=20061117092925.GT7164@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=arjan@infradead.org \
    --cc=davem@davemloft.net \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=mingo@elte.hu \
    --cc=oleg@tv-sign.ru \
    --cc=paulmck@us.ibm.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tglx@timesys.com \
    --cc=torvalds@osdl.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;
as well as URLs for NNTP newsgroup(s).