public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@infradead.org>
To: rusty@rustcorp.com.au
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org
Subject: [PATCH] modules: Take a shortcut for checking if an address is in a module
Date: Tue, 10 Jun 2008 13:05:19 -0700	[thread overview]
Message-ID: <20080610130519.21bc66f3@infradead.org> (raw)



From: Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH] modules: Take a shortcut for checking if an address is in a module

Various pieces of the kernel (lockdep, latencytop, etc) tend to store
backtraces, sometimes at a relatively high frequency. In itself this
isn't a big performance deal (after all you're using diagnostics features),
but there have been some complaints from people who have over 100 modules
loaded that this is a tad too slow.

This is due to the new backtracer code which looks at every slot on the stack
to see if it's a kernel/module text address, so that's 1024 slots.
1024 times 100 modules... that's a lot of list walking.

On some architectures (esp x86), the modules go into a specific range of
virtual memory; this patch adds a check just before walking the module
list to see if the address that's asked for is in the module range in
the first place, and manages to skip the list walk for the (common) case
of this not being so.


Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 kernel/module.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 5f80478..b7dbef1 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2595,6 +2595,21 @@ struct module *__module_text_address(unsigned long addr)
 {
 	struct module *mod;
 
+	/* 
+	 * shortcut for the architectures that have a well
+	 * defined start/end virtual address of modules:
+	 * we can decide something for sure isn't a module
+	 * without walking the potentially long module list.
+	 */
+#ifdef MODULES_VADDR
+	if (addr < MODULES_VADDR)
+		return NULL;
+#endif
+#ifdef MODULES_END
+	if (addr > MODULES_END)
+		return NULL;
+#endif
+
 	list_for_each_entry(mod, &modules, list)
 		if (within(addr, mod->module_init, mod->init_text_size)
 		    || within(addr, mod->module_core, mod->core_text_size))
-- 
1.5.4.5


-- 
If you want to reach me at my work email, use arjan@linux.intel.com
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

             reply	other threads:[~2008-06-10 20:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-10 20:05 Arjan van de Ven [this message]
2008-06-11 11:12 ` [PATCH] modules: Take a shortcut for checking if an address is in a module Rusty Russell
2008-06-11 15:18   ` Arjan van de Ven
2008-06-11 18:54     ` Vegard Nossum
2008-06-18  9:57       ` Ingo Molnar
2008-06-18 10:24         ` Peter Zijlstra
2008-06-18 12:27           ` Rusty Russell
2008-06-12  0:20     ` Rusty Russell
2008-06-26  5:46       ` Rusty Russell
2008-06-26 11:48         ` Ingo Molnar
2008-06-18 10:00     ` Ingo Molnar

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=20080610130519.21bc66f3@infradead.org \
    --to=arjan@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rusty@rustcorp.com.au \
    /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