[PATCH 0/8] latched RB-trees and __module_address()
From: Peter Zijlstra
Date: Wed Mar 18 2015 - 09:54:51 EST
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)
{
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/