aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorAshutosh Naik <ashutosh.naik@gmail.com>2006-03-23 06:00:46 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 10:38:14 -0500
commit6389a385114ae358693f213266de6468ea116c77 (patch)
tree7fafbc62a71887202d09b0748148fa79211a0a65 /kernel/module.c
parentcf8b8975c3c35d1269bf6f1c6f2ae4efb6909607 (diff)
[PATCH] kernel/module.c Semaphore to Mutex Conversion for module_mutex
This patch converts the module_mutex semaphore to a mutex. Signed-off-by: Ashutosh Naik <ashutosh.naik@gmail.com> Cc: Arjan van de Ven <arjan@infradead.org> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/kernel/module.c b/kernel/module.c
index de6312da6bb5..fb404299082e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -61,7 +61,7 @@
61static DEFINE_SPINLOCK(modlist_lock); 61static DEFINE_SPINLOCK(modlist_lock);
62 62
63/* List of modules, protected by module_mutex AND modlist_lock */ 63/* List of modules, protected by module_mutex AND modlist_lock */
64static DECLARE_MUTEX(module_mutex); 64static DEFINE_MUTEX(module_mutex);
65static LIST_HEAD(modules); 65static LIST_HEAD(modules);
66 66
67static DEFINE_MUTEX(notify_mutex); 67static DEFINE_MUTEX(notify_mutex);
@@ -602,7 +602,7 @@ static void free_module(struct module *mod);
602static void wait_for_zero_refcount(struct module *mod) 602static void wait_for_zero_refcount(struct module *mod)
603{ 603{
604 /* Since we might sleep for some time, drop the semaphore first */ 604 /* Since we might sleep for some time, drop the semaphore first */
605 up(&module_mutex); 605 mutex_unlock(&module_mutex);
606 for (;;) { 606 for (;;) {
607 DEBUGP("Looking at refcount...\n"); 607 DEBUGP("Looking at refcount...\n");
608 set_current_state(TASK_UNINTERRUPTIBLE); 608 set_current_state(TASK_UNINTERRUPTIBLE);
@@ -611,7 +611,7 @@ static void wait_for_zero_refcount(struct module *mod)
611 schedule(); 611 schedule();
612 } 612 }
613 current->state = TASK_RUNNING; 613 current->state = TASK_RUNNING;
614 down(&module_mutex); 614 mutex_lock(&module_mutex);
615} 615}
616 616
617asmlinkage long 617asmlinkage long
@@ -628,7 +628,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
628 return -EFAULT; 628 return -EFAULT;
629 name[MODULE_NAME_LEN-1] = '\0'; 629 name[MODULE_NAME_LEN-1] = '\0';
630 630
631 if (down_interruptible(&module_mutex) != 0) 631 if (mutex_lock_interruptible(&module_mutex) != 0)
632 return -EINTR; 632 return -EINTR;
633 633
634 mod = find_module(name); 634 mod = find_module(name);
@@ -677,14 +677,14 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
677 677
678 /* Final destruction now noone is using it. */ 678 /* Final destruction now noone is using it. */
679 if (mod->exit != NULL) { 679 if (mod->exit != NULL) {
680 up(&module_mutex); 680 mutex_unlock(&module_mutex);
681 mod->exit(); 681 mod->exit();
682 down(&module_mutex); 682 mutex_lock(&module_mutex);
683 } 683 }
684 free_module(mod); 684 free_module(mod);
685 685
686 out: 686 out:
687 up(&module_mutex); 687 mutex_unlock(&module_mutex);
688 return ret; 688 return ret;
689} 689}
690 690
@@ -1973,13 +1973,13 @@ sys_init_module(void __user *umod,
1973 return -EPERM; 1973 return -EPERM;
1974 1974
1975 /* Only one module load at a time, please */ 1975 /* Only one module load at a time, please */
1976 if (down_interruptible(&module_mutex) != 0) 1976 if (mutex_lock_interruptible(&module_mutex) != 0)
1977 return -EINTR; 1977 return -EINTR;
1978 1978
1979 /* Do all the hard work */ 1979 /* Do all the hard work */
1980 mod = load_module(umod, len, uargs); 1980 mod = load_module(umod, len, uargs);
1981 if (IS_ERR(mod)) { 1981 if (IS_ERR(mod)) {
1982 up(&module_mutex); 1982 mutex_unlock(&module_mutex);
1983 return PTR_ERR(mod); 1983 return PTR_ERR(mod);
1984 } 1984 }
1985 1985
@@ -1988,7 +1988,7 @@ sys_init_module(void __user *umod,
1988 stop_machine_run(__link_module, mod, NR_CPUS); 1988 stop_machine_run(__link_module, mod, NR_CPUS);
1989 1989
1990 /* Drop lock so they can recurse */ 1990 /* Drop lock so they can recurse */
1991 up(&module_mutex); 1991 mutex_unlock(&module_mutex);
1992 1992
1993 mutex_lock(&notify_mutex); 1993 mutex_lock(&notify_mutex);
1994 notifier_call_chain(&module_notify_list, MODULE_STATE_COMING, mod); 1994 notifier_call_chain(&module_notify_list, MODULE_STATE_COMING, mod);
@@ -2007,15 +2007,15 @@ sys_init_module(void __user *umod,
2007 mod->name); 2007 mod->name);
2008 else { 2008 else {
2009 module_put(mod); 2009 module_put(mod);
2010 down(&module_mutex); 2010 mutex_lock(&module_mutex);
2011 free_module(mod); 2011 free_module(mod);
2012 up(&module_mutex); 2012 mutex_unlock(&module_mutex);
2013 } 2013 }
2014 return ret; 2014 return ret;
2015 } 2015 }
2016 2016
2017 /* Now it's a first class citizen! */ 2017 /* Now it's a first class citizen! */
2018 down(&module_mutex); 2018 mutex_lock(&module_mutex);
2019 mod->state = MODULE_STATE_LIVE; 2019 mod->state = MODULE_STATE_LIVE;
2020 /* Drop initial reference. */ 2020 /* Drop initial reference. */
2021 module_put(mod); 2021 module_put(mod);
@@ -2023,7 +2023,7 @@ sys_init_module(void __user *umod,
2023 mod->module_init = NULL; 2023 mod->module_init = NULL;
2024 mod->init_size = 0; 2024 mod->init_size = 0;
2025 mod->init_text_size = 0; 2025 mod->init_text_size = 0;
2026 up(&module_mutex); 2026 mutex_unlock(&module_mutex);
2027 2027
2028 return 0; 2028 return 0;
2029} 2029}
@@ -2113,7 +2113,7 @@ struct module *module_get_kallsym(unsigned int symnum,
2113{ 2113{
2114 struct module *mod; 2114 struct module *mod;
2115 2115
2116 down(&module_mutex); 2116 mutex_lock(&module_mutex);
2117 list_for_each_entry(mod, &modules, list) { 2117 list_for_each_entry(mod, &modules, list) {
2118 if (symnum < mod->num_symtab) { 2118 if (symnum < mod->num_symtab) {
2119 *value = mod->symtab[symnum].st_value; 2119 *value = mod->symtab[symnum].st_value;
@@ -2121,12 +2121,12 @@ struct module *module_get_kallsym(unsigned int symnum,
2121 strncpy(namebuf, 2121 strncpy(namebuf,
2122 mod->strtab + mod->symtab[symnum].st_name, 2122 mod->strtab + mod->symtab[symnum].st_name,
2123 127); 2123 127);
2124 up(&module_mutex); 2124 mutex_unlock(&module_mutex);
2125 return mod; 2125 return mod;
2126 } 2126 }
2127 symnum -= mod->num_symtab; 2127 symnum -= mod->num_symtab;
2128 } 2128 }
2129 up(&module_mutex); 2129 mutex_unlock(&module_mutex);
2130 return NULL; 2130 return NULL;
2131} 2131}
2132 2132
@@ -2169,7 +2169,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
2169 struct list_head *i; 2169 struct list_head *i;
2170 loff_t n = 0; 2170 loff_t n = 0;
2171 2171
2172 down(&module_mutex); 2172 mutex_lock(&module_mutex);
2173 list_for_each(i, &modules) { 2173 list_for_each(i, &modules) {
2174 if (n++ == *pos) 2174 if (n++ == *pos)
2175 break; 2175 break;
@@ -2190,7 +2190,7 @@ static void *m_next(struct seq_file *m, void *p, loff_t *pos)
2190 2190
2191static void m_stop(struct seq_file *m, void *p) 2191static void m_stop(struct seq_file *m, void *p)
2192{ 2192{
2193 up(&module_mutex); 2193 mutex_unlock(&module_mutex);
2194} 2194}
2195 2195
2196static int m_show(struct seq_file *m, void *p) 2196static int m_show(struct seq_file *m, void *p)