Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Always take the object lock before changing vmpage flags...
details: https://anonhg.NetBSD.org/src/rev/c12f35720988
branches: trunk
changeset: 759136:c12f35720988
user: hannken <hannken%NetBSD.org@localhost>
date: Tue Nov 30 10:55:25 2010 +0000
description:
Always take the object lock before changing vmpage flags. Fixes a deadlock
where a thread is waiting on "genput" but the page in question is neither
BUSY nor WANTED.
No objections from tech-kern@.
diffstat:
sys/miscfs/genfs/genfs_io.c | 8 ++++++--
sys/uvm/uvm_bio.c | 6 +++---
2 files changed, 9 insertions(+), 5 deletions(-)
diffs (84 lines):
diff -r f6cea988a81d -r c12f35720988 sys/miscfs/genfs/genfs_io.c
--- a/sys/miscfs/genfs/genfs_io.c Tue Nov 30 10:50:29 2010 +0000
+++ b/sys/miscfs/genfs/genfs_io.c Tue Nov 30 10:55:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_io.c,v 1.43 2010/11/19 05:38:10 uebayasi Exp $ */
+/* $NetBSD: genfs_io.c,v 1.44 2010/11/30 10:55:25 hannken Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.43 2010/11/19 05:38:10 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.44 2010/11/30 10:55:25 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -569,6 +569,7 @@
iobytes);
skipbytes += iobytes;
+ mutex_enter(&uobj->vmobjlock);
for (i = 0; i < holepages; i++) {
if (memwrite) {
pgs[pidx + i]->flags &= ~PG_CLEAN;
@@ -577,6 +578,7 @@
pgs[pidx + i]->flags |= PG_RDONLY;
}
}
+ mutex_exit(&uobj->vmobjlock);
continue;
}
@@ -638,6 +640,7 @@
UVMHIST_LOG(ubchist, "gop_alloc off 0x%x/0x%x -> %d",
startoffset, npages << PAGE_SHIFT, error,0);
if (!error) {
+ mutex_enter(&uobj->vmobjlock);
for (i = 0; i < npages; i++) {
struct vm_page *pg = pgs[i];
@@ -648,6 +651,7 @@
UVMHIST_LOG(ubchist, "mark dirty pg %p",
pg,0,0,0);
}
+ mutex_exit(&uobj->vmobjlock);
}
}
if (!glocked) {
diff -r f6cea988a81d -r c12f35720988 sys/uvm/uvm_bio.c
--- a/sys/uvm/uvm_bio.c Tue Nov 30 10:50:29 2010 +0000
+++ b/sys/uvm/uvm_bio.c Tue Nov 30 10:55:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_bio.c,v 1.70 2010/06/22 18:34:50 rmind Exp $ */
+/* $NetBSD: uvm_bio.c,v 1.71 2010/11/30 10:55:25 hannken Exp $ */
/*
* Copyright (c) 1998 Chuck Silvers.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.70 2010/06/22 18:34:50 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.71 2010/11/30 10:55:25 hannken Exp $");
#include "opt_uvmhist.h"
#include "opt_ubc.h"
@@ -645,6 +645,7 @@
memset((char *)umapva + endoff, 0, zerolen);
}
umap->flags &= ~UMAP_PAGES_LOCKED;
+ mutex_enter(&uobj->vmobjlock);
mutex_enter(&uvm_pageqlock);
for (i = 0; i < npages; i++) {
rv = pmap_extract(pmap_kernel(),
@@ -658,7 +659,6 @@
mutex_exit(&uvm_pageqlock);
pmap_kremove(umapva, ubc_winsize);
pmap_update(pmap_kernel());
- mutex_enter(&uobj->vmobjlock);
uvm_page_unbusy(pgs, npages);
mutex_exit(&uobj->vmobjlock);
unmapped = true;
Home |
Main Index |
Thread Index |
Old Index