unicorn/qemu/target-i386
Longpeng(Mike) 8b5400d675
target-i386: present virtual L3 cache info for vcpus
Some software algorithms are based on the hardware's cache info, for example,
for x86 linux kernel, when cpu1 want to wakeup a task on cpu2, cpu1 will trigger
a resched IPI and told cpu2 to do the wakeup if they don't share low level
cache. Oppositely, cpu1 will access cpu2's runqueue directly if they share llc.
The relevant linux-kernel code as bellow:

static void ttwu_queue(struct task_struct *p, int cpu)
{
struct rq *rq = cpu_rq(cpu);
......
if (... && !cpus_share_cache(smp_processor_id(), cpu)) {
......
ttwu_queue_remote(p, cpu); /* will trigger RES IPI */
return;
}
......
ttwu_do_activate(rq, p, 0); /* access target's rq directly */
......
}

In real hardware, the cpus on the same socket share L3 cache, so one won't
trigger a resched IPIs when wakeup a task on others. But QEMU doesn't present a
virtual L3 cache info for VM, then the linux guest will trigger lots of RES IPIs
under some workloads even if the virtual cpus belongs to the same virtual socket.

For KVM, there will be lots of vmexit due to guest send IPIs.
The workload is a SAP HANA's testsuite, we run it one round(about 40 minuates)
and observe the (Suse11sp3)Guest's amounts of RES IPIs which triggering during
the period:
No-L3 With-L3(applied this patch)
cpu0:	363890	44582
cpu1:	373405	43109
cpu2:	340783	43797
cpu3:	333854	43409
cpu4:	327170	40038
cpu5:	325491	39922
cpu6:	319129	42391
cpu7:	306480	41035
cpu8:	161139	32188
cpu9:	164649	31024
cpu10:	149823	30398
cpu11:	149823	32455
cpu12:	164830	35143
cpu13:	172269	35805
cpu14:	179979	33898
cpu15:	194505	32754
avg:	268963.6	40129.8

The VM's topology is "1*socket 8*cores 2*threads".
After present virtual L3 cache info for VM, the amounts of RES IPIs in guest
reduce 85%.

For KVM, vcpus send IPIs will cause vmexit which is expensive, so it can cause
severe performance degradation. We had tested the overall system performance if
vcpus actually run on sparate physical socket. With L3 cache, the performance
improves 7.2%~33.1%(avg:15.7%).

Backports commit 14c985cffa6cb177fc01a163d8bcf227c104718c from qemu
2018-02-25 23:16:14 -05:00
..
arch_memory_mapping.c x86: Clean up includes 2018-02-19 01:00:09 -05:00
bpt_helper.c cpu-exec: Rename cpu_resume_from_signal() to cpu_loop_exit_noexc() 2018-02-24 17:25:28 -05:00
cc_helper_template.h This code should now build the x86_x64-softmmu part 2. 2017-01-19 22:50:28 +11:00
cc_helper.c target-i386: Perform set/reset_inhibit_irq inline 2018-02-20 13:34:47 -05:00
cpu-qom.h target-i386: make cpu-qom.h not target specific 2018-02-24 00:55:22 -05:00
cpu.c target-i386: present virtual L3 cache info for vcpus 2018-02-25 23:16:14 -05:00
cpu.h target-i386: present virtual L3 cache info for vcpus 2018-02-25 23:16:14 -05:00
excp_helper.c cpu: move exec-all.h inclusion out of cpu.h 2018-02-24 02:39:08 -05:00
fpu_helper.c cpu: move exec-all.h inclusion out of cpu.h 2018-02-24 02:39:08 -05:00
helper.c target-i386: Move user-mode exception actions out of user-exec.c 2018-02-24 17:27:08 -05:00
helper.h target-i386: implement PKE for TCG 2018-02-22 10:18:55 -05:00
int_helper.c cpu: move exec-all.h inclusion out of cpu.h 2018-02-24 02:39:08 -05:00
Makefile.objs target-i386: Enable control registers for MPX 2018-02-20 13:27:46 -05:00
mem_helper.c Fix confusing argument names in some common functions 2018-02-25 03:58:27 -05:00
misc_helper.c cpu: move exec-all.h inclusion out of cpu.h 2018-02-24 02:39:08 -05:00
mpx_helper.c cpu: move exec-all.h inclusion out of cpu.h 2018-02-24 02:39:08 -05:00
ops_sse_header.h target-i386: Rename struct XMMReg to ZMMReg 2018-02-18 23:46:30 -05:00
ops_sse.h target-i386: Rename XMM_[BWLSDQ] helpers to ZMM_* 2018-02-18 23:53:16 -05:00
seg_helper.c target-i386: Add comment about do_interrupt_user() next_eip argument 2018-02-24 17:26:18 -05:00
shift_helper_template.h This code should now build the x86_x64-softmmu part 2. 2017-01-19 22:50:28 +11:00
smm_helper.c target-i386: Include log.h in smm_helper 2018-02-24 03:06:07 -05:00
svm_helper.c cpu: move exec-all.h inclusion out of cpu.h 2018-02-24 02:39:08 -05:00
svm.h Clean up ill-advised or unusual header guards 2018-02-25 04:22:46 -05:00
TODO
topology.h pc: Add x86_topo_ids_from_apicid() 2018-02-25 20:31:36 -05:00
translate.c tcg: Reorg TCGOp chaining 2018-02-25 21:44:50 -05:00
unicorn.c qemu-common: push cpu.h inclusion out of qemu-common.h 2018-02-24 01:50:56 -05:00
unicorn.h