From: Catalin Marinas <catalin.marinas@arm.com>
To: He Zhe <zhe.he@windriver.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
tglx@linutronix.de, rostedt@goodmis.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org
Subject: Re: [PATCH v2] kmemleak: Turn kmemleak_lock to raw spinlock on RT
Date: Tue, 18 Dec 2018 15:07:45 +0000 [thread overview]
Message-ID: <20181218150744.GB20197@arrakis.emea.arm.com> (raw)
In-Reply-To: <16ac893a-a080-18a5-e636-7b7668d978b0@windriver.com>
On Tue, Dec 18, 2018 at 06:51:41PM +0800, He Zhe wrote:
> On 2018/12/6 03:14, Sebastian Andrzej Siewior wrote:
> > With raw locks you wouldn't have multiple readers at the same time.
> > Maybe you wouldn't have recursion but since you can't have multiple
> > readers you would add lock contention where was none (because you could
> > have two readers at the same time).
>
> OK. I understand your concern finally. At the commit log said, I wanted to use raw
> rwlock but didn't find the DEFINE helper for it. Thinking it would not be expected to
> have great performance, I turn to use raw spinlock instead. And yes, this would
> introduce worse performance.
Looking through the kmemleak code, I can't really find significant
reader contention. The longest holder of this lock (read) is the scan
thread which is also protected by a scan_mutex, so can't run
concurrently with another scanner (triggered through debugfs). The other
read_lock(&kmemleak_lock) user is find_and_get_object() called from a
few places. However, all such places normally follow a create_object()
call (kmemleak_alloc() and friends) which already performs a
write_lock(&kmemleak_lock), so it needs to wait for the scan thread to
release the kmemleak_lock.
It may be worth running some performance/latency tests during kmemleak
scanning (echo scan > /sys/kernel/debug/kmemleak) but at a quick look,
I don't think we'd see any difference with a raw_spin_lock_t.
With a bit more thinking (though I'll be off until the new year), we
could probably get rid of the kmemleak_lock entirely in scan_block() and
make lookup_object() and the related rbtree code in kmemleak RCU-safe.
--
Catalin
next prev parent reply other threads:[~2018-12-18 15:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-22 9:04 [PATCH v2] kmemleak: Turn kmemleak_lock to raw spinlock on RT zhe.he
2018-11-22 10:16 ` Sebastian Andrzej Siewior
2018-11-23 9:53 ` Sebastian Andrzej Siewior
2018-11-23 11:02 ` Andrea Parri
2018-11-23 11:06 ` Sebastian Andrzej Siewior
2018-11-23 11:31 ` Catalin Marinas
2018-11-23 15:51 ` Steven Rostedt
2018-11-26 8:40 ` Peter Zijlstra
2018-11-24 14:26 ` He Zhe
2018-11-30 18:19 ` Sebastian Andrzej Siewior
2018-12-05 13:53 ` He Zhe
2018-12-05 19:14 ` Sebastian Andrzej Siewior
2018-12-18 10:51 ` He Zhe
2018-12-18 15:07 ` Catalin Marinas [this message]
2018-12-19 15:30 ` Sebastian Andrzej Siewior
2018-12-20 1:46 ` He Zhe
2018-12-18 15:12 ` Catalin Marinas
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=20181218150744.GB20197@arrakis.emea.arm.com \
--to=catalin.marinas@arm.com \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=zhe.he@windriver.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 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).