Module Name:    src
Committed By:   christos
Date:           Wed Sep 14 12:28:09 UTC 2011

Modified Files:
        src/sys/compat/linux/common: linux_futex.c linux_futex.h linux_mod.c

Log Message:
Can't use RUN_ONCE here to initialize the futex_lock, otherwise we cannot
unload the module.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/compat/linux/common/linux_futex.c
cvs rdiff -u -r1.4 -r1.5 src/sys/compat/linux/common/linux_futex.h
cvs rdiff -u -r1.1 -r1.2 src/sys/compat/linux/common/linux_mod.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_futex.c
diff -u src/sys/compat/linux/common/linux_futex.c:1.26 src/sys/compat/linux/common/linux_futex.c:1.27
--- src/sys/compat/linux/common/linux_futex.c:1.26	Tue Jul  6 21:30:35 2010
+++ src/sys/compat/linux/common/linux_futex.c	Wed Sep 14 08:28:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_futex.c,v 1.26 2010/07/07 01:30:35 chs Exp $ */
+/*	$NetBSD: linux_futex.c,v 1.27 2011/09/14 12:28:08 christos Exp $ */
 
 /*-
  * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.26 2010/07/07 01:30:35 chs Exp $");
+__KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.27 2011/09/14 12:28:08 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -42,7 +42,6 @@
 #include <sys/queue.h>
 #include <sys/condvar.h>
 #include <sys/mutex.h>
-#include <sys/once.h>
 #include <sys/kmem.h>
 #include <sys/kernel.h>
 #include <sys/atomic.h>
@@ -92,14 +91,18 @@
 #define FUTEXPRINTF(a)
 #endif
 
-static ONCE_DECL(futex_once);
-
-static int
-futex_init(void)
+void
+linux_futex_init(void)
 {
-	FUTEXPRINTF(("futex_init: initializing futex\n"));
+	FUTEXPRINTF(("%s: initializing futex\n", __func__));
 	mutex_init(&futex_lock, MUTEX_DEFAULT, IPL_NONE);
-	return 0;
+}
+
+void
+linux_futex_fini(void)
+{
+	FUTEXPRINTF(("%s: destroying futex\n", __func__));
+	mutex_destroy(&futex_lock);
 }
 
 static struct waiting_proc *futex_wp_alloc(void);
@@ -158,8 +161,6 @@
 	struct waiting_proc *wp;
 	int op_ret;
 
-	RUN_ONCE(&futex_once, futex_init);
-
 	/*
 	 * Our implementation provides only private futexes. Most of the apps
 	 * should use private futexes but don't claim so. Therefore we treat

Index: src/sys/compat/linux/common/linux_futex.h
diff -u src/sys/compat/linux/common/linux_futex.h:1.4 src/sys/compat/linux/common/linux_futex.h:1.5
--- src/sys/compat/linux/common/linux_futex.h:1.4	Tue Jul  6 21:30:35 2010
+++ src/sys/compat/linux/common/linux_futex.h	Wed Sep 14 08:28:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_futex.h,v 1.4 2010/07/07 01:30:35 chs Exp $ */
+/*	$NetBSD: linux_futex.h,v 1.5 2011/09/14 12:28:08 christos Exp $ */
 
 /*-
  * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -76,5 +76,7 @@
 struct linux_sys_futex_args;
 int	linux_do_futex(struct lwp *, const struct linux_sys_futex_args *,
 		       register_t *, struct timespec *);
+void	linux_futex_init(void);
+void	linux_futex_fini(void);
 
 #endif /* !_LINUX_FUTEX_H */

Index: src/sys/compat/linux/common/linux_mod.c
diff -u src/sys/compat/linux/common/linux_mod.c:1.1 src/sys/compat/linux/common/linux_mod.c:1.2
--- src/sys/compat/linux/common/linux_mod.c:1.1	Wed Nov 19 13:36:03 2008
+++ src/sys/compat/linux/common/linux_mod.c	Wed Sep 14 08:28:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_mod.c,v 1.1 2008/11/19 18:36:03 ad Exp $	*/
+/*	$NetBSD: linux_mod.c,v 1.2 2011/09/14 12:28:08 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.1 2008/11/19 18:36:03 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.2 2011/09/14 12:28:08 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -46,6 +46,7 @@
 #include <sys/signalvar.h>
 
 #include <compat/linux/common/linux_sysctl.h>
+#include <compat/linux/common/linux_futex.h>
 #include <compat/linux/common/linux_exec.h>
 
 #if defined(EXEC_ELF32) && ELFSIZE == 32
@@ -111,6 +112,7 @@
 
 	switch (cmd) {
 	case MODULE_CMD_INIT:
+		linux_futex_init();
 		linux_sysctl_init();
 		error = exec_add(linux_execsw,
 		    __arraycount(linux_execsw));
@@ -121,8 +123,10 @@
 	case MODULE_CMD_FINI:
 		error = exec_remove(linux_execsw,
 		    __arraycount(linux_execsw));
-		if (error == 0)
+		if (error == 0) {
 			linux_sysctl_fini();
+			linux_futex_fini();
+		}
 		return error;
 
 	default:

Reply via email to