From: Matthew Wilcox <willy@infradead.org>
To: Stephen Brennan <stephen.s.brennan@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Konrad Wilk <konrad.wilk@oracle.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v6 0/1] proc: Allow pid_revalidate() during LOOKUP_RCU
Date: Mon, 4 Oct 2021 19:41:36 +0100 [thread overview]
Message-ID: <YVtK4E/KBMR82hKd@casper.infradead.org> (raw)
In-Reply-To: <YVtF3lm/JjhlnF09@casper.infradead.org>
On Mon, Oct 04, 2021 at 07:20:14PM +0100, Matthew Wilcox wrote:
> On Mon, Oct 04, 2021 at 10:56:28AM -0700, Stephen Brennan wrote:
> > Problem Description:
> >
> > When running running ~128 parallel instances of "TZ=/etc/localtime ps
> > -fe >/dev/null" on a 128CPU machine, the %sys utilization reaches 97%,
> > and perf shows the following code path as being responsible for heavy
> > contention on the d_lockref spinlock:
> >
> > walk_component()
> > lookup_fast()
> > d_revalidate()
> > pid_revalidate() // returns -ECHILD
> > unlazy_child()
> > lockref_get_not_dead(&nd->path.dentry->d_lockref) <-- contention
> >
> > The reason is that pid_revalidate() is triggering a drop from RCU to ref
> > path walk mode. All concurrent path lookups thus try to grab a reference
> > to the dentry for /proc/, before re-executing pid_revalidate() and then
> > stepping into the /proc/$pid directory. Thus there is huge spinlock
> > contention. This patch allows pid_revalidate() to execute in RCU mode,
> > meaning that the path lookup can successfully enter the /proc/$pid
> > directory while still in RCU mode. Later on, the path lookup may still
> > drop into ref mode, but the contention will be much reduced at this
> > point.
> >
> > By applying this patch, %sys utilization falls to around 85% under the
> > same workload, and the number of ps processes executed per unit time
> > increases by 3x-4x. Although this particular workload is a bit
> > contrived, we have seen some large collections of eager monitoring
> > scripts which produced similarly high %sys time due to contention in the
> > /proc directory.
>
> I think it's perhaps also worth noting that this is a performance
> regression relative to ... v5.4? v4.14? I forget the details; do you
> have those to hand, Stephen?
>
> (Yes, this is a stupid workload. Yes, a customer really does have
> this workload.)
OK, it's not a performance regression. My apologies; I misremembered
the ticket. What happens with 4.14 is that the tasks all sleep on
the directory's i_mutex. When i_mutex became i_rwsem, all the lookups
would now contend on the dentry spinlock. That turns "lots of processes
sleeping" into "lots of processes spinning", which looks like a regression
if you're asking "Why has my system time increased a lot?"
prev parent reply other threads:[~2021-10-04 18:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-04 17:56 [PATCH v6 0/1] proc: Allow pid_revalidate() during LOOKUP_RCU Stephen Brennan
2021-10-04 17:56 ` [PATCH v6 1/1] " Stephen Brennan
2021-10-04 18:20 ` [PATCH v6 0/1] " Matthew Wilcox
2021-10-04 18:41 ` Matthew Wilcox [this message]
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=YVtK4E/KBMR82hKd@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=konrad.wilk@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stephen.s.brennan@oracle.com \
--cc=viro@zeniv.linux.org.uk \
/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).