All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] latched RB-trees and __module_address()
@ 2015-03-18 13:36 Peter Zijlstra
  2015-03-18 13:36 ` [PATCH 1/8] module: Sanitize RCU usage and locking Peter Zijlstra
                   ` (8 more replies)
  0 siblings, 9 replies; 28+ messages in thread
From: Peter Zijlstra @ 2015-03-18 13:36 UTC (permalink / raw)
  To: mingo, rusty, mathieu.desnoyers, oleg, paulmck, torvalds
  Cc: linux-kernel, andi, rostedt, tglx, peterz

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)
 {


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2015-03-20  9:50 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-18 13:36 [PATCH 0/8] latched RB-trees and __module_address() Peter Zijlstra
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

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.