Fix psset_pick_purge when last candidate with index 0 dirtiness is ineligible

psset_pick_purge used max_bit-- after rejecting a time-ineligible
candidate, which caused unnecessary re-scanning of the same bitmap
and makes assert fail in debug mode) and a size_t underflow
when the lowest-index entry was rejected.  Use max_bit = ind - 1
to skip directly past the rejected index.
This commit is contained in:
Slobodan Predolac 2026-03-25 21:13:34 -07:00 committed by Guangli Dai
parent 1d018d8fda
commit d758349ca4
2 changed files with 58 additions and 2 deletions

View file

@ -417,7 +417,10 @@ psset_pick_purge(psset_t *psset, const nstime_t *now) {
if (nstime_compare(tm_allowed, now) <= 0) {
return ps;
}
max_bit--;
if (ind == 0) {
break;
}
max_bit = ind - 1;
}
/* No page is ready yet */
return NULL;