@@ -622,8 +622,8 @@ static bool multifd_send_pages(void)
* using more channels, so ensure it doesn't overflow if the
* limit is lower now.
*/
- next_channel %= migrate_multifd_channels();
- for (i = next_channel;; i = (i + 1) % migrate_multifd_channels()) {
+ i = qatomic_load_acquire(&next_channel) % migrate_multifd_channels();
+ for (;; i = (i + 1) % migrate_multifd_channels()) {
if (multifd_send_should_exit()) {
return false;
}
@@ -633,7 +633,8 @@ static bool multifd_send_pages(void)
* sender thread can clear it.
*/
if (qatomic_read(&p->pending_job) == false) {
- next_channel = (i + 1) % migrate_multifd_channels();
+ qatomic_store_release(&next_channel,
+ (i + 1) % migrate_multifd_channels());
break;
}
}