On Tue, Mar 10, 2026 at 08:08:36PM -0300, Jorge Merlino wrote:
>  void throttle_group_restart_tgm(ThrottleGroupMember *tgm)
>  {
>      ThrottleDirection dir;
> +    ThrottleState *ts = tgm->throttle_state;
> +    ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts);
>  
>      if (tgm->throttle_state) {
>          for (dir = THROTTLE_READ; dir < THROTTLE_MAX; dir++) {
>              QEMUTimer *t = tgm->throttle_timers.timers[dir];
> +            qemu_mutex_lock(&tg->lock);
>              if (timer_pending(t)) {
> +                qemu_mutex_unlock(&tg->lock);

I think I was too fast with my patch, I overlooked this part.

Maybe we need something like this for that function:

 for (...) {

   qemu_mutex_lock();

   if (timer_pending()) {
      /* We had a timer, delete it, we'll restart the queue now */
      timer_del(...);
   } else if (tg->any_timer_armed) {
      /* Someone else had a timer, let's wait for that request to be
       * scheduled so we can go next */
      qemu_mutex_unlock();
      continue;
   } else {
      /* There are no timers in this group, let's run our request now.
         Set any_timer_armed so no one else does it in the meantime */
      tg->any_timer_armed = true;
   }

   qemu_mutex_unlock();
   throttle_group_restart_queue();

 }

Maybe any_timer_armed needs a new name in this case.

Berto

Reply via email to