Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/linux/common Can't use RUN_ONCE here to initializ...
details: https://anonhg.NetBSD.org/src/rev/a96d3ad5838b
branches: trunk
changeset: 769554:a96d3ad5838b
user: christos <christos%NetBSD.org@localhost>
date: Wed Sep 14 12:28:08 2011 +0000
description:
Can't use RUN_ONCE here to initialize the futex_lock, otherwise we cannot
unload the module.
diffstat:
sys/compat/linux/common/linux_futex.c | 23 ++++++++++++-----------
sys/compat/linux/common/linux_futex.h | 4 +++-
sys/compat/linux/common/linux_mod.c | 10 +++++++---
3 files changed, 22 insertions(+), 15 deletions(-)
diffs (123 lines):
diff -r 3bb447bc4e0f -r a96d3ad5838b sys/compat/linux/common/linux_futex.c
--- a/sys/compat/linux/common/linux_futex.c Wed Sep 14 11:49:21 2011 +0000
+++ b/sys/compat/linux/common/linux_futex.c Wed Sep 14 12:28:08 2011 +0000
@@ -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);
+void
+linux_futex_init(void)
+{
+ FUTEXPRINTF(("%s: initializing futex\n", __func__));
+ mutex_init(&futex_lock, MUTEX_DEFAULT, IPL_NONE);
+}
-static int
-futex_init(void)
+void
+linux_futex_fini(void)
{
- FUTEXPRINTF(("futex_init: initializing futex\n"));
- mutex_init(&futex_lock, MUTEX_DEFAULT, IPL_NONE);
- return 0;
+ 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
diff -r 3bb447bc4e0f -r a96d3ad5838b sys/compat/linux/common/linux_futex.h
--- a/sys/compat/linux/common/linux_futex.h Wed Sep 14 11:49:21 2011 +0000
+++ b/sys/compat/linux/common/linux_futex.h Wed Sep 14 12:28:08 2011 +0000
@@ -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 */
diff -r 3bb447bc4e0f -r a96d3ad5838b sys/compat/linux/common/linux_mod.c
--- a/sys/compat/linux/common/linux_mod.c Wed Sep 14 11:49:21 2011 +0000
+++ b/sys/compat/linux/common/linux_mod.c Wed Sep 14 12:28:08 2011 +0000
@@ -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:
Home |
Main Index |
Thread Index |
Old Index