On 10/11/2026 23:02, Dmitrii Omelchenko wrote:
> +
> +static void *rdma_consumer_thread(void *opaque)
> +{
> +    RDMAContext *rdma = opaque;
> +    RDMASendRing *r = rdma->send_ring;
> +    bool stop = false;
> +
> +    rcu_register_thread();
> +
> +    while (!qatomic_read(&r->abort) && !stop) {
> +        RDMACmd cmd;
> +
> +        if (ring_pop(r, &cmd)) {
> +            if (rdma_consumer_dispatch(rdma, &cmd, &stop) < 0) {
> +                ring_set_abort(rdma);
> +                break;
> +            }
> +            ring_advance_tail(r);
> +            continue;
> +        }
> +        ring_idle_wait(r);
> +    }
> +
> +    if (qatomic_read(&r->abort)) {
> +        /* make the failure visible to the producer's rdma_errored() checks 
> */
> +        rdma->errored = true;
> +    }
> +    rcu_unregister_thread();
> +    return NULL;
> +}
> +


The consumer thread writes rdma->errored here:

     if (qatomic_read(&r->abort)) {
         rdma->errored = true;
     }

However, rdma->errored is read by the producer/migration thread through
rdma_errored() and directly in the control-channel path. Since this is a
plain non-atomic store/read pair, the new consumer thread introduces a data
race.

The atomic access to r->abort does not make the subsequent rdma->errored
store safe, since the store happens after the abort handling and is not
protected by wait_lock. In particular, the producer may race with this
store while scanning dirty pages or waiting for a barrier.

Please either make rdma->errored atomic and use atomic accesses consistently,
or use the existing atomic ring abort state as the sole cross-thread error
indicator and have the producer-side error checks consult that state.

With this synchronization issue fixed, the consumer-thread error path will
be much easier to reason about.

Reply via email to