[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <491D6B4EAD0A714894D8AD22F4BDE043032910@SCYBEXDAG04.amd.com>
Date: Wed, 7 Mar 2012 16:48:38 +0000
From: "Chen, Dennis (SRDC SW)" <Dennis1.Chen@....com>
To: "jbaron@...hat.com" <jbaron@...hat.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 2/2] Refine mutex and rcu method in module.c,
kernel<3.2.9>
Adding dynamic debug maintainer -- Jason Baron...
-----Original Message-----
From: Chen, Dennis (SRDC SW)
Sent: Wednesday, March 07, 2012 10:57 PM
To: linux-kernel@...r.kernel.org
Cc: Chen, Dennis (SRDC SW)
Subject: [PATCH 2/2] Refine mutex and rcu method in module.c, kernel<3.2.9>
1. Add protection code for module_bug_list readers
2. Add a new module_bug_mutex as the mutex of the module_bug_list writers
--- lib/bug.ori.c 2012-03-07 20:42:56.454850872 +0800
+++ lib/bug.c 2012-03-07 20:58:48.562825887 +0800
@@ -42,6 +42,7 @@
#include <linux/kernel.h>
#include <linux/bug.h>
#include <linux/sched.h>
+#include <linux/rcupdate.h>
extern const struct bug_entry __start___bug_table[], __stop___bug_table[];
@@ -56,19 +57,24 @@
#ifdef CONFIG_MODULES
static LIST_HEAD(module_bug_list);
+static DEFINE_MUTEX(module_bug_mutex);
static const struct bug_entry *module_find_bug(unsigned long bugaddr)
{
struct module *mod;
- list_for_each_entry(mod, &module_bug_list, bug_list) {
+ rcu_read_lock();
+ list_for_each_entry_rcu(mod, &module_bug_list, bug_list) {
const struct bug_entry *bug = mod->bug_table;
unsigned i;
for (i = 0; i < mod->num_bugs; ++i, ++bug)
- if (bugaddr == bug_addr(bug))
+ if (bugaddr == bug_addr(bug)){
+ rcu_read_unlock();
return bug;
+ }
}
+ rcu_read_unlock();
return NULL;
}
@@ -96,7 +102,9 @@
* traversals, but since we only traverse on BUG()s, a spinlock
* could potentially lead to deadlock and thus be counter-productive.
*/
- list_add(&mod->bug_list, &module_bug_list);
+ mutex_lock(&module_bug_mutex);
+ list_add_rcu(&mod->bug_list, &module_bug_list);
+ mutex_unlock(&module_bug_mutex);
}
void module_bug_cleanup(struct module *mod)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists