From: Peter Zijlstra <peterz@infradead.org>
To: mingo@kernel.org, rusty@rustcorp.com.au,
mathieu.desnoyers@efficios.com, oleg@redhat.com,
paulmck@linux.vnet.ibm.com, torvalds@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, andi@firstfloor.org,
rostedt@goodmis.org, tglx@linutronix.de, peterz@infradead.org
Subject: [PATCH 0/8] latched RB-trees and __module_address()
Date: Wed, 18 Mar 2015 14:36:26 +0100 [thread overview]
Message-ID: <20150318133626.526984618@infradead.org> (raw)
This series is aimed at making __module_address() go fast(er).
On the way there is:
- annotates and sanitizes module locking
- introduces the latched RB-tree
- employs it to make __module_address() go fast.
I've build and boot tested this on x86_64 with modules and lockdep
enabled. Performance numbers (below) are done with lockdep disabled.
As mentioned in the previous posting; the reason for writing the latched
RB-tree as generic code is mostly for clarity/documentation purposes; as
there are a number of separate and non trivial bits to the complete
solution.
As measued on my ivb-ep system with 84 modules loaded; prior to patching
the test module (below) reports:
avg +- stdev
Before: 1689 +- 287 [ns] per __module_address() call
After: 137 +- 38 [ns] per __module_address() call
Note; I have also tested things like: perf record -a -g modprobe
mod_test, to make 'sure' to hit some of the more interesting paths.
---
kernel/Makefile | 2 ++
kernel/mod_test.c | 30 ++++++++++++++++++++++++++++++
kernel/module.c | 3 ++-
3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/kernel/Makefile b/kernel/Makefile
index 1408b33..ec69606 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -28,6 +28,8 @@ obj-y += irq/
obj-y += rcu/
obj-y += livepatch/
+obj-m += mod_test.o
+
obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
obj-$(CONFIG_FREEZER) += freezer.o
obj-$(CONFIG_PROFILING) += profile.o
diff --git a/kernel/mod_test.c b/kernel/mod_test.c
index e69de29..cf32cfc 100644
--- a/kernel/mod_test.c
+++ b/kernel/mod_test.c
@@ -0,0 +1,30 @@
+
+#include <linux/module.h>
+#include <linux/sched.h>
+
+MODULE_LICENSE("GPL");
+
+extern unsigned long module_addr_max;
+
+static int __init test_init(void)
+{
+ u64 t1, t2;
+
+ local_irq_disable();
+ t1 = sched_clock();
+ barrier();
+ t1 = sched_clock() - t1;
+
+ barrier();
+
+ t2 = sched_clock();
+ (void)__module_address(module_addr_max);
+ t2 = sched_clock() - t2;
+ local_irq_enable();
+
+ printk("time: %Lu %Lu %Lu\n", t2 - t1, t1, t2);
+
+ return -EINVAL;
+}
+
+module_init(test_init);
diff --git a/kernel/module.c b/kernel/module.c
index b3d634e..6423dc2 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -155,7 +155,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
/* Bounds of module allocation, for speeding __module_address.
* Protected by module_mutex. */
-static unsigned long module_addr_min = -1UL, module_addr_max = 0;
+unsigned long module_addr_min = -1UL, module_addr_max = 0;
+EXPORT_SYMBOL(module_addr_max);
int register_module_notifier(struct notifier_block *nb)
{
next reply other threads:[~2015-03-18 13:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-18 13:36 Peter Zijlstra [this message]
2015-03-18 13:36 ` [PATCH 1/8] module: Sanitize RCU usage and locking Peter Zijlstra
2015-03-20 3:36 ` Rusty Russell
2015-03-18 13:36 ` [PATCH 2/8] module: Annotate module version magic Peter Zijlstra
2015-03-18 13:36 ` [PATCH 3/8] module, jump_label: Fix module locking Peter Zijlstra
2015-03-20 4:26 ` Rusty Russell
2015-03-20 9:11 ` Peter Zijlstra
2015-03-18 13:36 ` [PATCH 4/8] rbtree: Make lockless searches non-fatal Peter Zijlstra
2015-03-18 13:36 ` [PATCH 5/8] seqlock: Better document raw_write_seqcount_latch() Peter Zijlstra
2015-03-18 14:29 ` Mathieu Desnoyers
2015-03-18 14:50 ` Peter Zijlstra
2015-03-18 13:36 ` [PATCH 6/8] rbtree: Implement generic latch_tree Peter Zijlstra
2015-03-18 16:20 ` Ingo Molnar
2015-03-19 5:14 ` Andrew Morton
2015-03-19 7:25 ` Peter Zijlstra
2015-03-19 20:58 ` Andrew Morton
2015-03-19 21:36 ` Steven Rostedt
2015-03-19 21:38 ` Steven Rostedt
2015-03-19 21:47 ` Andrew Morton
2015-03-19 21:54 ` Steven Rostedt
2015-03-19 22:12 ` Peter Zijlstra
2015-03-19 22:04 ` Peter Zijlstra
2015-03-20 9:50 ` Peter Zijlstra
2015-03-19 22:10 ` Peter Zijlstra
2015-03-18 13:36 ` [PATCH 7/8] module: Optimize __module_address() using a latched RB-tree Peter Zijlstra
2015-03-18 13:36 ` [PATCH 8/8] module: Use __module_address() for module_address_lookup() Peter Zijlstra
2015-03-18 14:21 ` [PATCH 0/8] latched RB-trees and __module_address() Christoph Hellwig
2015-03-18 14:38 ` Peter Zijlstra
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=20150318133626.526984618@infradead.org \
--to=peterz@infradead.org \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®