Skip to contentSkip to conversation

accel/tcg: Remove dead code from rr_cpu_thread_fn()

PATCH In review Peter Maydell 2 participants 2 messages Aug 15, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 accel/tcg: Remove dead code from rr_cpu_thread_fn()

The main loop in rr_cpu_thread_fn() can never terminate, so the code at the end of the function to clean up the RCU subsystem is dead code. Replace it with g_assert_not_reached().

(This is different from the other cpu_thread_fn for e.g. MTTCG or for the KVM accelerator -- those can exit, if the vCPU they are responsible for is unplugged. But the RR cpu thread fn handles all CPUs in the system in a round-robin way, so even if one is unplugged it keeps looping.)

Resolves: Coverity CID 1547782

---
 accel/tcg/tcg-accel-ops-rr.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
accel/tcg/tcg-accel-ops-rr.c +1 -3
index 48c38714bd6..38ab16244e3 100644
@@ -302,9 +302,7 @@ static void *rr_cpu_thread_fn(void *arg)
         rr_deal_with_unplugged_cpus();
     }
 
-    rcu_remove_force_rcu_notifier(&force_rcu);
-    rcu_unregister_thread();
-    return NULL;
+    g_assert_not_reached();
 }
 
 void rr_start_vcpu_thread(CPUState *cpu)
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Peter Maydell

The main loop in rr_cpu_thread_fn() can never terminate, so the code at the end of the function to clean up the RCU subsystem is dead code. Replace it with g_assert_not_reached().

(This is different from the other cpu_thread_fn for e.g. MTTCG or for the KVM accelerator -- those can exit, if the vCPU they are responsible for is unplugged. But the RR cpu thread fn handles all CPUs in the system in a round-robin way, so even if one is unplugged it keeps looping.)

Resolves: Coverity CID 1547782

---
  accel/tcg/tcg-accel-ops-rr.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
accel/tcg/tcg-accel-ops-rr.c +0 -0
index 48c38714bd6..38ab16244e3 100644

accel/tcg/tcg-accel-ops-rr.c static void *rr_cpu_thread_fn(void *arg) · line 308

Quoted 10 lines
accel/tcg/tcg-accel-ops-rr.c +1 -3
@@ -302,9 +302,7 @@ static void *rr_cpu_thread_fn(void *arg)
          rr_deal_with_unplugged_cpus();
      }
 
-    rcu_remove_force_rcu_notifier(&force_rcu);
-    rcu_unregister_thread();
-    return NULL;
+    g_assert_not_reached();
  }
 
  void rr_start_vcpu_thread(CPUState *cpu)

r~