* Add a small number of queued pages to a batch queue for later processing * without the corresponding queue lock held. The caller must have enqueued a * marker page at the desired start point for the scan. Pages will be * physically dequeued if the caller so requests. Otherwise, the returned * batch may contain marker pages, and it is up to the caller to handle them. * * When processing
| 268 | * collected. |
| 269 | */ |
| 270 | static __always_inline void |
| 271 | vm_pageout_collect_batch(struct scan_state *ss, const bool dequeue) |
| 272 | { |
| 273 | struct vm_pagequeue *pq; |
| 274 | vm_page_t m, marker, n; |
| 275 | |
| 276 | marker = ss->marker; |
| 277 | pq = ss->pq; |
| 278 | |
| 279 | KASSERT((marker->a.flags & PGA_ENQUEUED) != 0, |
| 280 | ("marker %p not enqueued", ss->marker)); |
| 281 | |
| 282 | vm_pagequeue_lock(pq); |
| 283 | for (m = TAILQ_NEXT(marker, plinks.q); m != NULL && |
| 284 | ss->scanned < ss->maxscan && ss->bq.bq_cnt < VM_BATCHQUEUE_SIZE; |
| 285 | m = n, ss->scanned++) { |
| 286 | n = TAILQ_NEXT(m, plinks.q); |
| 287 | if ((m->flags & PG_MARKER) == 0) { |
| 288 | KASSERT((m->a.flags & PGA_ENQUEUED) != 0, |
| 289 | ("page %p not enqueued", m)); |
| 290 | KASSERT((m->flags & PG_FICTITIOUS) == 0, |
| 291 | ("Fictitious page %p cannot be in page queue", m)); |
| 292 | KASSERT((m->oflags & VPO_UNMANAGED) == 0, |
| 293 | ("Unmanaged page %p cannot be in page queue", m)); |
| 294 | } else if (dequeue) |
| 295 | continue; |
| 296 | |
| 297 | (void)vm_batchqueue_insert(&ss->bq, m); |
| 298 | if (dequeue) { |
| 299 | TAILQ_REMOVE(&pq->pq_pl, m, plinks.q); |
| 300 | vm_page_aflag_clear(m, PGA_ENQUEUED); |
| 301 | } |
| 302 | } |
| 303 | TAILQ_REMOVE(&pq->pq_pl, marker, plinks.q); |
| 304 | if (__predict_true(m != NULL)) |
| 305 | TAILQ_INSERT_BEFORE(m, marker, plinks.q); |
| 306 | else |
| 307 | TAILQ_INSERT_TAIL(&pq->pq_pl, marker, plinks.q); |
| 308 | if (dequeue) |
| 309 | vm_pagequeue_cnt_add(pq, -ss->bq.bq_cnt); |
| 310 | vm_pagequeue_unlock(pq); |
| 311 | } |
| 312 | |
| 313 | /* |
| 314 | * Return the next page to be scanned, or NULL if the scan is complete. |
no test coverage detected