From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org,
Rusty Russell <rusty@rustcorp.com.au>,
Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
tglx@linutronix.de,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [RFC 1/4] module: use rcu_read_lock() while walking over a RCU protected list
Date: Fri, 31 Jul 2015 19:08:05 +0200 [thread overview]
Message-ID: <1438362488-29857-2-git-send-email-bigeasy@linutronix.de> (raw)
In-Reply-To: <1438362488-29857-1-git-send-email-bigeasy@linutronix.de>
The `modules' list uses list_for_each_entry_rcu() itarator.
rcu_readlock() protects here against against module removal invoked from
another CPU while preempt_disable() does not.
I don't understand what syncs in CONFIG_MODULES_TREE_LOOKUP against
module removal. In the other (RCU) case there is synchronize_sched().
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
kernel/module.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/kernel/module.c b/kernel/module.c
index 4d2b82e610e2..a62d2d48cd63 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3979,9 +3979,9 @@ bool is_module_address(unsigned long addr)
{
bool ret;
- preempt_disable();
+ rcu_read_lock();
ret = __module_address(addr) != NULL;
- preempt_enable();
+ rcu_read_unlock();
return ret;
}
@@ -3990,7 +3990,7 @@ bool is_module_address(unsigned long addr)
* __module_address - get the module which contains an address.
* @addr: the address.
*
- * Must be called with preempt disabled or module mutex held so that
+ * Must be called with RCU read or module mutex held so that
* module doesn't get freed during this.
*/
struct module *__module_address(unsigned long addr)
@@ -4024,9 +4024,9 @@ bool is_module_text_address(unsigned long addr)
{
bool ret;
- preempt_disable();
+ rcu_read_lock();
ret = __module_text_address(addr) != NULL;
- preempt_enable();
+ rcu_read_unlock();
return ret;
}
@@ -4035,7 +4035,7 @@ bool is_module_text_address(unsigned long addr)
* __module_text_address - get the module whose code contains an address.
* @addr: the address.
*
- * Must be called with preempt disabled or module mutex held so that
+ * Must be called with RCU read lock or module mutex held so that
* module doesn't get freed during this.
*/
struct module *__module_text_address(unsigned long addr)
--
2.4.6
next prev parent reply other threads:[~2015-07-31 17:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 17:08 [RFC 0/4] use rcu_read_lock() during module list walk Sebastian Andrzej Siewior
2015-07-31 17:08 ` Sebastian Andrzej Siewior [this message]
2015-07-31 17:14 ` [RFC 1/4] module: use rcu_read_lock() while walking over a RCU protected list Peter Zijlstra
2015-07-31 17:08 ` [RFC 2/4] jump_label: use rcu_read_lock() while accessing __module_*() Sebastian Andrzej Siewior
2015-07-31 17:16 ` Peter Zijlstra
2015-07-31 17:08 ` [RFC 3/4] kprobes: Add a RCU lock while invoking __module_text_address() Sebastian Andrzej Siewior
2015-07-31 17:08 ` [RFC 4/4] kprobe: remove preempt_disable() from check_kprobe_address_safe() Sebastian Andrzej Siewior
2015-07-31 17:22 ` [RFC 0/4] use rcu_read_lock() during module list walk 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=1438362488-29857-2-git-send-email-bigeasy@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=ananth@in.ibm.com \
--cc=anil.s.keshavamurthy@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®