Adding a device to an existing priority ring reuses the per-CPU reader storage. A ring that previously contained one device can therefore keep every CPU at the old common starting offset after peers are added. Deleting devices or rings can likewise leave offsets and quotas that describe the previous membership. Reset the valid per-CPU ring offsets and quotas after peer insertion and every nonempty deletion. Run the initialization helper under the topology writer, which excludes allocation walks, without allocating new reader storage or adding selector hot-path work. Use cpu-id modulo placement for a fresh best-effort rotation across all valid rings. This does not move existing slots or guarantee strict balance for every active CPU subset. Mask and availability transitions do not trigger the topology reset. Signed-off-by: Lian Wang --- mm/swapfile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/swapfile.c b/mm/swapfile.c index 9e90f815f99c..d659afb574b3 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -496,6 +496,7 @@ add_to_ring: spin_unlock(&swap_queue_update_lock); memalloc_noreclaim_restore(noreclaim_flag); kfree(old_ring); + swap_queue_reset_readers(); return 0; failed: @@ -568,6 +569,8 @@ static void swap_queue_del(struct swap_info_struct *si) swap_queue_install_readers(NULL, 0); } spin_unlock(&swap_queue_update_lock); + if (swap_queue_len) + swap_queue_reset_readers(); kfree(old_ring); kfree(old_queue);