From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933315AbbCRNyt (ORCPT ); Wed, 18 Mar 2015 09:54:49 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:34082 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755814AbbCRNyk (ORCPT ); Wed, 18 Mar 2015 09:54:40 -0400 Message-Id: <20150318133626.526984618@infradead.org> User-Agent: quilt/0.61-1 Date: Wed, 18 Mar 2015 14:36:26 +0100 From: Peter Zijlstra 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() Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 +#include + +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) {