From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Tejun Heo <tj@kernel.org>, John Stultz <john.stultz@linaro.org>,
Ingo Molnar <mingo@redhat.com>,
lkml <linux-kernel@vger.kernel.org>,
Dmitry Shmidt <dimitrysh@google.com>,
Rom Lemarchand <romlem@google.com>,
Colin Cross <ccross@google.com>, Todd Kjos <tkjos@google.com>,
Oleg Nesterov <oleg@redhat.com>
Subject: Re: Severe performance regression w/ 4.4+ on Android due to cgroup locking changes
Date: Thu, 14 Jul 2016 10:15:50 -0700 [thread overview]
Message-ID: <20160714171550.GX7094@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160714164547.GG30154@twins.programming.kicks-ass.net>
On Thu, Jul 14, 2016 at 06:45:47PM +0200, Peter Zijlstra wrote:
> On Thu, Jul 14, 2016 at 09:23:55AM -0700, Paul E. McKenney wrote:
> > Hmmm... How does this handle the following sequence of events for
> > the case where we are not biased towards the reader?
> >
> > o The per-CPU rwsem is set up with RCU_NONE and readers_slow
> > (as opposed to readers_block). The rcu_sync ->gp_state is
> > GP_PENDING, which means that rcu_sync_is_idle() will always
> > return true.
>
> /false/, rcu_sync_is_idle() will always be false, to force us into the
> slowpath.
Ah, got it...
> > o Task A on CPU 0 runs percpu_down_read() to completion, and remains
> > within the critical section. CPU 0's ->refcount is therefore 1.
> >
> > o Task B on CPU 1 does percpu_down_write(), which write-acquires
> > ->rw_sem, does rcu_sync_enter() (which is a no-op due to
> > RCU_NONE), sets ->state to readers_block, and is just now going
> > to wait for readers, which first invokes readers_active_check(),
> > which starts summing the ->refcount for CPUs 0, 1, and 2,
> > obtaining the value 1 so far.
> >
> > o Task C CPU 2 enters percpu_down_read(), disables preemption,
> > increments CPU 2's ->refcount, sees rcu_sync_is_idle() return
> > true (so skips __percpu_down_read()), enables preemption, and
> > enters its critical section.
>
> false, so does __percpu_down_read()
>
> >
> > o Task C migrates to CPU 3 and invokes percpu_up_read(), which
> > disables preemption, sees rcu_sync_is_idle() return true, calls
> > __this_cpu_dec() on CPU 3's ->refcount, and enables preemption.
> > The value of CPU 3's ->refcount is thus (unsigned int)-1.
>
> __percpu_up_read()
>
> >
> > o Task B on CPU 1 continues execution in readers_active_check(), with
> > the full sum being zero.
> >
> > So it looks to me like we have Task A as a writer at the same time that
> > Task A is a reader, which would not be so good.
> >
> > So what am I missing here?
>
> for RCU_NONE we init rsp->gp_state to !0, which makes:
>
> static inline rcu_sync_is_idle()'s
>
> return !rsp->gp_state (aka. rsp->gp_state == 0)
>
> return false.
>
> > And a couple of checkpatch nits below. Yes, I had to apply the patch to
> > figure out what it was doing. ;-)
>
> Yah, too much churn to read :-)
>
> In any case, rest assured you've already gone over this part of the
> patch several times. I repurposed an old percpu-rwsem optimization, Oleg
> recognised it.
OK, in that case I will hold off pending John Stultz's performance
checks.
Thanx, Paul
next prev parent reply other threads:[~2016-07-14 17:15 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-13 0:00 Severe performance regression w/ 4.4+ on Android due to cgroup locking changes John Stultz
2016-07-13 8:21 ` Peter Zijlstra
2016-07-13 14:42 ` Paul E. McKenney
2016-07-13 18:13 ` Dmitry Shmidt
2016-07-13 18:32 ` Paul E. McKenney
2016-07-13 18:21 ` Tejun Heo
2016-07-13 18:33 ` Tejun Heo
2016-07-13 20:13 ` John Stultz
2016-07-13 20:18 ` Tejun Heo
2016-07-13 20:26 ` Peter Zijlstra
2016-07-13 20:39 ` Tejun Heo
2016-07-13 20:51 ` Peter Zijlstra
2016-07-13 21:01 ` Tejun Heo
2016-07-13 21:03 ` Paul E. McKenney
2016-07-13 21:05 ` Tejun Heo
2016-07-13 21:18 ` Paul E. McKenney
2016-07-13 21:42 ` Paul E. McKenney
2016-07-13 21:46 ` John Stultz
2016-07-13 22:17 ` Paul E. McKenney
2016-07-13 22:39 ` John Stultz
2016-07-13 23:02 ` Paul E. McKenney
2016-07-13 23:04 ` Paul E. McKenney
2016-07-14 11:35 ` Tejun Heo
2016-07-14 12:04 ` Peter Zijlstra
2016-07-14 12:08 ` Tejun Heo
2016-07-14 12:20 ` Peter Zijlstra
2016-07-14 15:07 ` Tejun Heo
2016-07-14 15:24 ` Tejun Heo
2016-07-14 16:32 ` Peter Zijlstra
2016-07-14 17:34 ` Oleg Nesterov
2016-07-14 16:54 ` John Stultz
2016-07-13 22:25 ` John Stultz
2016-07-13 22:01 ` Tejun Heo
2016-07-13 22:33 ` Paul E. McKenney
2016-07-14 6:49 ` Peter Zijlstra
2016-07-14 11:20 ` Tejun Heo
2016-07-14 12:11 ` Peter Zijlstra
2016-07-14 15:14 ` Tejun Heo
2016-07-14 13:18 ` Peter Zijlstra
2016-07-14 14:14 ` Peter Zijlstra
2016-07-14 14:58 ` Oleg Nesterov
2016-07-14 16:14 ` Peter Zijlstra
2016-07-14 16:37 ` Peter Zijlstra
2016-07-14 17:05 ` Oleg Nesterov
2016-07-14 16:23 ` Paul E. McKenney
2016-07-14 16:45 ` Peter Zijlstra
2016-07-14 17:15 ` Paul E. McKenney [this message]
2016-07-14 16:43 ` John Stultz
2016-07-14 16:49 ` Peter Zijlstra
2016-07-14 17:02 ` John Stultz
2016-07-14 17:13 ` Oleg Nesterov
2016-07-14 17:30 ` John Stultz
2016-07-14 17:41 ` Oleg Nesterov
2016-07-14 17:51 ` John Stultz
2016-07-14 18:09 ` Oleg Nesterov
2016-07-14 18:36 ` Peter Zijlstra
2016-07-14 19:35 ` Peter Zijlstra
2016-07-13 20:57 ` John Stultz
2016-07-13 20:52 ` Paul E. McKenney
2016-07-13 20:57 ` Peter Zijlstra
2016-07-13 21:08 ` Paul E. McKenney
2016-07-13 21:01 ` Dmitry Shmidt
2016-07-13 21:03 ` John Stultz
2016-07-13 21:05 ` Paul E. McKenney
2016-07-13 20:31 ` Dmitry Shmidt
2016-07-13 20:44 ` Colin Cross
2016-07-13 20:54 ` 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=20160714171550.GX7094@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=ccross@google.com \
--cc=dimitrysh@google.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=romlem@google.com \
--cc=tj@kernel.org \
--cc=tkjos@google.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.