All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Byungchul Park <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: torvalds@linux-foundation.org, hpa@zytor.com,
	linux-kernel@vger.kernel.org, byungchul.park@lge.com,
	mingo@kernel.org, tglx@linutronix.de, peterz@infradead.org,
	johan@kernel.org
Subject: [tip:locking/core] locking/lockdep: Add a boot parameter allowing unwind in cross-release and disable it by default
Date: Wed, 25 Oct 2017 04:11:48 -0700	[thread overview]
Message-ID: <tip-d141babe4244945f1d001118578e0eb3ce12729d@git.kernel.org> (raw)
In-Reply-To: <1508921765-15396-5-git-send-email-byungchul.park@lge.com>

Commit-ID:  d141babe4244945f1d001118578e0eb3ce12729d
Gitweb:     https://git.kernel.org/tip/d141babe4244945f1d001118578e0eb3ce12729d
Author:     Byungchul Park <byungchul.park@lge.com>
AuthorDate: Wed, 25 Oct 2017 17:56:00 +0900
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 25 Oct 2017 12:19:01 +0200

locking/lockdep: Add a boot parameter allowing unwind in cross-release and disable it by default

Johan Hovold reported a heavy performance regression caused by lockdep
cross-release:

 > Boot time (from "Linux version" to login prompt) had in fact doubled
 > since 4.13 where it took 17 seconds (with my current config) compared to
 > the 35 seconds I now see with 4.14-rc4.
 >
 > I quick bisect pointed to lockdep and specifically the following commit:
 >
 >	28a903f63ec0 ("locking/lockdep: Handle non(or multi)-acquisition
 >	               of a crosslock")
 >
 > which I've verified is the commit which doubled the boot time (compared
 > to 28a903f63ec0^) (added by lockdep crossrelease series [1]).

Currently cross-release performs unwind on every acquisition, but that
is very expensive.

This patch makes unwind optional and disables it by default and only
records acquire_ip.

Full stack traces are sometimes required for full analysis, in which
case a boot paramter, crossrelease_fullstack, can be specified.

On my qemu Ubuntu machine (x86_64, 4 cores, 512M), the regression was
fixed. We measure boot times with 'perf stat --null --repeat 10 $QEMU',
where $QEMU launches a kernel with init=/bin/true:

1. No lockdep enabled:

 Performance counter stats for 'qemu_booting_time.sh bzImage' (10 runs):

       2.756558155 seconds time elapsed                    ( +-  0.09% )

2. Lockdep enabled:

 Performance counter stats for 'qemu_booting_time.sh bzImage' (10 runs):

       2.968710420 seconds time elapsed                    ( +-  0.12% )

3. Lockdep enabled + cross-release enabled:

 Performance counter stats for 'qemu_booting_time.sh bzImage' (10 runs):

       3.153839636 seconds time elapsed                    ( +-  0.31% )

4. Lockdep enabled + cross-release enabled + this patch applied:

 Performance counter stats for 'qemu_booting_time.sh bzImage' (10 runs):

       2.963669551 seconds time elapsed                    ( +-  0.11% )

I.e. lockdep cross-release performance is now indistinguishable from
vanilla lockdep.

Bisected-by: Johan Hovold <johan@kernel.org>
Analyzed-by: Thomas Gleixner <tglx@linutronix.de>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Reported-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Byungchul Park <byungchul.park@lge.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: amir73il@gmail.com
Cc: axboe@kernel.dk
Cc: darrick.wong@oracle.com
Cc: david@fromorbit.com
Cc: hch@infradead.org
Cc: idryomov@gmail.com
Cc: johannes.berg@intel.com
Cc: kernel-team@lge.com
Cc: linux-block@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-xfs@vger.kernel.org
Cc: oleg@redhat.com
Cc: tj@kernel.org
Link: http://lkml.kernel.org/r/1508921765-15396-5-git-send-email-byungchul.park@lge.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 Documentation/admin-guide/kernel-parameters.txt |  3 +++
 kernel/locking/lockdep.c                        | 19 +++++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 0549662..f20ed5e 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -709,6 +709,9 @@
 			It will be ignored when crashkernel=X,high is not used
 			or memory reserved is below 4G.
 
+	crossrelease_fullstack
+			[KNL] Allow to record full stack trace in cross-release
+
 	cryptomgr.notests
                         [KNL] Disable crypto self-tests
 
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index e36e652..160b5d6 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -76,6 +76,15 @@ module_param(lock_stat, int, 0644);
 #define lock_stat 0
 #endif
 
+static int crossrelease_fullstack;
+static int __init allow_crossrelease_fullstack(char *str)
+{
+	crossrelease_fullstack = 1;
+	return 0;
+}
+
+early_param("crossrelease_fullstack", allow_crossrelease_fullstack);
+
 /*
  * lockdep_lock: protects the lockdep graph, the hashes and the
  *               class/list/hash allocators.
@@ -4863,8 +4872,14 @@ static void add_xhlock(struct held_lock *hlock)
 	xhlock->trace.nr_entries = 0;
 	xhlock->trace.max_entries = MAX_XHLOCK_TRACE_ENTRIES;
 	xhlock->trace.entries = xhlock->trace_entries;
-	xhlock->trace.skip = 3;
-	save_stack_trace(&xhlock->trace);
+
+	if (crossrelease_fullstack) {
+		xhlock->trace.skip = 3;
+		save_stack_trace(&xhlock->trace);
+	} else {
+		xhlock->trace.nr_entries = 1;
+		xhlock->trace.entries[0] = hlock->acquire_ip;
+	}
 }
 
 static inline int same_context_xhlock(struct hist_lock *xhlock)

  reply	other threads:[~2017-10-25 11:15 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25  8:55 [PATCH v5 0/9] cross-release: Enhence performance and fix false positives Byungchul Park
2017-10-25  8:55 ` Byungchul Park
2017-10-25  8:55 ` [PATCH v5 1/9] block: use DECLARE_COMPLETION_ONSTACK in submit_bio_wait Byungchul Park
2017-10-25  8:55   ` Byungchul Park
2017-10-25 11:10   ` [tip:locking/core] block: Use DECLARE_COMPLETION_ONSTACK() in submit_bio_wait() tip-bot for Christoph Hellwig
2017-10-25  8:55 ` [PATCH v5 2/9] locking/lockdep: Provide empty lockdep_map structure for !CONFIG_LOCKDEP Byungchul Park
2017-10-25  8:55   ` Byungchul Park
2017-10-25 11:11   ` [tip:locking/core] " tip-bot for Byungchul Park
2017-10-25  8:55 ` [PATCH v5 3/9] completion: Change the prefix of lock name for completion variable Byungchul Park
2017-10-25  8:55   ` Byungchul Park
2017-10-25 11:11   ` [tip:locking/core] locking/lockdep, sched/completions: Change the prefix of lock name for completion variables tip-bot for Byungchul Park
2017-10-25  8:56 ` [PATCH v5 4/9] locking/lockdep: Add a boot parameter allowing unwind in cross-release and disable it by default Byungchul Park
2017-10-25  8:56   ` Byungchul Park
2017-10-25 11:11   ` tip-bot for Byungchul Park [this message]
2017-10-25  8:56 ` [PATCH v5 5/9] locking/lockdep: Remove the BROKEN flag from CONFIG_LOCKDEP_CROSSRELEASE and CONFIG_LOCKDEP_COMPLETIONS Byungchul Park
2017-10-25  8:56   ` Byungchul Park
2017-10-25 11:12   ` [tip:locking/core] " tip-bot for Byungchul Park
2017-10-25  8:56 ` [PATCH v5 6/9] locking/lockdep: Introduce CONFIG_BOOTPARAM_LOCKDEP_CROSSRELEASE_FULLSTACK Byungchul Park
2017-10-25  8:56   ` Byungchul Park
2017-10-25 11:12   ` [tip:locking/core] locking/lockdep: Introduce CONFIG_BOOTPARAM_LOCKDEP_CROSSRELEASE_FULLSTACK=y tip-bot for Byungchul Park
2017-10-25  8:56 ` [PATCH v5 7/9] completion: Add support for initializing completion with lockdep_map Byungchul Park
2017-10-25  8:56   ` Byungchul Park
2017-10-25 11:12   ` [tip:locking/core] sched/completions: Add support for initializing completions " tip-bot for Byungchul Park
2017-10-25  8:56 ` [PATCH v5 8/9] workqueue: Remove unnecessary acquisitions wrt workqueue flush Byungchul Park
2017-10-25  8:56   ` Byungchul Park
2017-10-25 11:13   ` [tip:locking/core] workqueue: Remove now redundant lock acquisitions wrt. workqueue flushes tip-bot for Byungchul Park
2017-10-25  8:56 ` [PATCH v5 9/9] block: Assign a lock_class per gendisk used for wait_for_completion() Byungchul Park
2017-10-25  8:56   ` Byungchul Park
2017-10-25 10:13   ` Ingo Molnar
2017-10-25 10:13     ` Ingo Molnar
2017-10-25 10:13     ` Ingo Molnar
2017-10-25 10:13     ` Ingo Molnar
2017-10-25 18:20     ` Jens Axboe
2017-10-25 18:20       ` Jens Axboe
2017-10-26  5:50       ` Ingo Molnar
2017-10-26  5:50         ` Ingo Molnar
2017-10-26  5:58         ` Byungchul Park
2017-10-26  5:58           ` Byungchul Park
2017-10-26  9:31   ` [tip:locking/core] block, locking/lockdep: " tip-bot for Byungchul Park

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=tip-d141babe4244945f1d001118578e0eb3ce12729d@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=byungchul.park@lge.com \
    --cc=hpa@zytor.com \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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 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.