From 068a5ea02f62853116788a2c42d8851a94bb7567 Mon Sep 17 00:00:00 2001 From: "Emilio G. Cota" Date: Sun, 19 Aug 2018 05:13:35 -0400 Subject: qom: convert the CPU list to RCU Iterating over the list without using atomics is undefined behaviour, since the list can be modified concurrently by other threads (e.g. every time a new thread is created in user-mode). Fix it by implementing the CPU list as an RCU QTAILQ. This requires a little bit of extra work to traverse list in reverse order (see previous patch), but other than that the conversion is trivial. Signed-off-by: Emilio G. Cota Message-Id: <20180819091335.22863-12-cota@braap.org> Signed-off-by: Paolo Bonzini --- cpus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cpus.c') diff --git a/cpus.c b/cpus.c index a5ea3eef80..91613491b7 100644 --- a/cpus.c +++ b/cpus.c @@ -1491,7 +1491,7 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) atomic_mb_set(&cpu->exit_request, 0); } - qemu_tcg_rr_wait_io_event(cpu ? cpu : QTAILQ_FIRST(&cpus)); + qemu_tcg_rr_wait_io_event(cpu ? cpu : first_cpu); deal_with_unplugged_cpus(); } -- cgit v1.2.3-70-g09d2