--- sys/vm/vm_page.c.orig +++ sys/vm/vm_page.c @@ -4120,7 +4120,12 @@ if (nqueue == PQ_ACTIVE) new.act_count = max(old.act_count, ACT_INIT); if (old.queue == nqueue) { - if (nqueue != PQ_ACTIVE) + /* + * There is no need to requeue pages already in the + * active queue. + */ + if (nqueue != PQ_ACTIVE || + (old.flags & PGA_ENQUEUED) == 0) new.flags |= nflag; } else { new.flags |= nflag; @@ -4217,7 +4222,8 @@ * referenced and avoid any queue operations. */ new.flags &= ~PGA_QUEUE_OP_MASK; - if (nflag != PGA_REQUEUE_HEAD && old.queue == PQ_ACTIVE) + if (nflag != PGA_REQUEUE_HEAD && old.queue == PQ_ACTIVE && + (old.flags & PGA_ENQUEUED) != 0) new.flags |= PGA_REFERENCED; else { new.flags |= nflag;