[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/12] cpus-common: ensure auto-assigned cpu_indexes don't clash
From: |
Alex Bennée |
Subject: |
[PULL 10/12] cpus-common: ensure auto-assigned cpu_indexes don't clash |
Date: |
Wed, 27 May 2020 15:54:53 +0100 |
Basing the cpu_index on the number of currently allocated vCPUs fails
when vCPUs aren't removed in a LIFO manner. This is especially true
when we are allocating a cpu_index for each guest thread in
linux-user where there is no ordering constraint on their allocation
and de-allocation.
[I've dropped the assert which is there to guard against out-of-order
removal as this should probably be caught higher up the stack. Maybe
we could just ifdef CONFIG_SOFTTMU it?]
Signed-off-by: Alex Bennée <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Acked-by: Igor Mammedow <address@hidden>
Cc: Nikolay Igotti <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Cc: Eduardo Habkost <address@hidden>
Message-Id: <address@hidden>
diff --git a/cpus-common.c b/cpus-common.c
index 55d5df89237..70a9d12981a 100644
--- a/cpus-common.c
+++ b/cpus-common.c
@@ -61,13 +61,15 @@ static bool cpu_index_auto_assigned;
static int cpu_get_free_index(void)
{
CPUState *some_cpu;
- int cpu_index = 0;
+ int max_cpu_index = 0;
cpu_index_auto_assigned = true;
CPU_FOREACH(some_cpu) {
- cpu_index++;
+ if (some_cpu->cpu_index >= max_cpu_index) {
+ max_cpu_index = some_cpu->cpu_index + 1;
+ }
}
- return cpu_index;
+ return max_cpu_index;
}
void cpu_list_add(CPUState *cpu)
@@ -90,8 +92,6 @@ void cpu_list_remove(CPUState *cpu)
return;
}
- assert(!(cpu_index_auto_assigned && cpu != QTAILQ_LAST(&cpus)));
-
QTAILQ_REMOVE_RCU(&cpus, cpu, node);
cpu->cpu_index = UNASSIGNED_CPU_INDEX;
}
--
2.20.1
- [PULL 01/12] configure: add alternate binary for genisoimage, (continued)
- [PULL 01/12] configure: add alternate binary for genisoimage, Alex Bennée, 2020/05/27
- [PULL 02/12] tests/vm: pass --genisoimage to basevm script, Alex Bennée, 2020/05/27
- [PULL 04/12] tests/tcg: fix invocation of the memory record/replay tests, Alex Bennée, 2020/05/27
- [PULL 05/12] tests/fp: enable extf80_le_quite tests, Alex Bennée, 2020/05/27
- [PULL 03/12] travis.yml: Use clang++ in the Clang tests, Alex Bennée, 2020/05/27
- [PULL 08/12] tests/docker: add debian11 base image, Alex Bennée, 2020/05/27
- [PULL 06/12] tests/fp: split and audit the conversion tests, Alex Bennée, 2020/05/27
- [PULL 07/12] tests/tcg: better detect confused gdb which can't connect, Alex Bennée, 2020/05/27
- [PULL 09/12] tests/docker: use a gcc-10 based image for arm64 tests, Alex Bennée, 2020/05/27
- [PULL 12/12] tests/tcg: add new threadcount test, Alex Bennée, 2020/05/27
- [PULL 10/12] cpus-common: ensure auto-assigned cpu_indexes don't clash,
Alex Bennée <=
- [PULL 11/12] linux-user: properly "unrealize" vCPU object, Alex Bennée, 2020/05/27
- Re: [PULL 00/12] testing and plugin fixes, Peter Maydell, 2020/05/28
- Re: [PULL 00/12] testing and plugin fixes, Alex Bennée, 2020/05/28
- Re: [PULL 00/12] testing and plugin fixes, Alex Bennée, 2020/05/28
- Re: [PULL 00/12] testing and plugin fixes, Peter Maydell, 2020/05/28
- Re: [PULL 00/12] testing and plugin fixes, Philippe Mathieu-Daudé, 2020/05/28
- Re: [PULL 00/12] testing and plugin fixes, Peter Maydell, 2020/05/28
- Re: [PULL 00/12] testing and plugin fixes, Philippe Mathieu-Daudé, 2020/05/28
- Re: [PULL 00/12] testing and plugin fixes, Peter Maydell, 2020/05/28
- Re: [PULL 00/12] testing and plugin fixes, Alex Bennée, 2020/05/28