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, laijs@cn.fujitsu.com,
linux@horizon.com, peterz@infradead.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH v6 7/9] module: Make the mod_tree stuff conditional on PERF_EVENTS || TRACING
Date: Wed, 06 May 2015 15:51:46 +0200 [thread overview]
Message-ID: <20150506135643.894795755@infradead.org> (raw)
In-Reply-To: <20150506135139.751304211@infradead.org>
[-- Attachment #1: peterz-modtree-optional.patch --]
[-- Type: text/plain, Size: 3661 bytes --]
Andrew worried about the overhead on small systems; only use the fancy
code when either perf or tracing is enabled.
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Requested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/module.h | 4 +++-
init/Kconfig | 4 ++++
kernel/module.c | 30 ++++++++++++++++++++++++++++--
3 files changed, 35 insertions(+), 3 deletions(-)
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -282,7 +282,7 @@ struct module {
*
* Cacheline align here, such that:
* module_init, module_core, init_size, core_size,
- * init_text_size, core_text_size and ltn_core.node[0]
+ * init_text_size, core_text_size and mtn_core::{mod,node[0]}
* are on the same cacheline.
*/
void *module_init ____cacheline_aligned;
@@ -296,6 +296,7 @@ struct module {
/* The size of the executable code in each section. */
unsigned int init_text_size, core_text_size;
+#ifdef CONFIG_MODULES_TREE_LOOKUP
/*
* We want mtn_core::{mod,node[0]} to be in the same cacheline as the
* above entries such that a regular lookup will only touch one
@@ -303,6 +304,7 @@ struct module {
*/
struct mod_tree_node mtn_core;
struct mod_tree_node mtn_init;
+#endif
/* Size of RO sections of the module (text+rodata) */
unsigned int init_ro_size, core_ro_size;
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1978,6 +1978,10 @@ endchoice
endif # MODULES
+config MODULES_TREE_LOOKUP
+ def_bool y
+ depends on PERF_EVENTS || TRACING
+
config INIT_ALL_POSSIBLE
bool
help
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -102,6 +102,8 @@ DEFINE_MUTEX(module_mutex);
EXPORT_SYMBOL_GPL(module_mutex);
static LIST_HEAD(modules);
+#ifdef CONFIG_MODULES_TREE_LOOKUP
+
/*
* Use a latched RB-tree for __module_address(); this allows us to use
* RCU-sched lookups of the address from any context.
@@ -112,6 +114,10 @@ static LIST_HEAD(modules);
*
* Because init ranges are short lived we mark them unlikely and have placed
* them outside the critical cacheline in struct module.
+ *
+ * This is conditional on PERF_EVENTS || TRACING because those can really hit
+ * __module_address() hard by doing a lot of stack unwinding; potentially from
+ * NMI context.
*/
static __always_inline unsigned long __mod_tree_val(struct latch_tree_node *n)
@@ -192,7 +198,7 @@ static void mod_tree_remove(struct modul
mod_tree_remove_init(mod);
}
-static struct module *mod_tree_find(unsigned long addr)
+static struct module *mod_find(unsigned long addr)
{
struct latch_tree_node *ltn;
@@ -203,6 +209,26 @@ static struct module *mod_tree_find(unsi
return container_of(ltn, struct mod_tree_node, node)->mod;
}
+#else /* MODULES_TREE_LOOKUP */
+
+static void mod_tree_insert(struct module *mod) { }
+static void mod_tree_remove_init(struct module *mod) { }
+static void mod_tree_remove(struct module *mod) { }
+
+static struct module *mod_find(unsigned long addr)
+{
+ struct module *mod;
+
+ list_for_each_entry_rcu(mod, &modules, list) {
+ if (within_module(addr, mod))
+ return mod;
+ }
+
+ return NULL;
+}
+
+#endif /* MODULES_TREE_LOOKUP */
+
#ifdef CONFIG_KGDB_KDB
struct list_head *kdb_modules = &modules; /* kdb needs the list of modules */
#endif /* CONFIG_KGDB_KDB */
@@ -3963,7 +3989,7 @@ struct module *__module_address(unsigned
if (addr < module_addr_min || addr > module_addr_max)
return NULL;
- mod = mod_tree_find(addr);
+ mod = mod_find(addr);
if (mod) {
BUG_ON(!within_module(addr, mod));
if (mod->state == MODULE_STATE_UNFORMED)
next prev parent reply other threads:[~2015-05-06 14:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 13:51 [PATCH v6 0/9] latched RB-trees and __module_address() Peter Zijlstra
2015-05-06 13:51 ` [PATCH v6 1/9] rbtree: Make lockless searches non-fatal Peter Zijlstra
2015-05-06 13:51 ` [PATCH v6 2/9] seqlock: Better document raw_write_seqcount_latch() Peter Zijlstra
2015-05-06 13:51 ` [PATCH v6 3/9] rcu: Move lockless_dereference() out of rcupdate.h Peter Zijlstra
2015-05-06 13:51 ` [PATCH v6 4/9] seqlock: Introduce raw_read_seqcount_latch() Peter Zijlstra
2015-05-06 13:51 ` [PATCH v6 5/9] rbtree: Implement generic latch_tree Peter Zijlstra
2015-05-06 13:51 ` [PATCH v6 6/9] module: Optimize __module_address() using a latched RB-tree Peter Zijlstra
2015-05-06 13:51 ` Peter Zijlstra [this message]
2015-05-06 13:51 ` [PATCH v6 8/9] module: Use __module_address() for module_address_lookup() Peter Zijlstra
2015-05-06 13:51 ` [PATCH v6 9/9] module: Rework module_addr_{min,max} Peter Zijlstra
2015-05-07 1:20 ` [PATCH v6 0/9] latched RB-trees and __module_address() Rusty Russell
2015-05-07 19:28 ` Ingo Molnar
2015-05-08 17:42 ` Rusty Russell
2015-05-12 11:52 ` 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=20150506135643.894795755@infradead.org \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@horizon.com \
--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
Powered by JetHome