accel/tcg: Replace g_new() + memcpy() by g_memdup()
Using g_memdup is a bit more compact than g_new + memcpy. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 20210509151618.2331764-2-f4bug@amsat.org Message-Id: <20210508201640.1045808-1-richard.henderson@linaro.org> [PMD: Split from bigger patch] Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
659f042ba8
commit
6d24478861
@ -837,11 +837,8 @@ void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, target_ulong addr,
|
|||||||
} else if (encode_pbm_to_runon(&runon, d)) {
|
} else if (encode_pbm_to_runon(&runon, d)) {
|
||||||
async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon);
|
async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon);
|
||||||
} else {
|
} else {
|
||||||
TLBFlushPageBitsByMMUIdxData *p
|
|
||||||
= g_new(TLBFlushPageBitsByMMUIdxData, 1);
|
|
||||||
|
|
||||||
/* Otherwise allocate a structure, freed by the worker. */
|
/* Otherwise allocate a structure, freed by the worker. */
|
||||||
*p = d;
|
TLBFlushPageBitsByMMUIdxData *p = g_memdup(&d, sizeof(d));
|
||||||
async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_2,
|
async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_2,
|
||||||
RUN_ON_CPU_HOST_PTR(p));
|
RUN_ON_CPU_HOST_PTR(p));
|
||||||
}
|
}
|
||||||
@ -875,13 +872,11 @@ void tlb_flush_page_bits_by_mmuidx_all_cpus(CPUState *src_cpu,
|
|||||||
flush_all_helper(src_cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon);
|
flush_all_helper(src_cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon);
|
||||||
} else {
|
} else {
|
||||||
CPUState *dst_cpu;
|
CPUState *dst_cpu;
|
||||||
TLBFlushPageBitsByMMUIdxData *p;
|
|
||||||
|
|
||||||
/* Allocate a separate data block for each destination cpu. */
|
/* Allocate a separate data block for each destination cpu. */
|
||||||
CPU_FOREACH(dst_cpu) {
|
CPU_FOREACH(dst_cpu) {
|
||||||
if (dst_cpu != src_cpu) {
|
if (dst_cpu != src_cpu) {
|
||||||
p = g_new(TLBFlushPageBitsByMMUIdxData, 1);
|
TLBFlushPageBitsByMMUIdxData *p = g_memdup(&d, sizeof(d));
|
||||||
*p = d;
|
|
||||||
async_run_on_cpu(dst_cpu,
|
async_run_on_cpu(dst_cpu,
|
||||||
tlb_flush_page_bits_by_mmuidx_async_2,
|
tlb_flush_page_bits_by_mmuidx_async_2,
|
||||||
RUN_ON_CPU_HOST_PTR(p));
|
RUN_ON_CPU_HOST_PTR(p));
|
||||||
@ -927,15 +922,13 @@ void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu,
|
|||||||
/* Allocate a separate data block for each destination cpu. */
|
/* Allocate a separate data block for each destination cpu. */
|
||||||
CPU_FOREACH(dst_cpu) {
|
CPU_FOREACH(dst_cpu) {
|
||||||
if (dst_cpu != src_cpu) {
|
if (dst_cpu != src_cpu) {
|
||||||
p = g_new(TLBFlushPageBitsByMMUIdxData, 1);
|
p = g_memdup(&d, sizeof(d));
|
||||||
*p = d;
|
|
||||||
async_run_on_cpu(dst_cpu, tlb_flush_page_bits_by_mmuidx_async_2,
|
async_run_on_cpu(dst_cpu, tlb_flush_page_bits_by_mmuidx_async_2,
|
||||||
RUN_ON_CPU_HOST_PTR(p));
|
RUN_ON_CPU_HOST_PTR(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p = g_new(TLBFlushPageBitsByMMUIdxData, 1);
|
p = g_memdup(&d, sizeof(d));
|
||||||
*p = d;
|
|
||||||
async_safe_run_on_cpu(src_cpu, tlb_flush_page_bits_by_mmuidx_async_2,
|
async_safe_run_on_cpu(src_cpu, tlb_flush_page_bits_by_mmuidx_async_2,
|
||||||
RUN_ON_CPU_HOST_PTR(p));
|
RUN_ON_CPU_HOST_PTR(p));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user