diff options
| author | Emilio G. Cota | 2018-08-19 11:13:35 +0200 |
|---|---|---|
| committer | Paolo Bonzini | 2018-08-23 18:46:25 +0200 |
| commit | 068a5ea02f62853116788a2c42d8851a94bb7567 (patch) | |
| tree | 0e7c635241a440b1aeee6dd853077fad928a40d4 /linux-user | |
| parent | spapr: do not use CPU_FOREACH_REVERSE (diff) | |
| download | qemu-068a5ea02f62853116788a2c42d8851a94bb7567.tar.gz qemu-068a5ea02f62853116788a2c42d8851a94bb7567.tar.xz qemu-068a5ea02f62853116788a2c42d8851a94bb7567.zip | |
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 <cota@braap.org>
Message-Id: <20180819091335.22863-12-cota@braap.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'linux-user')
| -rw-r--r-- | linux-user/main.c | 2 | ||||
| -rw-r--r-- | linux-user/syscall.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/linux-user/main.c b/linux-user/main.c index ea00dd9057..923cbb753a 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -126,7 +126,7 @@ void fork_end(int child) Discard information about the parent threads. */ CPU_FOREACH_SAFE(cpu, next_cpu) { if (cpu != thread_cpu) { - QTAILQ_REMOVE(&cpus, cpu, node); + QTAILQ_REMOVE_RCU(&cpus, cpu, node); } } qemu_init_cpu_list(); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 202aa777ad..3c3c1aec48 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8157,7 +8157,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, TaskState *ts; /* Remove the CPU from the list. */ - QTAILQ_REMOVE(&cpus, cpu, node); + QTAILQ_REMOVE_RCU(&cpus, cpu, node); cpu_list_unlock(); |
