[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 09/13] accel/all: Extract common_vcpu_thread_create()
|
From: |
Richard Henderson |
|
Subject: |
Re: [PATCH v4 09/13] accel/all: Extract common_vcpu_thread_create() |
|
Date: |
Wed, 23 Mar 2022 15:11:26 -0700 |
|
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 |
On 3/23/22 10:17, Philippe Mathieu-Daudé wrote:
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
All accelerators implement a very similar create_vcpu_thread()
handler. Extract the common part as common_vcpu_thread_create(),
which only requires the AccelOpsClass::vcpu_thread_fn() routine
and the accelerator AccelOpsClass::thread_name for debugging
purpose.
The single exception is TCG/RR which re-use a single vCPU. Have
it use the same logic by using the .precheck/.postcheck handlers.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Too much all at once.
But I see now why you moved code in the direction you did in patch 5.
@@ -279,28 +279,13 @@ bool rr_create_vcpu_thread_precheck(CPUState *cpu)
return !single_tcg_cpu_thread;
}
-void rr_start_vcpu_thread(CPUState *cpu)
+void rr_create_vcpu_thread_postcheck(CPUState *cpu)
{
- char thread_name[VCPU_THREAD_NAME_SIZE];
static QemuCond *single_tcg_halt_cond;
- static QemuThread *single_tcg_cpu_thread;
Patch 8 is not really standalone, since you didn't move this variable.
I think it's probably a mistake to split out precheck and postcheck separately.
-
- if (!single_tcg_cpu_thread) {
+ if (! single_tcg_cpu_thread) {
Extraneous whitespace.
@@ -30,7 +30,8 @@ struct AccelOpsClass {
bool (*cpus_are_resettable)(void);
- void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
+ const char *thread_name;
Why don't we just get this name from the AccelClass?
+static void common_vcpu_thread_create(CPUState *cpu)
+{
+ char thread_name[VCPU_THREAD_NAME_SIZE];
+
+ cpu->thread = g_new0(QemuThread, 1);
+ cpu->halt_cond = g_new0(QemuCond, 1);
+ qemu_cond_init(cpu->halt_cond);
+ snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/%s",
+ cpu->cpu_index, cpus_accel->thread_name ?: "DUMMY");
Surely g_strdup_printf is better than the static size buffer.
r~
- Re: [PATCH v4 03/13] target/i386/hvf: Free resources when vCPU is destroyed, (continued)
- [PATCH v4 04/13] accel/hvf: Remove pointless assertion, Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 05/13] accel/tcg: Init TCG cflags in vCPU thread handler, Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 06/13] accel/tcg: Reorganize tcg_accel_ops_init(), Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 07/13] accel-ops: Introduce create_vcpu_thread_precheck / postcheck handlers, Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 08/13] accel/tcg: Extract rr_create_vcpu_thread_precheck(), Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 09/13] accel/all: Extract common_vcpu_thread_create(), Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 10/13] accel-ops: Introduce common_vcpu_thread_destroy() and .precheck handler, Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 11/13] accel/tcg: Add rr_destroy_vcpu_thread_precheck(), Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 12/13] softmmu/cpus: Free cpu->thread in generic_destroy_vcpu_thread(), Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 13/13] softmmu/cpus: Free cpu->halt_cond in generic_destroy_vcpu_thread(), Philippe Mathieu-Daudé, 2022/03/23