[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
答复: [PATCH V8 6/8] physmem: Add helper function to destroy CPU AddressSp
From: |
zhukeqian |
Subject: |
答复: [PATCH V8 6/8] physmem: Add helper function to destroy CPU AddressSpace |
Date: |
Fri, 15 Mar 2024 01:16:39 +0000 |
Hi Salil,
[...]
+void cpu_address_space_destroy(CPUState *cpu, int asidx) {
+ CPUAddressSpace *cpuas;
+
+ assert(cpu->cpu_ases);
+ assert(asidx >= 0 && asidx < cpu->num_ases);
+ /* KVM cannot currently support multiple address spaces. */
+ assert(asidx == 0 || !kvm_enabled());
+
+ cpuas = &cpu->cpu_ases[asidx];
+ if (tcg_enabled()) {
+ memory_listener_unregister(&cpuas->tcg_as_listener);
+ }
+
+ address_space_destroy(cpuas->as);
+ g_free_rcu(cpuas->as, rcu);
In address_space_destroy(), it calls call_rcu1() on cpuas->as which will set
do_address_space_destroy() as the rcu func.
And g_free_rcu() also calls call_rcu1() on cpuas->as which will overwrite the
rcu func as g_free().
Then I think the g_free() may be called twice in rcu thread, please verify that.
The source code of call_rcu1:
void call_rcu1(struct rcu_head *node, void (*func)(struct rcu_head *node))
{
node->func = func;
enqueue(node);
qatomic_inc(&rcu_call_count);
qemu_event_set(&rcu_call_ready_event);
}
Thanks,
Keqian
+
+ if (asidx == 0) {
+ /* reset the convenience alias for address space 0 */
+ cpu->as = NULL;
+ }
+
+ if (--cpu->cpu_ases_count == 0) {
+ g_free(cpu->cpu_ases);
+ cpu->cpu_ases = NULL;
+ }
+}
+
AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) {
/* Return the AddressSpace corresponding to the specified index */
--
2.34.1
- [PATCH V8 0/8] Add architecture agnostic code to support vCPU Hotplug, Salil Mehta, 2024/03/11
- [PATCH V8 1/8] accel/kvm: Extract common KVM vCPU {creation, parking} code, Salil Mehta, 2024/03/11
- [PATCH V8 2/8] hw/acpi: Move CPU ctrl-dev MMIO region len macro to common header file, Salil Mehta, 2024/03/11
- [PATCH V8 3/8] hw/acpi: Update ACPI GED framework to support vCPU Hotplug, Salil Mehta, 2024/03/11
- [PATCH V8 4/8] hw/acpi: Update GED _EVT method AML with CPU scan, Salil Mehta, 2024/03/11
- [PATCH V8 5/8] hw/acpi: Update CPUs AML with cpu-(ctrl)dev change, Salil Mehta, 2024/03/11
- [PATCH V8 6/8] physmem: Add helper function to destroy CPU AddressSpace, Salil Mehta, 2024/03/11
- 答复: [PATCH V8 6/8] physmem: Add helper function to destroy CPU AddressSpace,
zhukeqian <=
- [PATCH V8 7/8] gdbstub: Add helper function to unregister GDB register space, Salil Mehta, 2024/03/11
- [PATCH V8 8/8] docs/specs/acpi_hw_reduced_hotplug: Add the CPU Hotplug Event Bit, Salil Mehta, 2024/03/11
- Re: [PATCH V8 0/8] Add architecture agnostic code to support vCPU Hotplug, Michael S. Tsirkin, 2024/03/12