Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm convert from CIRCLEQ to TAILQ
details: https://anonhg.NetBSD.org/src/rev/e7823a681dcb
branches: trunk
changeset: 791554:e7823a681dcb
user: christos <christos%NetBSD.org@localhost>
date: Sat Nov 23 14:32:13 2013 +0000
description:
convert from CIRCLEQ to TAILQ
add uvm_swap_shutdown(), unused
diffstat:
sys/uvm/uvm_swap.c | 80 +++++++++++++++++++++++++++++++++++++++++++----------
sys/uvm/uvm_swap.h | 4 ++-
2 files changed, 67 insertions(+), 17 deletions(-)
diffs (205 lines):
diff -r 0d5e4b6116d7 -r e7823a681dcb sys/uvm/uvm_swap.c
--- a/sys/uvm/uvm_swap.c Sat Nov 23 14:20:46 2013 +0000
+++ b/sys/uvm/uvm_swap.c Sat Nov 23 14:32:13 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_swap.c,v 1.163 2013/05/07 15:49:09 riastradh Exp $ */
+/* $NetBSD: uvm_swap.c,v 1.164 2013/11/23 14:32:13 christos 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.163 2013/05/07 15:49:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.164 2013/11/23 14:32:13 christos Exp $");
#include "opt_uvmhist.h"
#include "opt_compat_netbsd.h"
@@ -81,7 +81,7 @@
* partitions/files. there is a sorted LIST of "swappri" structures
* which describe "swapdev"'s at that priority. this LIST is headed
* by the "swap_priority" global var. each "swappri" contains a
- * CIRCLEQ of "swapdev" structures at that priority.
+ * TAILQ of "swapdev" structures at that priority.
*
* locking:
* - swap_syscall_lock (krwlock_t): this lock serializes the swapctl
@@ -136,7 +136,7 @@
int swd_drumsize; /* #pages in drum */
blist_t swd_blist; /* blist for this swapdev */
struct vnode *swd_vp; /* backing vnode */
- CIRCLEQ_ENTRY(swapdev) swd_next; /* priority circleq */
+ TAILQ_ENTRY(swapdev) swd_next; /* priority circleq */
int swd_bsize; /* blocksize (bytes) */
int swd_maxactive; /* max active i/o reqs */
@@ -149,7 +149,7 @@
*/
struct swappri {
int spi_priority; /* priority */
- CIRCLEQ_HEAD(spi_swapdev, swapdev) spi_swapdev;
+ TAILQ_HEAD(spi_swapdev, swapdev) spi_swapdev;
/* circleq of swapdevs at this priority */
LIST_ENTRY(swappri) spi_swappri; /* global list of pri's */
};
@@ -335,7 +335,7 @@
priority, 0, 0, 0);
spp->spi_priority = priority;
- CIRCLEQ_INIT(&spp->spi_swapdev);
+ TAILQ_INIT(&spp->spi_swapdev);
if (pspp)
LIST_INSERT_AFTER(pspp, spp, spi_swappri);
@@ -351,7 +351,7 @@
* circleq list and bump the total number of swapdevs.
*/
sdp->swd_priority = priority;
- CIRCLEQ_INSERT_TAIL(&spp->spi_swapdev, sdp, swd_next);
+ TAILQ_INSERT_TAIL(&spp->spi_swapdev, sdp, swd_next);
uvmexp.nswapdev++;
}
@@ -373,10 +373,10 @@
*/
LIST_FOREACH(spp, &swap_priority, spi_swappri) {
- CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
+ TAILQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
if (sdp->swd_vp == vp) {
if (remove) {
- CIRCLEQ_REMOVE(&spp->spi_swapdev,
+ TAILQ_REMOVE(&spp->spi_swapdev,
sdp, swd_next);
uvmexp.nswapdev--;
}
@@ -399,8 +399,7 @@
struct swappri *spp, *nextspp;
LIST_FOREACH_SAFE(spp, &swap_priority, spi_swappri, nextspp) {
- if (CIRCLEQ_FIRST(&spp->spi_swapdev) !=
- (void *)&spp->spi_swapdev)
+ if (TAILQ_EMPTY(&spp->spi_swapdev))
continue;
LIST_REMOVE(spp, spi_swappri);
kmem_free(spp, sizeof(*spp));
@@ -421,7 +420,7 @@
struct swappri *spp;
LIST_FOREACH(spp, &swap_priority, spi_swappri) {
- CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
+ TAILQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
if (sdp->swd_flags & SWF_FAKE)
continue;
if (pgno >= sdp->swd_drumoffset &&
@@ -742,7 +741,7 @@
int count = 0;
LIST_FOREACH(spp, &swap_priority, spi_swappri) {
- CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
+ TAILQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
int inuse;
if (sec-- <= 0)
@@ -1108,6 +1107,55 @@
return (0);
}
+void
+uvm_swap_shutdown(struct lwp *l)
+{
+ struct swapdev *sdp;
+ struct swappri *spp;
+ struct vnode *vp;
+ int error;
+
+ printf("turning of swap...");
+ rw_enter(&swap_syscall_lock, RW_WRITER);
+ mutex_enter(&uvm_swap_data_lock);
+again:
+ LIST_FOREACH(spp, &swap_priority, spi_swappri)
+ TAILQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
+ if (sdp->swd_flags & SWF_FAKE)
+ continue;
+ if ((sdp->swd_flags & (SWF_INUSE|SWF_ENABLE)) == 0)
+ continue;
+#ifdef DEBUG
+ printf("\nturning off swap on %s...",
+ sdp->swd_path);
+#endif
+ if (vn_lock(vp = sdp->swd_vp, LK_EXCLUSIVE)) {
+ error = EBUSY;
+ vp = NULL;
+ } else
+ error = 0;
+ if (!error) {
+ error = swap_off(l, sdp);
+ mutex_enter(&uvm_swap_data_lock);
+ }
+ if (error) {
+ printf("stopping swap on %s failed "
+ "with error %d\n", sdp->swd_path, error);
+ TAILQ_REMOVE(&spp->spi_swapdev, sdp,
+ swd_next);
+ uvmexp.nswapdev--;
+ swaplist_trim();
+ if (vp)
+ vput(vp);
+ }
+ goto again;
+ }
+ printf(" done\n");
+ mutex_exit(&uvm_swap_data_lock);
+ rw_exit(&swap_syscall_lock);
+}
+
+
/*
* /dev/drum interface and i/o functions
*/
@@ -1555,7 +1603,7 @@
ReTry: /* XXXMRG */
LIST_FOREACH(spp, &swap_priority, spi_swappri) {
- CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
+ TAILQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
uint64_t result;
/* if it's not enabled, then we can't swap from it */
@@ -1572,8 +1620,8 @@
/*
* successful allocation! now rotate the circleq.
*/
- CIRCLEQ_REMOVE(&spp->spi_swapdev, sdp, swd_next);
- CIRCLEQ_INSERT_TAIL(&spp->spi_swapdev, sdp, swd_next);
+ TAILQ_REMOVE(&spp->spi_swapdev, sdp, swd_next);
+ TAILQ_INSERT_TAIL(&spp->spi_swapdev, sdp, swd_next);
sdp->swd_npginuse += *nslots;
uvmexp.swpginuse += *nslots;
mutex_exit(&uvm_swap_data_lock);
diff -r 0d5e4b6116d7 -r e7823a681dcb sys/uvm/uvm_swap.h
--- a/sys/uvm/uvm_swap.h Sat Nov 23 14:20:46 2013 +0000
+++ b/sys/uvm/uvm_swap.h Sat Nov 23 14:32:13 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_swap.h,v 1.18 2011/04/27 00:35:52 rmind Exp $ */
+/* $NetBSD: uvm_swap.h,v 1.19 2013/11/23 14:32:13 christos Exp $ */
/*
* Copyright (c) 1997 Matthew R. Green
@@ -39,6 +39,7 @@
#endif
struct swapent;
+struct lwp;
#if defined(VMSWAP)
int uvm_swap_get(struct vm_page *, int, int);
@@ -50,6 +51,7 @@
#else /* defined(VMSWAP) */
#define uvm_swapisfull() true
#endif /* defined(VMSWAP) */
+void uvm_swap_shutdown(struct lwp *);
#endif /* _KERNEL */
Home |
Main Index |
Thread Index |
Old Index