* Ensure that the page ends up in the specified page queue. If the page is * active or being moved to the active queue, ensure that its act_count is * at least ACT_INIT but do not otherwise mess with it. */
| 4058 | * at least ACT_INIT but do not otherwise mess with it. |
| 4059 | */ |
| 4060 | static __always_inline void |
| 4061 | vm_page_mvqueue(vm_page_t m, const uint8_t nqueue, const uint16_t nflag) |
| 4062 | { |
| 4063 | vm_page_astate_t old, new; |
| 4064 | |
| 4065 | KASSERT(m->ref_count > 0, |
| 4066 | ("%s: page %p does not carry any references", __func__, m)); |
| 4067 | KASSERT(nflag == PGA_REQUEUE || nflag == PGA_REQUEUE_HEAD, |
| 4068 | ("%s: invalid flags %x", __func__, nflag)); |
| 4069 | |
| 4070 | if ((m->oflags & VPO_UNMANAGED) != 0 || vm_page_wired(m)) |
| 4071 | return; |
| 4072 | |
| 4073 | old = vm_page_astate_load(m); |
| 4074 | do { |
| 4075 | if ((old.flags & PGA_DEQUEUE) != 0) |
| 4076 | break; |
| 4077 | new = old; |
| 4078 | new.flags &= ~PGA_QUEUE_OP_MASK; |
| 4079 | if (nqueue == PQ_ACTIVE) |
| 4080 | new.act_count = max(old.act_count, ACT_INIT); |
| 4081 | if (old.queue == nqueue) { |
| 4082 | if (nqueue != PQ_ACTIVE) |
| 4083 | new.flags |= nflag; |
| 4084 | } else { |
| 4085 | new.flags |= nflag; |
| 4086 | new.queue = nqueue; |
| 4087 | } |
| 4088 | } while (!vm_page_pqstate_commit(m, &old, new)); |
| 4089 | } |
| 4090 | |
| 4091 | /* |
| 4092 | * Put the specified page on the active list (if appropriate). |
no test coverage detected