Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm Catch up with the usage of struct vmspace::vm_refcnt
details: https://anonhg.NetBSD.org/src/rev/06bc46f67666
branches: trunk
changeset: 1010462:06bc46f67666
user: kamil <kamil%NetBSD.org@localhost>
date: Tue May 26 00:50:53 2020 +0000
description:
Catch up with the usage of struct vmspace::vm_refcnt
Use the dedicated reference counting routines.
Change the type of struct vmspace::vm_refcnt and struct vm_map::ref_count
to volatile.
Remove the unnecessary vm->vm_map.misc_lock locking in process_domem().
Reviewed by <ad>
diffstat:
sys/dev/iscsi/iscsi_ioctl.c | 4 ++--
sys/kern/kern_proc.c | 6 +++---
sys/kern/sys_process.c | 8 +++-----
sys/uvm/uvm_extern.h | 5 ++---
sys/uvm/uvm_map.h | 4 ++--
5 files changed, 12 insertions(+), 15 deletions(-)
diffs (114 lines):
diff -r b2dff52334ce -r 06bc46f67666 sys/dev/iscsi/iscsi_ioctl.c
--- a/sys/dev/iscsi/iscsi_ioctl.c Mon May 25 23:48:26 2020 +0000
+++ b/sys/dev/iscsi/iscsi_ioctl.c Tue May 26 00:50:53 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_ioctl.c,v 1.30 2018/12/07 14:59:19 mlelstv Exp $ */
+/* $NetBSD: iscsi_ioctl.c,v 1.31 2020/05/26 00:50:54 kamil Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -1308,7 +1308,7 @@
if ((p->p_sflag & PS_WEXIT) || (p->p_vmspace->vm_refcnt < 1)) {
return ISCSI_STATUS_NO_RESOURCES;
}
- p->p_vmspace->vm_refcnt++;
+ uvmspace_addref(p->p_vmspace);
/* this is lifted from uvm_io */
error = uvm_map_extract(&p->p_vmspace->vm_map, databuf, datalen,
diff -r b2dff52334ce -r 06bc46f67666 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c Mon May 25 23:48:26 2020 +0000
+++ b/sys/kern/kern_proc.c Tue May 26 00:50:53 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_proc.c,v 1.253 2020/05/23 23:42:43 ad Exp $ */
+/* $NetBSD: kern_proc.c,v 1.254 2020/05/26 00:50:53 kamil Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.253 2020/05/23 23:42:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.254 2020/05/26 00:50:53 kamil Exp $");
#ifdef _KERNEL_OPT
#include "opt_kstack.h"
@@ -1753,7 +1753,7 @@
/* curproc exception is for coredump. */
if ((p != curproc && (p->p_sflag & PS_WEXIT) != 0) ||
- (p->p_vmspace->vm_refcnt < 1)) { /* XXX */
+ (p->p_vmspace->vm_refcnt < 1)) {
return EFAULT;
}
diff -r b2dff52334ce -r 06bc46f67666 sys/kern/sys_process.c
--- a/sys/kern/sys_process.c Mon May 25 23:48:26 2020 +0000
+++ b/sys/kern/sys_process.c Tue May 26 00:50:53 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_process.c,v 1.179 2017/04/13 07:58:45 skrll Exp $ */
+/* $NetBSD: sys_process.c,v 1.180 2020/05/26 00:50:53 kamil Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.179 2017/04/13 07:58:45 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.180 2020/05/26 00:50:53 kamil Exp $");
#ifdef _KERNEL_OPT
#include "opt_ptrace.h"
@@ -168,12 +168,10 @@
vm = p->p_vmspace;
- mutex_enter(&vm->vm_map.misc_lock);
if ((l->l_flag & LW_WEXIT) || vm->vm_refcnt < 1)
error = EFAULT;
if (error == 0)
- p->p_vmspace->vm_refcnt++; /* XXX */
- mutex_exit(&vm->vm_map.misc_lock);
+ uvmspace_addref(p->p_vmspace);
if (error != 0)
return error;
error = uvm_io(&vm->vm_map, uio, pax_mprotect_prot(l));
diff -r b2dff52334ce -r 06bc46f67666 sys/uvm/uvm_extern.h
--- a/sys/uvm/uvm_extern.h Mon May 25 23:48:26 2020 +0000
+++ b/sys/uvm/uvm_extern.h Tue May 26 00:50:53 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_extern.h,v 1.226 2020/05/09 15:13:19 thorpej Exp $ */
+/* $NetBSD: uvm_extern.h,v 1.227 2020/05/26 00:50:53 kamil Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -566,8 +566,7 @@
*/
struct vmspace {
struct vm_map vm_map; /* VM address map */
- int vm_refcnt; /* number of references *
- * note: protected by vm_map.misc_lock */
+ volatile int vm_refcnt; /* number of references */
void * vm_shm; /* SYS5 shared memory private data XXX */
/* we copy from vm_startcopy to the end of the structure on fork */
#define vm_startcopy vm_rssize
diff -r b2dff52334ce -r 06bc46f67666 sys/uvm/uvm_map.h
--- a/sys/uvm/uvm_map.h Mon May 25 23:48:26 2020 +0000
+++ b/sys/uvm/uvm_map.h Tue May 26 00:50:53 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_map.h,v 1.79 2020/03/14 14:15:43 ad Exp $ */
+/* $NetBSD: uvm_map.h,v 1.80 2020/05/26 00:50:53 kamil Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -220,7 +220,7 @@
struct vm_map_entry header; /* List of entries */
int nentries; /* Number of entries */
vsize_t size; /* virtual size */
- int ref_count; /* Reference count */
+ volatile int ref_count; /* Reference count */
struct vm_map_entry * hint; /* hint for quick lookups */
struct vm_map_entry * first_free; /* First free space hint */
unsigned int timestamp; /* Version number */
Home |
Main Index |
Thread Index |
Old Index