Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm avoid taking locks that aren't initialised.
details: https://anonhg.NetBSD.org/src/rev/e23b7d3eef0d
branches: trunk
changeset: 379244:e23b7d3eef0d
user: mrg <mrg%NetBSD.org@localhost>
date: Sun May 23 00:36:36 2021 +0000
description:
avoid taking locks that aren't initialised.
fixes panic when typing 'reboot' at the askroot prompt.
diffstat:
sys/uvm/uvm_swap.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diffs (44 lines):
diff -r a5297d2f476a -r e23b7d3eef0d sys/uvm/uvm_swap.c
--- a/sys/uvm/uvm_swap.c Sat May 22 17:20:01 2021 +0000
+++ b/sys/uvm/uvm_swap.c Sun May 23 00:36:36 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_swap.c,v 1.203 2021/03/13 15:29:55 skrll Exp $ */
+/* $NetBSD: uvm_swap.c,v 1.204 2021/05/23 00:36:36 mrg Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.203 2021/03/13 15:29:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.204 2021/05/23 00:36:36 mrg Exp $");
#include "opt_uvmhist.h"
#include "opt_compat_netbsd.h"
@@ -202,6 +202,7 @@ static struct swap_priority swap_priorit
/* locks */
static kmutex_t uvm_swap_data_lock __cacheline_aligned;
static krwlock_t swap_syscall_lock;
+bool uvm_swap_init_done = false;
/* workqueue and use counter for swap to regular files */
static int sw_reg_count = 0;
@@ -296,6 +297,8 @@ uvm_swap_init(void)
pool_init(&vndbuf_pool, sizeof(struct vndbuf), 0, 0, 0, "swp vnd",
NULL, IPL_BIO);
+ uvm_swap_init_done = true;
+
UVMHIST_LOG(pdhist, "<- done", 0, 0, 0, 0);
}
@@ -1141,6 +1144,8 @@ uvm_swap_shutdown(struct lwp *l)
struct vnode *vp;
int error;
+ if (!uvm_swap_init_done)
+ return;
printf("turning off swap...");
rw_enter(&swap_syscall_lock, RW_WRITER);
mutex_enter(&uvm_swap_data_lock);
Home |
Main Index |
Thread Index |
Old Index