4 * Copyright (c) 2010 The DragonFly Project. All rights reserved.
6 * This code is derived from software contributed to The DragonFly Project
7 * by Matthew Dillon <dillon@backplane.com>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
19 * 3. Neither the name of The DragonFly Project nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific, prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * Implement the swapcache daemon. When enabled swap is assumed to be
39 * configured on a fast storage device such as a SSD. Swap is assigned
40 * to clean vnode-backed pages in the inactive queue, clustered by object
41 * if possible, and written out. The swap assignment sticks around even
42 * after the underlying pages have been recycled.
44 * The daemon manages write bandwidth based on sysctl settings to control
47 * The vnode strategy code will check for the swap assignments and divert
48 * reads to the swap device when the data is present in the swapcache.
50 * This operates on both regular files and the block device vnodes used by
51 * filesystems to manage meta-data.
55 #include <sys/param.h>
56 #include <sys/systm.h>
57 #include <sys/kernel.h>
59 #include <sys/kthread.h>
60 #include <sys/resourcevar.h>
61 #include <sys/signalvar.h>
62 #include <sys/vnode.h>
63 #include <sys/vmmeter.h>
64 #include <sys/sysctl.h>
65 #include <sys/eventhandler.h>
68 #include <vm/vm_param.h>
70 #include <vm/vm_object.h>
71 #include <vm/vm_page.h>
72 #include <vm/vm_map.h>
73 #include <vm/vm_pageout.h>
74 #include <vm/vm_pager.h>
75 #include <vm/swap_pager.h>
76 #include <vm/vm_extern.h>
78 #include <sys/spinlock2.h>
79 #include <vm/vm_page2.h>
81 /* the kernel process "vm_pageout"*/
82 static int vm_swapcached_flush (vm_page_t m, int isblkdev);
83 static int vm_swapcache_test(vm_page_t m);
84 static int vm_swapcache_writing_heuristic(void);
85 static int vm_swapcache_writing(vm_page_t marker, int count, int scount);
86 static void vm_swapcache_cleaning(vm_object_t marker,
87 struct vm_object_hash **swindexp);
88 static void vm_swapcache_movemarker(vm_object_t marker,
89 struct vm_object_hash *swindex, vm_object_t object);
90 struct thread *swapcached_thread;
92 SYSCTL_NODE(_vm, OID_AUTO, swapcache, CTLFLAG_RW, NULL, NULL);
94 int vm_swapcache_read_enable;
95 static long vm_swapcache_wtrigger;
96 static int vm_swapcache_sleep;
97 static int vm_swapcache_maxscan = PQ_L2_SIZE * 8;
98 static int vm_swapcache_maxlaunder = PQ_L2_SIZE * 4;
99 static int vm_swapcache_data_enable = 0;
100 static int vm_swapcache_meta_enable = 0;
101 static int vm_swapcache_maxswappct = 75;
102 static int vm_swapcache_hysteresis;
103 static int vm_swapcache_min_hysteresis;
104 int vm_swapcache_use_chflags = 0; /* require chflags cache */
105 static int64_t vm_swapcache_minburst = 10000000LL; /* 10MB */
106 static int64_t vm_swapcache_curburst = 4000000000LL; /* 4G after boot */
107 static int64_t vm_swapcache_maxburst = 2000000000LL; /* 2G nominal max */
108 static int64_t vm_swapcache_accrate = 100000LL; /* 100K/s */
109 static int64_t vm_swapcache_write_count;
110 static int64_t vm_swapcache_maxfilesize;
111 static int64_t vm_swapcache_cleanperobj = 16*1024*1024;
113 SYSCTL_INT(_vm_swapcache, OID_AUTO, maxlaunder,
114 CTLFLAG_RW, &vm_swapcache_maxlaunder, 0, "");
115 SYSCTL_INT(_vm_swapcache, OID_AUTO, maxscan,
116 CTLFLAG_RW, &vm_swapcache_maxscan, 0, "");
118 SYSCTL_INT(_vm_swapcache, OID_AUTO, data_enable,
119 CTLFLAG_RW, &vm_swapcache_data_enable, 0, "");
120 SYSCTL_INT(_vm_swapcache, OID_AUTO, meta_enable,
121 CTLFLAG_RW, &vm_swapcache_meta_enable, 0, "");
122 SYSCTL_INT(_vm_swapcache, OID_AUTO, read_enable,
123 CTLFLAG_RW, &vm_swapcache_read_enable, 0, "");
124 SYSCTL_INT(_vm_swapcache, OID_AUTO, maxswappct,
125 CTLFLAG_RW, &vm_swapcache_maxswappct, 0, "");
126 SYSCTL_INT(_vm_swapcache, OID_AUTO, hysteresis,
127 CTLFLAG_RD, &vm_swapcache_hysteresis, 0, "");
128 SYSCTL_INT(_vm_swapcache, OID_AUTO, min_hysteresis,
129 CTLFLAG_RW, &vm_swapcache_min_hysteresis, 0, "");
130 SYSCTL_INT(_vm_swapcache, OID_AUTO, use_chflags,
131 CTLFLAG_RW, &vm_swapcache_use_chflags, 0, "");
133 SYSCTL_QUAD(_vm_swapcache, OID_AUTO, minburst,
134 CTLFLAG_RW, &vm_swapcache_minburst, 0, "");
135 SYSCTL_QUAD(_vm_swapcache, OID_AUTO, curburst,
136 CTLFLAG_RW, &vm_swapcache_curburst, 0, "");
137 SYSCTL_QUAD(_vm_swapcache, OID_AUTO, maxburst,
138 CTLFLAG_RW, &vm_swapcache_maxburst, 0, "");
139 SYSCTL_QUAD(_vm_swapcache, OID_AUTO, maxfilesize,
140 CTLFLAG_RW, &vm_swapcache_maxfilesize, 0, "");
141 SYSCTL_QUAD(_vm_swapcache, OID_AUTO, accrate,
142 CTLFLAG_RW, &vm_swapcache_accrate, 0, "");
143 SYSCTL_QUAD(_vm_swapcache, OID_AUTO, write_count,
144 CTLFLAG_RW, &vm_swapcache_write_count, 0, "");
145 SYSCTL_QUAD(_vm_swapcache, OID_AUTO, cleanperobj,
146 CTLFLAG_RW, &vm_swapcache_cleanperobj, 0, "");
148 #define SWAPMAX(adj) \
149 ((int64_t)vm_swap_max * (vm_swapcache_maxswappct + (adj)) / 100)
152 * When shutting down the machine we want to stop swapcache operation
153 * immediately so swap is not accessed after devices have been shuttered.
156 shutdown_swapcache(void *arg __unused)
158 vm_swapcache_read_enable = 0;
159 vm_swapcache_data_enable = 0;
160 vm_swapcache_meta_enable = 0;
161 wakeup(&vm_swapcache_sleep); /* shortcut 5-second wait */
165 * vm_swapcached is the high level pageout daemon.
170 vm_swapcached_thread(void)
172 enum { SWAPC_WRITING, SWAPC_CLEANING } state = SWAPC_WRITING;
173 enum { SWAPB_BURSTING, SWAPB_RECOVERING } burst = SWAPB_BURSTING;
174 static struct vm_page page_marker[PQ_L2_SIZE];
175 static struct vm_object swmarker;
176 static struct vm_object_hash *swindex;
182 curthread->td_flags |= TDF_SYSTHREAD;
183 EVENTHANDLER_REGISTER(shutdown_pre_sync, shutdown_kproc,
184 swapcached_thread, SHUTDOWN_PRI_FIRST);
185 EVENTHANDLER_REGISTER(shutdown_pre_sync, shutdown_swapcache,
186 NULL, SHUTDOWN_PRI_SECOND);
189 * Initialize our marker for the inactive scan (SWAPC_WRITING)
191 bzero(&page_marker, sizeof(page_marker));
192 for (q = 0; q < PQ_L2_SIZE; ++q) {
193 page_marker[q].flags = PG_FICTITIOUS | PG_MARKER;
194 page_marker[q].busy_count = PBUSY_LOCKED;
195 page_marker[q].queue = PQ_INACTIVE + q;
196 page_marker[q].pc = q;
197 page_marker[q].wire_count = 1;
198 vm_page_queues_spin_lock(PQ_INACTIVE + q);
200 &vm_page_queues[PQ_INACTIVE + q].pl,
201 &page_marker[q], pageq);
202 vm_page_queues_spin_unlock(PQ_INACTIVE + q);
205 vm_swapcache_min_hysteresis = 1024;
206 vm_swapcache_hysteresis = vm_swapcache_min_hysteresis;
207 vm_swapcache_wtrigger = -vm_swapcache_hysteresis;
210 * Initialize our marker for the vm_object scan (SWAPC_CLEANING)
212 bzero(&swmarker, sizeof(swmarker));
213 swmarker.type = OBJT_MARKER;
214 swindex = &vm_object_hash[0];
215 lwkt_gettoken(&swindex->token);
216 TAILQ_INSERT_HEAD(&swindex->list, &swmarker, object_list);
217 lwkt_reltoken(&swindex->token);
227 kproc_suspend_loop();
230 * Check every 5 seconds when not enabled or if no swap
233 if ((vm_swapcache_data_enable == 0 &&
234 vm_swapcache_meta_enable == 0 &&
235 vm_swap_cache_use <= SWAPMAX(0)) ||
237 tsleep(&vm_swapcache_sleep, 0, "csleep", hz * 5);
242 * Polling rate when enabled is approximately 10 hz.
244 tsleep(&vm_swapcache_sleep, 0, "csleep", hz / 10);
247 * State hysteresis. Generate write activity up to 75% of
248 * swap, then clean out swap assignments down to 70%, then
251 if (state == SWAPC_WRITING) {
252 if (vm_swap_cache_use > SWAPMAX(0))
253 state = SWAPC_CLEANING;
255 if (vm_swap_cache_use < SWAPMAX(-10))
256 state = SWAPC_WRITING;
260 * We are allowed to continue accumulating burst value
261 * in either state. Allow the user to set curburst > maxburst
262 * for the initial load-in.
264 if (vm_swapcache_curburst < vm_swapcache_maxburst) {
265 vm_swapcache_curburst += vm_swapcache_accrate / 10;
266 if (vm_swapcache_curburst > vm_swapcache_maxburst)
267 vm_swapcache_curburst = vm_swapcache_maxburst;
271 * We don't want to nickle-and-dime the scan as that will
272 * create unnecessary fragmentation. The minimum burst
273 * is one-seconds worth of accumulation.
275 if (state != SWAPC_WRITING) {
276 vm_swapcache_cleaning(&swmarker, &swindex);
279 if (vm_swapcache_curburst < vm_swapcache_accrate)
283 count = vm_swapcache_maxlaunder / PQ_L2_SIZE + 2;
284 scount = vm_swapcache_maxscan / PQ_L2_SIZE + 2;
286 if (burst == SWAPB_BURSTING) {
287 if (vm_swapcache_writing_heuristic()) {
288 for (q = 0; q < PQ_L2_SIZE; ++q) {
290 vm_swapcache_writing(
296 if (vm_swapcache_curburst <= 0)
297 burst = SWAPB_RECOVERING;
298 } else if (vm_swapcache_curburst > vm_swapcache_minburst) {
299 if (vm_swapcache_writing_heuristic()) {
300 for (q = 0; q < PQ_L2_SIZE; ++q) {
302 vm_swapcache_writing(
308 burst = SWAPB_BURSTING;
310 if (reached_end == PQ_L2_SIZE) {
311 vm_swapcache_wtrigger = -vm_swapcache_hysteresis;
316 * Cleanup (NOT REACHED)
318 for (q = 0; q < PQ_L2_SIZE; ++q) {
319 vm_page_queues_spin_lock(PQ_INACTIVE + q);
321 &vm_page_queues[PQ_INACTIVE + q].pl,
322 &page_marker[q], pageq);
323 vm_page_queues_spin_unlock(PQ_INACTIVE + q);
326 lwkt_gettoken(&swindex->token);
327 TAILQ_REMOVE(&swindex->list, &swmarker, object_list);
328 lwkt_reltoken(&swindex->token);
331 static struct kproc_desc swpc_kp = {
333 vm_swapcached_thread,
336 SYSINIT(swapcached, SI_SUB_KTHREAD_PAGE, SI_ORDER_SECOND, kproc_start, &swpc_kp);
339 * Deal with an overflow of the heuristic counter or if the user
340 * manually changes the hysteresis.
342 * Try to avoid small incremental pageouts by waiting for enough
343 * pages to buildup in the inactive queue to hopefully get a good
344 * burst in. This heuristic is bumped by the VM system and reset
345 * when our scan hits the end of the queue.
347 * Return TRUE if we need to take a writing pass.
350 vm_swapcache_writing_heuristic(void)
356 hyst = vmstats.v_inactive_count / 4;
357 if (hyst < vm_swapcache_min_hysteresis)
358 hyst = vm_swapcache_min_hysteresis;
360 vm_swapcache_hysteresis = hyst;
363 for (q = PQ_INACTIVE; q < PQ_INACTIVE + PQ_L2_SIZE; ++q) {
364 adds += atomic_swap_long(&vm_page_queues[q].adds, 0);
366 vm_swapcache_wtrigger += adds;
367 if (vm_swapcache_wtrigger < -hyst)
368 vm_swapcache_wtrigger = -hyst;
369 return (vm_swapcache_wtrigger >= 0);
373 * Take a writing pass on one of the inactive queues, return non-zero if
374 * we hit the end of the queue.
377 vm_swapcache_writing(vm_page_t marker, int count, int scount)
385 * Scan the inactive queue from our marker to locate
386 * suitable pages to push to the swap cache.
388 * We are looking for clean vnode-backed pages.
390 vm_page_queues_spin_lock(marker->queue);
391 while ((m = TAILQ_NEXT(marker, pageq)) != NULL &&
392 count > 0 && scount-- > 0) {
393 KKASSERT(m->queue == marker->queue);
396 * Stop using swap if paniced, dumping, or dumped.
397 * Don't try to write if our curburst has been exhausted.
399 if (panicstr || dumping)
401 if (vm_swapcache_curburst < 0)
408 &vm_page_queues[marker->queue].pl, marker, pageq);
410 &vm_page_queues[marker->queue].pl, m, marker, pageq);
413 * Ignore markers and ignore pages that already have a swap
416 if (m->flags & (PG_MARKER | PG_SWAPPED))
418 if (vm_page_busy_try(m, TRUE))
420 vm_page_queues_spin_unlock(marker->queue);
422 if ((object = m->object) == NULL) {
424 vm_page_queues_spin_lock(marker->queue);
427 vm_object_hold(object);
428 if (m->object != object) {
429 vm_object_drop(object);
431 vm_page_queues_spin_lock(marker->queue);
434 if (vm_swapcache_test(m)) {
435 vm_object_drop(object);
437 vm_page_queues_spin_lock(marker->queue);
443 vm_object_drop(object);
445 vm_page_queues_spin_lock(marker->queue);
452 * PG_NOTMETA generically means 'don't swapcache this',
453 * and HAMMER will set this for regular data buffers
454 * (and leave it unset for meta-data buffers) as
455 * appropriate when double buffering is enabled.
457 if (m->flags & PG_NOTMETA) {
458 vm_object_drop(object);
460 vm_page_queues_spin_lock(marker->queue);
465 * If data_enable is 0 do not try to swapcache data.
466 * If use_chflags is set then only swapcache data for
467 * VSWAPCACHE marked vnodes, otherwise any vnode.
469 if (vm_swapcache_data_enable == 0 ||
470 ((vp->v_flag & VSWAPCACHE) == 0 &&
471 vm_swapcache_use_chflags)) {
472 vm_object_drop(object);
474 vm_page_queues_spin_lock(marker->queue);
477 if (vm_swapcache_maxfilesize &&
479 (vm_swapcache_maxfilesize >> PAGE_SHIFT)) {
480 vm_object_drop(object);
482 vm_page_queues_spin_lock(marker->queue);
489 * PG_NOTMETA generically means 'don't swapcache this',
490 * and HAMMER will set this for regular data buffers
491 * (and leave it unset for meta-data buffers) as
492 * appropriate when double buffering is enabled.
494 if (m->flags & PG_NOTMETA) {
495 vm_object_drop(object);
497 vm_page_queues_spin_lock(marker->queue);
500 if (vm_swapcache_meta_enable == 0) {
501 vm_object_drop(object);
503 vm_page_queues_spin_lock(marker->queue);
509 vm_object_drop(object);
511 vm_page_queues_spin_lock(marker->queue);
517 * Assign swap and initiate I/O.
519 * (adjust for the --count which also occurs in the loop)
521 count -= vm_swapcached_flush(m, isblkdev);
524 * Setup for next loop using marker.
526 vm_object_drop(object);
527 vm_page_queues_spin_lock(marker->queue);
531 * The marker could wind up at the end, which is ok. If we hit the
532 * end of the list adjust the heuristic.
534 * Earlier inactive pages that were dirty and become clean
535 * are typically moved to the end of PQ_INACTIVE by virtue
536 * of vfs_vmio_release() when they become unwired from the
539 vm_page_queues_spin_unlock(marker->queue);
542 * m invalid but can be used to test for NULL
548 * Flush the specified page using the swap_pager. The page
549 * must be busied by the caller and its disposition will become
550 * the responsibility of this function.
552 * Try to collect surrounding pages, including pages which may
553 * have already been assigned swap. Try to cluster within a
554 * contiguous aligned SMAP_META_PAGES (typ 16 x PAGE_SIZE) block
555 * to match what swap_pager_putpages() can do.
557 * We also want to try to match against the buffer cache blocksize
558 * but we don't really know what it is here. Since the buffer cache
559 * wires and unwires pages in groups the fact that we skip wired pages
560 * should be sufficient.
562 * Returns a count of pages we might have flushed (minimum 1)
566 vm_swapcached_flush(vm_page_t m, int isblkdev)
569 vm_page_t marray[SWAP_META_PAGES];
571 int rtvals[SWAP_META_PAGES];
579 vm_page_protect(m, VM_PROT_READ);
581 vm_object_hold(object);
584 * Try to cluster around (m), keeping in mind that the swap pager
585 * can only do SMAP_META_PAGES worth of continguous write.
587 x = (int)m->pindex & SWAP_META_MASK;
592 for (i = x - 1; i >= 0; --i) {
593 m = vm_page_lookup_busy_try(object, basei - x + i,
595 if (error || m == NULL)
597 if (vm_swapcache_test(m)) {
601 if (isblkdev && (m->flags & PG_NOTMETA)) {
606 vm_page_protect(m, VM_PROT_READ);
607 if (m->queue - m->pc == PQ_CACHE) {
608 vm_page_unqueue_nowakeup(m);
609 vm_page_deactivate(m);
616 for (j = x + 1; j < SWAP_META_PAGES; ++j) {
617 m = vm_page_lookup_busy_try(object, basei - x + j,
619 if (error || m == NULL)
621 if (vm_swapcache_test(m)) {
625 if (isblkdev && (m->flags & PG_NOTMETA)) {
630 vm_page_protect(m, VM_PROT_READ);
631 if (m->queue - m->pc == PQ_CACHE) {
632 vm_page_unqueue_nowakeup(m);
633 vm_page_deactivate(m);
640 vm_object_pip_add(object, count);
641 swap_pager_putpages(object, marray + i, count, FALSE, rtvals + i);
642 vm_swapcache_write_count += count * PAGE_SIZE;
643 vm_swapcache_curburst -= count * PAGE_SIZE;
646 if (rtvals[i] != VM_PAGER_PEND) {
647 vm_page_busy_wait(marray[i], FALSE, "swppgfd");
648 vm_page_io_finish(marray[i]);
649 vm_page_wakeup(marray[i]);
650 vm_object_pip_wakeup(object);
654 vm_object_drop(object);
659 * Test whether a VM page is suitable for writing to the swapcache.
660 * Does not test m->queue, PG_MARKER, or PG_SWAPPED.
662 * Returns 0 on success, 1 on failure
665 vm_swapcache_test(vm_page_t m)
669 if (m->flags & PG_UNMANAGED)
671 if (m->hold_count || m->wire_count)
673 if (m->valid != VM_PAGE_BITS_ALL)
675 if (m->dirty & m->valid)
677 if ((object = m->object) == NULL)
679 if (object->type != OBJT_VNODE ||
680 (object->flags & OBJ_DEAD)) {
683 vm_page_test_dirty(m);
684 if (m->dirty & m->valid)
692 * We clean whole objects up to 16MB
696 vm_swapcache_cleaning(vm_object_t marker, struct vm_object_hash **swindexp)
705 count = vm_swapcache_maxlaunder;
706 scount = vm_swapcache_maxscan;
709 * Look for vnode objects
711 lwkt_gettoken(&(*swindexp)->token);
715 while ((object = TAILQ_NEXT(marker, object_list)) != NULL) {
717 * We have to skip markers. We cannot hold/drop marker
720 if (object->type == OBJT_MARKER) {
721 vm_swapcache_movemarker(marker, *swindexp, object);
727 * Safety, or in case there are millions of VM objects
728 * without swapcache backing.
734 * We must hold the object before potentially yielding.
736 vm_object_hold(object);
740 * Only operate on live VNODE objects that are either
741 * VREG or VCHR (VCHR for meta-data).
743 if ((object->type != OBJT_VNODE) ||
744 ((object->flags & OBJ_DEAD) ||
745 object->swblock_count == 0) ||
746 ((vp = object->handle) == NULL) ||
747 (vp->v_type != VREG && vp->v_type != VCHR)) {
748 vm_object_drop(object);
749 /* object may be invalid now */
750 vm_swapcache_movemarker(marker, *swindexp, object);
756 * Reset the object pindex stored in the marker if the
757 * working object has changed.
759 if (marker->backing_object != object || didmove) {
761 marker->backing_object_offset = 0;
762 marker->backing_object = object;
767 * Look for swblocks starting at our iterator.
769 * The swap_pager_condfree() function attempts to free
770 * swap space starting at the specified index. The index
771 * will be updated on return. The function will return
772 * a scan factor (NOT the number of blocks freed).
774 * If it must cut its scan of the object short due to an
775 * excessive number of swblocks, or is able to free the
776 * requested number of blocks, it will return n >= count
777 * and we break and pick it back up on a future attempt.
779 * Scan the object linearly and try to batch large sets of
780 * blocks that are likely to clean out entire swap radix
784 lwkt_reltoken(&(*swindexp)->token);
786 n = swap_pager_condfree(object, &marker->size,
787 (count + SWAP_META_MASK) & ~SWAP_META_MASK);
789 vm_object_drop(object); /* object may be invalid now */
790 lwkt_gettoken(&(*swindexp)->token);
793 * If we have exhausted the object or deleted our per-pass
794 * page limit then move us to the next object. Note that
795 * the current object may no longer be on the vm_object_list.
798 marker->backing_object_offset > vm_swapcache_cleanperobj) {
799 vm_swapcache_movemarker(marker, *swindexp, object);
804 * If we have exhausted our max-launder stop for now.
807 marker->backing_object_offset += n * PAGE_SIZE;
813 * Iterate vm_object_lists[] hash table
815 TAILQ_REMOVE(&(*swindexp)->list, marker, object_list);
816 lwkt_reltoken(&(*swindexp)->token);
817 if (++*swindexp >= &vm_object_hash[VMOBJ_HSIZE])
818 *swindexp = &vm_object_hash[0];
819 lwkt_gettoken(&(*swindexp)->token);
820 TAILQ_INSERT_HEAD(&(*swindexp)->list, marker, object_list);
822 if (*swindexp != &vm_object_hash[0])
826 lwkt_reltoken(&(*swindexp)->token);
830 * Move the marker past the current object. Object can be stale, but we
831 * still need it to determine if the marker has to be moved. If the object
832 * is still the 'current object' (object after the marker), we hop-scotch
833 * the marker past it.
836 vm_swapcache_movemarker(vm_object_t marker, struct vm_object_hash *swindex,
839 if (TAILQ_NEXT(marker, object_list) == object) {
840 TAILQ_REMOVE(&swindex->list, marker, object_list);
841 TAILQ_INSERT_AFTER(&swindex->list, object, marker, object_list);