From d70f0ab38d62708116e90de6dd57f9b31182e02e Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 3 Jul 2019 18:46:39 +0000 Subject: [PATCH] Cache the next queue element when traversing a page queue. When QUEUE_MACRO_DEBUG_TRASH is configured, removing a queue element invalidates its queue linkage pointers. vm_pageout_collect_batch() was relying on these pointers remaining valid after a removal, so modify it to fetch the next queued page before dequeuing the current page. Submitted by: Don Morris Reviewed by: cem, vangyzen MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D20842 --- sys/vm/vm_pageout.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index 333044121519..733678e4cbcb 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -266,7 +266,7 @@ static __always_inline void vm_pageout_collect_batch(struct scan_state *ss, const bool dequeue) { struct vm_pagequeue *pq; - vm_page_t m, marker; + vm_page_t m, marker, n; marker = ss->marker; pq = ss->pq; @@ -277,7 +277,8 @@ vm_pageout_collect_batch(struct scan_state *ss, const bool dequeue) vm_pagequeue_lock(pq); for (m = TAILQ_NEXT(marker, plinks.q); m != NULL && ss->scanned < ss->maxscan && ss->bq.bq_cnt < VM_BATCHQUEUE_SIZE; - m = TAILQ_NEXT(m, plinks.q), ss->scanned++) { + m = n, ss->scanned++) { + n = TAILQ_NEXT(m, plinks.q); if ((m->flags & PG_MARKER) == 0) { KASSERT((m->aflags & PGA_ENQUEUED) != 0, ("page %p not enqueued", m));