Linux's kswapd daemon and its two-list active/inactive LRU approximation — a more scalable cousin of the victim selection you implement here — decide which pages get written to swap the moment memory pressure hits. Get victim selection wrong and you reproduce thrashing, the exact failure mode where a server burns more cycles swapping pages than serving requests.