tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Modules loading modules?



On Sun, 1 Aug 2010, Antti Kantee wrote:

I'm not sure if it's a good idea to change the size of kmutex_t.  I
guess plenty of data structures have carefully been adjusted by hand
to its size and I don't know of any automatic way to recalculate that
stuff.

Even if not, since this is the only user and we probably won't have
that many of them even in the future, why not just define a new type
``rmutex'' which contains a kmutex, an owner and the counter? It feels wrong to punish all the normal kmutex users for just one use.
It'll also make the implementation a lot simpler to test, since it's
purely MI.

"separate normal case and worst case"

Round two! Taking pooka's suggestion, this version is built on top of (rather than beside) the existing non-recursive mutex. As such, it does not affect any MD code.

Attached is a set of diffs that

1. Adds sys/sys/rmutex.h and sys/kern/kern_rmutex.c to implement
   recursive adaptive mutexes.  (Conspicuously missing is an rmutex(9)
   man page...  It will happen before this gets committed.)

2. Converts the existing module_lock from a normal kmutex_t to an
   rmutex_t

3. Updates all of the (surprisingly many) places where module_lock
   is acquired.

Compile-tested on port-amd64 (including rumptest). Since there are no MD-changes in this version, there "shouldn't be" any issues with building on other ports.


As previously noted, there is only one known use case for this so far: modules loading other modules from within their xxx_modcmd() routine. The specific use case we have involves loading the acpicpu driver/module which eventually results in an attempt to load acpiverbose.

It would be really nice if the community could

A. Compile-test on additional architectures
B. Test to see that existing mutex operations still work correctly
C. Exercise the known use case if possible
D. Identify additional use cases


-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------
Index: sys/conf/files
===================================================================
RCS file: /cvsroot/src/sys/conf/files,v
retrieving revision 1.992
diff -u -p -r1.992 files
--- sys/conf/files      7 Jul 2010 01:09:39 -0000       1.992
+++ sys/conf/files      2 Aug 2010 00:08:26 -0000
@@ -1468,6 +1468,7 @@ file      kern/kern_prot.c
 file   kern/kern_ras.c
 file   kern/kern_rate.c
 file   kern/kern_resource.c
+file   kern/kern_rmutex.c
 file   kern/kern_runq.c
 file   kern/kern_rwlock.c
 file   kern/kern_rwlock_obj.c
Index: sys/sys/rmutex.h
===================================================================
RCS file: sys/sys/rmutex.h
diff -N sys/sys/rmutex.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ sys/sys/rmutex.h    2 Aug 2010 00:08:27 -0000
@@ -0,0 +1,53 @@
+/*     $NetBSD$        */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef        _SYS_RMUTEX_H_
+#define        _SYS_RMUTEX_H_
+
+#include <sys/mutex.h>
+
+/*
+ * A recursive mutex is simply an adaptive mutex which can be acquired
+ * multiple times by a single owner.
+ */
+ 
+struct rmutex {
+       kmutex_t        rmtx_mtx;
+       uint32_t        rmtx_recurse;
+};
+
+typedef struct rmutex rmutex_t;
+
+void   rmutex_init(rmutex_t *);
+void   rmutex_destroy(rmutex_t *);
+void   rmutex_enter(rmutex_t *);
+void   rmutex_exit(rmutex_t *);
+int    rmutex_tryenter(rmutex_t *);
+int    rmutex_owned(rmutex_t *);
+
+#endif /* _SYS_RMUTEX_H_ */
Index: sys/kern/kern_rmutex.c
===================================================================
RCS file: sys/kern/kern_rmutex.c
diff -N sys/kern/kern_rmutex.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ sys/kern/kern_rmutex.c      2 Aug 2010 00:08:28 -0000
@@ -0,0 +1,86 @@
+/*     $NetBSD$        */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h> 
+
+#include <sys/rmutex.h>
+
+void
+rmutex_init(rmutex_t *rmtx)
+{
+       mutex_init(&rmtx->rmtx_mtx, MUTEX_DEFAULT, IPL_NONE);
+       rmtx->rmtx_recurse = 0;
+}
+
+void
+rmutex_destroy(rmutex_t *rmtx)
+{
+       mutex_destroy(&rmtx->rmtx_mtx);
+}
+
+void
+rmutex_enter(rmutex_t *rmtx)
+{
+       if (mutex_owned(&rmtx->rmtx_mtx)) {
+               rmtx->rmtx_recurse++;
+               KASSERT(rmtx->rmtx_recurse != 0);
+       } else {
+               mutex_enter(&rmtx->rmtx_mtx);
+               rmtx->rmtx_recurse = 1;
+       }
+}
+
+void
+rmutex_exit(rmutex_t *rmtx)
+{
+       KASSERT(mutex_owned(&rmtx->rmtx_mtx));
+       KASSERT(rmtx->rmtx_recurse != 0);
+       if (--rmtx->rmtx_recurse == 0)
+               mutex_exit(&rmtx->rmtx_mtx);
+}
+
+int
+rmutex_tryenter(rmutex_t *rmtx)
+{
+       int rv = 1;
+
+       if (mutex_owned(&rmtx->rmtx_mtx)) {
+               rmtx->rmtx_recurse++;
+               KASSERT(rmtx->rmtx_recurse != 0);
+       } else if ((rv = mutex_tryenter(&rmtx->rmtx_mtx)) != 0) {
+               rmtx->rmtx_recurse++;
+               KASSERT(rmtx->rmtx_recurse != 0);
+       }
+       return rv;
+}
+
+int
+rmutex_owned(rmutex_t *rmtx)
+{
+       return mutex_owned(&rmtx->rmtx_mtx);
+}
Index: sys/sys/module.h
===================================================================
RCS file: /cvsroot/src/sys/sys/module.h,v
retrieving revision 1.24
diff -u -p -r1.24 module.h
--- sys/sys/module.h    26 Jun 2010 07:23:57 -0000      1.24
+++ sys/sys/module.h    2 Aug 2010 00:08:29 -0000
@@ -66,6 +66,7 @@ typedef enum modcmd {
 #ifdef _KERNEL
 
 #include <sys/mutex.h>
+#include <sys/rmutex.h>
 
 #include <prop/proplib.h>
 
@@ -115,7 +116,7 @@ __link_set_add_rodata(modules, name##_mo
 TAILQ_HEAD(modlist, module);
 
 extern struct vm_map   *module_map;
-extern kmutex_t                module_lock;
+extern rmutex_t                module_lock;
 extern u_int           module_count;
 extern u_int           module_builtinlist;
 extern struct modlist  module_list;
Index: sys/kern/kern_module.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_module.c,v
retrieving revision 1.70
diff -u -p -r1.70 kern_module.c
--- sys/kern/kern_module.c      26 Jun 2010 07:23:57 -0000      1.70
+++ sys/kern/kern_module.c      2 Aug 2010 00:08:30 -0000
@@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_module.
 #include <sys/kthread.h>
 #include <sys/sysctl.h>
 #include <sys/lock.h>
+#include <sys/rmutex.h>
 
 #include <uvm/uvm_extern.h>
 
@@ -72,7 +73,7 @@ static int    module_verbose_on;
 static int     module_autoload_on = 1;
 u_int          module_count;
 u_int          module_builtinlist;
-kmutex_t       module_lock;
+rmutex_t       module_lock;
 u_int          module_autotime = 10;
 u_int          module_gen = 1;
 static kcondvar_t module_thread_cv;
@@ -223,7 +224,7 @@ module_builtin_add(modinfo_t *const *mip
                modp[i] = module_newmodule(MODULE_SOURCE_KERNEL);
                modp[i]->mod_info = mip[i+mipskip];
        }
-       mutex_enter(&module_lock);
+       rmutex_enter(&module_lock);
 
        /* do this in three stages for error recovery and atomicity */
 
@@ -263,7 +264,7 @@ module_builtin_add(modinfo_t *const *mip
        }
 
  out:
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
        if (rv != 0) {
                for (i = 0; i < nmodinfo; i++) {
                        if (modp[i])
@@ -291,13 +292,13 @@ module_builtin_remove(modinfo_t *mi, boo
                if (rv)
                        return rv;
 
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
                rv = module_do_unload(mi->mi_name, true);
                if (rv) {
                        goto out;
                }
        } else {
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
        }
        TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
                if (strcmp(mod->mod_info->mi_name, mi->mi_name) == 0)
@@ -312,7 +313,7 @@ module_builtin_remove(modinfo_t *mi, boo
        }
 
  out:
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
        return rv;
 }
 
@@ -332,7 +333,7 @@ module_init(void)
        if (module_map == NULL) {
                module_map = kernel_map;
        }
-       mutex_init(&module_lock, MUTEX_DEFAULT, IPL_NONE);
+       rmutex_init(&module_lock);
        cv_init(&module_thread_cv, "modunload");
        mutex_init(&module_thread_lock, MUTEX_DEFAULT, IPL_NONE);
 
@@ -388,11 +389,11 @@ module_builtin_require_force(void)
 {
        module_t *mod;
 
-       mutex_enter(&module_lock);
+       rmutex_enter(&module_lock);
        TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
                module_require_force(mod);
        }
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
 }
 
 static struct sysctllog *module_sysctllog;
@@ -444,7 +445,7 @@ module_init_class(modclass_t class)
        module_t *mod;
        modinfo_t *mi;
 
-       mutex_enter(&module_lock);
+       rmutex_enter(&module_lock);
        /*
         * Builtins first.  These will not depend on pre-loaded modules
         * (because the kernel would not link).
@@ -493,7 +494,7 @@ module_init_class(modclass_t class)
                TAILQ_INSERT_TAIL(&module_builtins, mod, mod_chain);
        }
 
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
 }
 
 /*
@@ -534,10 +535,10 @@ module_load(const char *filename, int fl
                return error;
        }
 
-       mutex_enter(&module_lock);
+       rmutex_enter(&module_lock);
        error = module_do_load(filename, false, flags, props, NULL, class,
            false);
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
 
        return error;
 }
@@ -552,7 +553,7 @@ module_autoload(const char *filename, mo
 {
        int error;
 
-       KASSERT(mutex_owned(&module_lock));
+       KASSERT(rmutex_owned(&module_lock));
 
        /* Nothing if the user has disabled it. */
        if (!module_autoload_on) {
@@ -592,9 +593,9 @@ module_unload(const char *name)
                return error;
        }
 
-       mutex_enter(&module_lock);
+       rmutex_enter(&module_lock);
        error = module_do_unload(name, true);
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
 
        return error;
 }
@@ -609,7 +610,7 @@ module_lookup(const char *name)
 {
        module_t *mod;
 
-       KASSERT(mutex_owned(&module_lock));
+       KASSERT(rmutex_owned(&module_lock));
 
        TAILQ_FOREACH(mod, &module_list, mod_chain) {
                if (strcmp(mod->mod_info->mi_name, name) == 0) {
@@ -632,14 +633,14 @@ module_hold(const char *name)
 {
        module_t *mod;
 
-       mutex_enter(&module_lock);
+       rmutex_enter(&module_lock);
        mod = module_lookup(name);
        if (mod == NULL) {
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
                return ENOENT;
        }
        mod->mod_refcnt++;
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
 
        return 0;
 }
@@ -654,14 +655,14 @@ module_rele(const char *name)
 {
        module_t *mod;
 
-       mutex_enter(&module_lock);
+       rmutex_enter(&module_lock);
        mod = module_lookup(name);
        if (mod == NULL) {
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
                panic("module_rele: gone");
        }
        mod->mod_refcnt--;
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
 }
 
 /*
@@ -674,7 +675,7 @@ module_enqueue(module_t *mod)
 {
        int i;
 
-       KASSERT(mutex_owned(&module_lock));
+       KASSERT(rmutex_owned(&module_lock));
 
        /*
         * If there are requisite modules, put at the head of the queue.
@@ -712,7 +713,7 @@ module_do_builtin(const char *name, modu
        size_t len;
        int error;
 
-       KASSERT(mutex_owned(&module_lock));
+       KASSERT(rmutex_owned(&module_lock));
 
        /*
         * Search the list to see if we have a module by this name.
@@ -820,7 +821,7 @@ module_do_load(const char *name, bool is
        int error;
        size_t len;
 
-       KASSERT(mutex_owned(&module_lock));
+       KASSERT(rmutex_owned(&module_lock));
 
        filedict = NULL;
        error = 0;
@@ -1103,7 +1104,7 @@ module_do_unload(const char *name, bool 
        int error;
        u_int i;
 
-       KASSERT(mutex_owned(&module_lock));
+       KASSERT(rmutex_owned(&module_lock));
 
        mod = module_lookup(name);
        if (mod == NULL) {
@@ -1223,7 +1224,7 @@ int
 module_find_section(const char *name, void **addr, size_t *size)
 {
 
-       KASSERT(mutex_owned(&module_lock));
+       KASSERT(rmutex_owned(&module_lock));
        KASSERT(module_active != NULL);
 
        return kobj_find_section(module_active->mod_kobj, name, addr, size);
@@ -1244,7 +1245,7 @@ module_thread(void *cookie)
        int error;
 
        for (;;) {
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
                for (mod = TAILQ_FIRST(&module_list); mod != NULL; mod = next) {
                        next = TAILQ_NEXT(mod, mod_chain);
                        if (mod->mod_source == MODULE_SOURCE_KERNEL)
@@ -1271,7 +1272,7 @@ module_thread(void *cookie)
                                (void)module_do_unload(mi->mi_name, false);
                        }
                }
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
 
                mutex_enter(&module_thread_lock);
                (void)cv_timedwait(&module_thread_cv, &module_thread_lock,
Index: sys/kern/kern_syscall.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_syscall.c,v
retrieving revision 1.4
diff -u -p -r1.4 kern_syscall.c
--- sys/kern/kern_syscall.c     15 Apr 2010 20:46:08 -0000      1.4
+++ sys/kern/kern_syscall.c     2 Aug 2010 00:08:30 -0000
@@ -202,10 +202,10 @@ sys_nomodule(struct lwp *l, const void *
         * failed.  Acquiring module_lock delays us until any unload
         * has been completed or rolled back.
         */
-       mutex_enter(&module_lock);
+       rmutex_enter(&module_lock);
        sy = l->l_sysent;
        if (sy->sy_call != sys_nomodule) {
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
                return ERESTART;
        }
        /*
@@ -224,11 +224,11 @@ sys_nomodule(struct lwp *l, const void *
                            sy->sy_call == sys_nomodule) {
                                break;
                        }
-                       mutex_exit(&module_lock);
+                       rmutex_exit(&module_lock);
                        return ERESTART;
                }
        }
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
 #endif /* MODULAR */
 
        return sys_nosys(l, v, retval);
@@ -240,7 +240,7 @@ syscall_establish(const struct emul *em,
        struct sysent *sy;
        int i;
 
-       KASSERT(mutex_owned(&module_lock));
+       KASSERT(rmutex_owned(&module_lock));
 
        if (em == NULL) {
                em = &emul_netbsd;
@@ -277,7 +277,7 @@ syscall_disestablish(const struct emul *
        lwp_t *l;
        int i;
 
-       KASSERT(mutex_owned(&module_lock));
+       KASSERT(rmutex_owned(&module_lock));
 
        if (em == NULL) {
                em = &emul_netbsd;
Index: sys/kern/kern_exec.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_exec.c,v
retrieving revision 1.299
diff -u -p -r1.299 kern_exec.c
--- sys/kern/kern_exec.c        7 Jul 2010 01:30:37 -0000       1.299
+++ sys/kern/kern_exec.c        2 Aug 2010 00:08:31 -0000
@@ -500,17 +500,17 @@ exec_autoload(void)
        char const * const *list;
        int i;
 
-       mutex_enter(&module_lock);
+       rmutex_enter(&module_lock);
        list = (nexecs == 0 ? native : compat);
        for (i = 0; list[i] != NULL; i++) {
                if (module_autoload(list[i], MODULE_CLASS_MISC) != 0) {
                        continue;
                }
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
                yield();
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
        }
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
 #endif
 }
 
Index: sys/kern/sys_module.c
===================================================================
RCS file: /cvsroot/src/sys/kern/sys_module.c,v
retrieving revision 1.11
diff -u -p -r1.11 sys_module.c
--- sys/kern/sys_module.c       5 Mar 2010 18:35:01 -0000       1.11
+++ sys/kern/sys_module.c       2 Aug 2010 00:08:32 -0000
@@ -144,11 +144,11 @@ sys_modctl(struct lwp *l, const struct s
                if (error != 0) {
                        break;
                }
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
                mslen = (module_count+module_builtinlist+1) * sizeof(modstat_t);
                mso = kmem_zalloc(mslen, KM_SLEEP);
                if (mso == NULL) {
-                       mutex_exit(&module_lock);
+                       rmutex_exit(&module_lock);
                        return ENOMEM;
                }
                ms = mso;
@@ -187,7 +187,7 @@ sys_modctl(struct lwp *l, const struct s
                        ms->ms_source = mod->mod_source;
                        ms++;
                }
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
                error = copyout(mso, iov.iov_base,
                    min(mslen - sizeof(modstat_t), iov.iov_len));
                kmem_free(mso, mslen);
Index: sys/kern/sys_sig.c
===================================================================
RCS file: /cvsroot/src/sys/kern/sys_sig.c,v
retrieving revision 1.28
diff -u -p -r1.28 sys_sig.c
--- sys/kern/sys_sig.c  1 Jul 2010 02:38:31 -0000       1.28
+++ sys/kern/sys_sig.c  2 Aug 2010 00:08:33 -0000
@@ -353,7 +353,7 @@ sigaction1(struct lwp *l, int signum, co
        if (nsa != NULL) {
                if (__predict_false(vers < 2) &&
                    (p->p_lflag & PL_SIGCOMPAT) == 0) {
-                       mutex_enter(&module_lock);
+                       rmutex_enter(&module_lock);
                        if (sendsig_sigcontext_vec == NULL) {
                                (void)module_autoload("compat",
                                    MODULE_CLASS_ANY);
@@ -374,7 +374,7 @@ sigaction1(struct lwp *l, int signum, co
                         */
                        p->p_lflag |= PL_SIGCOMPAT;
                        mutex_exit(proc_lock);
-                       mutex_exit(&module_lock);
+                       rmutex_exit(&module_lock);
                }
 
                switch (vers) {
Index: sys/kern/tty.c
===================================================================
RCS file: /cvsroot/src/sys/kern/tty.c,v
retrieving revision 1.237
diff -u -p -r1.237 tty.c
--- sys/kern/tty.c      1 Jul 2010 02:38:31 -0000       1.237
+++ sys/kern/tty.c      2 Aug 2010 00:08:34 -0000
@@ -1264,13 +1264,13 @@ ttioctl(struct tty *tp, u_long cmd, void
                                break;
                        }
                        rw_exit(&ttcompat_lock);
-                       mutex_enter(&module_lock);
+                       rmutex_enter(&module_lock);
                        (void)module_autoload("compat", MODULE_CLASS_ANY);
                        if (ttcompatvec == NULL) {
-                               mutex_exit(&module_lock);
+                               rmutex_exit(&module_lock);
                                return EPASSTHROUGH;
                        }
-                       mutex_exit(&module_lock);
+                       rmutex_exit(&module_lock);
                }
                error = (*ttcompatvec)(tp, cmd, data, flag, l);
                rw_exit(&ttcompat_lock);
Index: sys/kern/uipc_accf.c
===================================================================
RCS file: /cvsroot/src/sys/kern/uipc_accf.c,v
retrieving revision 1.11
diff -u -p -r1.11 uipc_accf.c
--- sys/kern/uipc_accf.c        13 Mar 2010 23:03:39 -0000      1.11
+++ sys/kern/uipc_accf.c        2 Aug 2010 00:08:34 -0000
@@ -167,10 +167,10 @@ accept_filt_get(char *name)
                /* Try to autoload a module to satisfy the request. */
                strcpy(buf, "accf_");
                strlcat(buf, name, sizeof(buf));
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
                gen = module_gen;
                (void)module_autoload(buf, MODULE_CLASS_ANY);
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
        } while (gen != module_gen);
 
        return p;
Index: sys/kern/vfs_syscalls.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.407
diff -u -p -r1.407 vfs_syscalls.c
--- sys/kern/vfs_syscalls.c     30 Jun 2010 15:44:54 -0000      1.407
+++ sys/kern/vfs_syscalls.c     2 Aug 2010 00:08:35 -0000
@@ -278,9 +278,9 @@ mount_get_vfsops(const char *fstype, str
                return 0;
 
        /* If we can autoload a vfs module, try again */
-       mutex_enter(&module_lock);
+       rmutex_enter(&module_lock);
        (void)module_autoload(fstypename, MODULE_CLASS_VFS);
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
 
        if ((*vfsops = vfs_getopsbyname(fstypename)) != NULL)
                return 0;
Index: sys/net/if_ppp.c
===================================================================
RCS file: /cvsroot/src/sys/net/if_ppp.c,v
retrieving revision 1.131
diff -u -p -r1.131 if_ppp.c
--- sys/net/if_ppp.c    5 Apr 2010 07:22:23 -0000       1.131
+++ sys/net/if_ppp.c    2 Aug 2010 00:08:36 -0000
@@ -126,6 +126,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1
 #include <sys/malloc.h>
 #include <sys/module.h>
 #include <sys/mutex.h>
+#include <sys/rmutex.h>
 #include <sys/once.h>
 #include <sys/conf.h>
 #include <sys/kauth.h>
@@ -1820,7 +1821,7 @@ ppp_get_compressor(uint8_t ci)
        if (cp != NULL)
                return cp;
 
-       mutex_enter(&module_lock);
+       rmutex_enter(&module_lock);
        mutex_enter(&ppp_compressors_mtx);
        cp = ppp_get_compressor_noload(ci, true);
        mutex_exit(&ppp_compressors_mtx);
@@ -1838,7 +1839,7 @@ ppp_get_compressor(uint8_t ci)
                        }
                }
        }
-       mutex_exit(&module_lock);
+       rmutex_exit(&module_lock);
 
        return cp;
 }
Index: sys/miscfs/specfs/spec_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/miscfs/specfs/spec_vnops.c,v
retrieving revision 1.130
diff -u -p -r1.130 spec_vnops.c
--- sys/miscfs/specfs/spec_vnops.c      24 Jun 2010 13:03:17 -0000      1.130
+++ sys/miscfs/specfs/spec_vnops.c      2 Aug 2010 00:08:37 -0000
@@ -459,9 +459,9 @@ spec_open(void *v)
                                break;
                        
                        /* Try to autoload device module */
-                       mutex_enter(&module_lock);
+                       rmutex_enter(&module_lock);
                        (void) module_autoload(name, MODULE_CLASS_DRIVER);
-                       mutex_exit(&module_lock);
+                       rmutex_exit(&module_lock);
                } while (gen != module_gen);
 
                vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
@@ -512,9 +512,9 @@ spec_open(void *v)
                        VOP_UNLOCK(vp);
 
                         /* Try to autoload device module */
-                       mutex_enter(&module_lock);
+                       rmutex_enter(&module_lock);
                        (void) module_autoload(name, MODULE_CLASS_DRIVER);
-                       mutex_exit(&module_lock);
+                       rmutex_exit(&module_lock);
                        
                        vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
                } while (gen != module_gen);
Index: sys/dev/dm/dm_target.c
===================================================================
RCS file: /cvsroot/src/sys/dev/dm/dm_target.c,v
retrieving revision 1.13
diff -u -p -r1.13 dm_target.c
--- sys/dev/dm/dm_target.c      18 May 2010 15:10:41 -0000      1.13
+++ sys/dev/dm/dm_target.c      2 Aug 2010 00:08:38 -0000
@@ -83,9 +83,9 @@ dm_target_autoload(const char *dm_target
                gen = module_gen;
 
                /* Try to autoload target module */
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
                (void) module_autoload(name, MODULE_CLASS_MISC);
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
        } while (gen != module_gen);
 
        mutex_enter(&dm_target_mutex);
Index: sys/dev/acpi/acpi.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.208
diff -u -p -r1.208 acpi.c
--- sys/dev/acpi/acpi.c 25 Jul 2010 12:54:46 -0000      1.208
+++ sys/dev/acpi/acpi.c 2 Aug 2010 00:08:38 -0000
@@ -76,6 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.2
 #include <sys/malloc.h>
 #include <sys/module.h>
 #include <sys/mutex.h>
+#include <sys/rmutex.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
 #include <sys/timetc.h>
@@ -227,9 +228,9 @@ void
 acpi_load_verbose(void)
 {
        if (acpi_verbose_loaded == 0) {
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
                module_autoload("acpiverbose", MODULE_CLASS_MISC);
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
        }
 }
 
Index: sys/dev/mii/mii_physubr.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/mii_physubr.c,v
retrieving revision 1.71
diff -u -p -r1.71 mii_physubr.c
--- sys/dev/mii/mii_physubr.c   25 Jul 2010 14:44:34 -0000      1.71
+++ sys/dev/mii/mii_physubr.c   2 Aug 2010 00:08:39 -0000
@@ -72,9 +72,9 @@ const char *mii_get_descr_stub(int oui, 
 void mii_load_verbose(void)
 {
        if (mii_verbose_loaded == 0) {
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
                module_autoload("miiverbose", MODULE_CLASS_MISC);
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
        }
 }  
 
Index: sys/dev/pci/pci_subr.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pci_subr.c,v
retrieving revision 1.84
diff -u -p -r1.84 pci_subr.c
--- sys/dev/pci/pci_subr.c      25 Jul 2010 14:14:25 -0000      1.84
+++ sys/dev/pci/pci_subr.c      2 Aug 2010 00:08:40 -0000
@@ -324,9 +324,9 @@ int pciverbose_loaded = 0;
 void pci_load_verbose(void)
 {
        if (pciverbose_loaded == 0) {
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
                module_autoload("pciverbose", MODULE_CLASS_MISC);
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
        }
 }
 
Index: sys/dev/usb/usb_subr.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/usb_subr.c,v
retrieving revision 1.174
diff -u -p -r1.174 usb_subr.c
--- sys/dev/usb/usb_subr.c      27 Jul 2010 16:15:30 -0000      1.174
+++ sys/dev/usb/usb_subr.c      2 Aug 2010 00:08:41 -0000
@@ -123,9 +123,9 @@ int usb_verbose_loaded = 0;
 void usb_load_verbose(void)
 {
        if (usb_verbose_loaded == 0) {
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
                module_autoload("usbverbose", MODULE_CLASS_MISC);
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
        }
 }
 
Index: sys/dev/scsipi/scsipiconf.c
===================================================================
RCS file: /cvsroot/src/sys/dev/scsipi/scsipiconf.c,v
retrieving revision 1.39
diff -u -p -r1.39 scsipiconf.c
--- sys/dev/scsipi/scsipiconf.c 25 Jul 2010 13:49:58 -0000      1.39
+++ sys/dev/scsipi/scsipiconf.c 2 Aug 2010 00:08:41 -0000
@@ -108,9 +108,9 @@ void
 scsipi_load_verbose(void)
 {
        if (scsi_verbose_loaded == 0) {
-               mutex_enter(&module_lock);
+               rmutex_enter(&module_lock);
                module_autoload("scsiverbose", MODULE_CLASS_MISC);
-               mutex_exit(&module_lock);
+               rmutex_exit(&module_lock);
        }
 }
 
Index: sys/rump/librump/rumpkern/Makefile.rumpkern
===================================================================
RCS file: /cvsroot/src/sys/rump/librump/rumpkern/Makefile.rumpkern,v
retrieving revision 1.92
diff -u -p -r1.92 Makefile.rumpkern
--- sys/rump/librump/rumpkern/Makefile.rumpkern 19 Jul 2010 15:33:16 -0000      
1.92
+++ sys/rump/librump/rumpkern/Makefile.rumpkern 2 Aug 2010 00:08:42 -0000
@@ -50,9 +50,10 @@ SRCS+=       devsw.c
 SRCS+= init_sysctl_base.c kern_auth.c kern_descrip.c kern_event.c      \
        kern_hook.c kern_ksyms.c kern_malloc_stdtype.c kern_module.c    \
        kern_mutex_obj.c kern_ntptime.c kern_proc.c kern_rate.c         \
-       kern_resource.c kern_stub.c kern_syscall.c kern_sysctl.c        \
-       kern_tc.c kern_timeout.c kern_uidinfo.c param.c sys_descrip.c   \
-       sys_generic.c sys_module.c sys_pipe.c sys_select.c syscalls.c
+       kern_resource.c kern_rmutex.c kern_stub.c kern_syscall.c        \
+       kern_sysctl.c kern_tc.c kern_timeout.c kern_uidinfo.c param.c   \
+       sys_descrip.c sys_generic.c sys_module.c sys_pipe.c             \
+       sys_select.c syscalls.c
 
 # sys/kern subr (misc)
 SRCS+= subr_devsw.c subr_callback.c subr_copy.c subr_device.c          \


Home | Main Index | Thread Index | Old Index