Author: markj Date: Sun Sep 4 00:25:49 2016 New Revision: 305367 URL: https://svnweb.freebsd.org/changeset/base/305367
Log: Respect the caller's hints when performing swap readahead. The pager getpages interface allows the caller to bound the number of readahead and readbehind pages, and vm_fault_hold() makes use of this feature. These bounds were ignored after r305056, causing the swap pager to potentially page in more than the specified number of pages. Reported and reviewed by: alc X-MFC with: r305056 Modified: head/sys/vm/swap_pager.c Modified: head/sys/vm/swap_pager.c ============================================================================== --- head/sys/vm/swap_pager.c Sat Sep 3 23:57:17 2016 (r305366) +++ head/sys/vm/swap_pager.c Sun Sep 4 00:25:49 2016 (r305367) @@ -1086,7 +1086,7 @@ swap_pager_getpages(vm_object_t object, vm_page_t mpred, msucc, p; vm_pindex_t pindex; daddr_t blk; - int i, j, reqcount, shift; + int i, j, maxahead, maxbehind, reqcount, shift; reqcount = count; @@ -1094,7 +1094,7 @@ swap_pager_getpages(vm_object_t object, bp = getpbuf(&nsw_rcount); VM_OBJECT_WLOCK(object); - if (!swap_pager_haspage(object, m[0]->pindex, rbehind, rahead)) { + if (!swap_pager_haspage(object, m[0]->pindex, &maxbehind, &maxahead)) { relpbuf(bp, &nsw_rcount); return (VM_PAGER_FAIL); } @@ -1103,15 +1103,16 @@ swap_pager_getpages(vm_object_t object, * Clip the readahead and readbehind ranges to exclude resident pages. */ if (rahead != NULL) { - KASSERT(reqcount - 1 <= *rahead, + KASSERT(reqcount - 1 <= maxahead, ("page count %d extends beyond swap block", reqcount)); - *rahead -= reqcount - 1; + *rahead = imin(*rahead, maxahead - (reqcount - 1)); pindex = m[reqcount - 1]->pindex; msucc = TAILQ_NEXT(m[reqcount - 1], listq); if (msucc != NULL && msucc->pindex - pindex - 1 < *rahead) *rahead = msucc->pindex - pindex - 1; } if (rbehind != NULL) { + *rbehind = imin(*rbehind, maxbehind); pindex = m[0]->pindex; mpred = TAILQ_PREV(m[0], pglist, listq); if (mpred != NULL && pindex - mpred->pindex - 1 < *rbehind) _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"