public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
	rusty <rusty@rustcorp.com.au>
Subject: Re: [PATCH] tracing/profile: Fix profile_disable vs module_unload
Date: Wed, 26 Aug 2009 08:52:42 +0200	[thread overview]
Message-ID: <1251269562.7538.1222.camel@twins> (raw)
In-Reply-To: <1251269207.7538.1217.camel@twins>

On Wed, 2009-08-26 at 08:46 +0200, Peter Zijlstra wrote:

> Aahh, I see the bug, its only ftrace that knows about the module, not
> tracepoints themselves, _that_ needs fixing.

These are the bits I hacked up until I figured out the above bug.

---
 include/linux/ftrace_event.h |    2 +-
 include/linux/module.h       |   18 ++++++++++++++----
 kernel/module.c              |    9 +--------
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index df5b085..d86d60c 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -122,7 +122,7 @@ struct ftrace_event_call {
 	struct list_head	fields;
 	int			filter_active;
 	struct event_filter	*filter;
-	void			*mod;
+	struct module		*mod;
 	void			*data;
 
 	atomic_t		profile_count;
diff --git a/include/linux/module.h b/include/linux/module.h
index 86863cd..09e2b88 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -409,16 +409,26 @@ struct module *__module_address(unsigned long addr);
 bool is_module_address(unsigned long addr);
 bool is_module_text_address(unsigned long addr);
 
+static inline 
+int __within_module(unsigned long addr, void *start, unsigned long size)
+{
+	return ((void *)addr >= start && (void *)addr < start + size);
+}
+
 static inline int within_module_core(unsigned long addr, struct module *mod)
 {
-	return (unsigned long)mod->module_core <= addr &&
-	       addr < (unsigned long)mod->module_core + mod->core_size;
+	return __within_module(addr, mod->module_core, mod->core_size);
 }
 
 static inline int within_module_init(unsigned long addr, struct module *mod)
 {
-	return (unsigned long)mod->module_init <= addr &&
-	       addr < (unsigned long)mod->module_init + mod->init_size;
+	return __within_module(addr, mod->module_init, mod->init_size);
+}
+
+static inline int within_module_text(unsigned long addr, struct module *mod)
+{
+	return __within_module(addr, mod->module_init, mod->init_text_size) ||
+	       __within_module(addr, mod->core_init, mod->core_text_size);
 }
 
 /* Search for module by name: must hold module_mutex. */
diff --git a/kernel/module.c b/kernel/module.c
index b182143..822adb6 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2493,11 +2493,6 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
 	return 0;
 }
 
-static inline int within(unsigned long addr, void *start, unsigned long size)
-{
-	return ((void *)addr >= start && (void *)addr < start + size);
-}
-
 #ifdef CONFIG_KALLSYMS
 /*
  * This ignores the intensely annoying "mapping symbols" found
@@ -2912,9 +2907,7 @@ struct module *__module_text_address(unsigned long addr)
 {
 	struct module *mod = __module_address(addr);
 	if (mod) {
-		/* Make sure it's within the text section. */
-		if (!within(addr, mod->module_init, mod->init_text_size)
-		    && !within(addr, mod->module_core, mod->core_text_size))
+		if (!within_module_text(addr, mod))
 			mod = NULL;
 	}
 	return mod;


  reply	other threads:[~2009-08-26  6:53 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-24  4:19 [PATCH] tracing/profile: Fix profile_disable vs module_unload Li Zefan
2009-08-24  6:01 ` Peter Zijlstra
2009-08-24  6:22   ` Li Zefan
2009-08-24  6:56     ` Peter Zijlstra
2009-08-24  9:24       ` Ingo Molnar
2009-08-24  9:27         ` Peter Zijlstra
2009-08-24 16:13           ` Steven Rostedt
2009-08-25  5:22           ` Li Zefan
2009-08-25  6:21             ` Peter Zijlstra
2009-08-25  6:33               ` Li Zefan
2009-08-25  6:40                 ` Peter Zijlstra
2009-08-25  9:05                   ` Ingo Molnar
2009-08-25  9:12                     ` Peter Zijlstra
2009-08-25 10:22                       ` Ingo Molnar
2009-08-25 10:32                         ` Peter Zijlstra
2009-08-25 10:39                           ` Ingo Molnar
2009-08-25 10:47                             ` Peter Zijlstra
2009-08-25 14:52                               ` Peter Zijlstra
2009-08-26  6:18                                 ` Li Zefan
2009-08-26  6:46                                   ` Peter Zijlstra
2009-08-26  6:52                                     ` Peter Zijlstra [this message]
2009-08-26  7:01                                     ` Peter Zijlstra
2009-08-26  7:10                                       ` Li Zefan
2009-08-26  7:26                                         ` Peter Zijlstra
2009-08-26  7:31                                           ` Li Zefan
2009-08-26  7:39                                             ` Peter Zijlstra
2009-08-26  7:44                                               ` Li Zefan
2009-08-26 14:37                                         ` Steven Rostedt
2009-08-26 16:46                                           ` Mathieu Desnoyers
2009-08-26 17:48                                             ` Steven Rostedt
2009-08-26 18:01                                               ` Mathieu Desnoyers
2009-08-26 18:17                                                 ` Mathieu Desnoyers
2009-08-26 19:48                                                   ` Steven Rostedt
2009-08-26 19:53                                                     ` Mathieu Desnoyers
2009-08-26 21:21                                                       ` Steven Rostedt
2009-08-26 22:29                                                         ` Mathieu Desnoyers
2009-08-27  1:53                                                     ` Li Zefan
2009-08-27  2:13                                                       ` Steven Rostedt
2009-08-27 14:39                                                         ` Mathieu Desnoyers
2009-08-27 14:56                                                           ` Steven Rostedt
2009-08-27 15:11                                                             ` Mathieu Desnoyers
2009-08-27 15:51                                                               ` Steven Rostedt
2009-08-27 15:59                                                                 ` Mathieu Desnoyers
2009-08-27 16:03                                                                   ` Steven Rostedt
2009-08-27  6:25                                                     ` Peter Zijlstra
2009-08-27 15:57                                                       ` Steven Rostedt
2009-08-27 16:04                                                         ` Peter Zijlstra
2009-08-27 16:18                                                           ` Steven Rostedt
2009-08-27  1:01                                                 ` Li Zefan
2009-08-26 19:14                                             ` Peter Zijlstra
2009-08-26 19:44                                               ` Mathieu Desnoyers
2009-09-13 15:02 ` [tip:tracing/core] tracing/profile: fix " tip-bot for Li Zefan

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=1251269562.7538.1222.camel@twins \
    --to=peterz@infradead.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --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