[PATCH v7 05/12] KVM/x86/vPMU: tweak kvm_pmu_get_msr

2019-07-07 Thread Wei Wang
This patch changes kvm_pmu_get_msr to get the msr_data struct, because The host_initiated field from the struct could be used by get_msr. This also makes this API be consistent with kvm_pmu_set_msr. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen --- arch/x86/kvm/pmu.c | 4

Re: [PATCH v1] KVM: x86: PMU Whitelist

2019-07-03 Thread Wei Wang
On 07/03/2019 01:46 AM, Eric Hankland wrote: Sounds good to me. If you don't have any more comments I'll send out the next version with all the requested changes. No more so far. I'll see your new version. Best, Wei

Re: [PATCH v1] KVM: x86: PMU Whitelist

2019-06-25 Thread Wei Wang
On 06/25/2019 08:32 AM, Eric Hankland wrote: Thanks for your feedback - I'll send out an updated version > incorporating your comments shortly (assuming you don't have more > after this). Actually I have another thing to discuss: probably we could consider to make this filter list white/black

Re: [PATCH v1] KVM: x86: PMU Whitelist

2019-06-14 Thread Wei Wang
On 05/23/2019 06:23 AM, Eric Hankland wrote: - Add a VCPU ioctl that can control which events the guest can monitor. Signed-off-by: ehankland --- Some events can provide a guest with information about other guests or the host (e.g. L3 cache stats); providing the capability to restrict access

Re: [PATCH v1] KVM: x86: PMU Whitelist

2019-06-14 Thread Wei Wang
On 06/14/2019 01:43 AM, Eric Hankland wrote: Since we aren't using QEMU, I don't have those patches ready yet, but I can work on them if you want to review them at the same time as this patch. The architectural events (minus the LLC events) are probably a reasonable starting point for the

[PATCH v6 09/12] perf/x86: save/restore LBR_SELECT on vCPU switching

2019-06-06 Thread Wei Wang
The vCPU lbr event relies on the host to save/restore all the lbr related MSRs. So add the LBR_SELECT save/restore to the related functions for the vCPU case. Signed-off-by: Wei Wang Cc: Peter Zijlstra Cc: Andi Kleen --- arch/x86/events/intel/lbr.c | 7 +++ arch/x86/events/perf_event.h

[PATCH v6 07/12] perf/x86: no counter allocation support

2019-06-06 Thread Wei Wang
of counter assignment. Signed-off-by: Wei Wang Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/events/core.c | 12 include/linux/perf_event.h | 13 + kernel/events/core.c | 37 + 3 files changed, 50 insertions(+), 12 deletions

[PATCH v6 10/12] KVM/x86/lbr: lazy save the guest lbr stack

2019-06-06 Thread Wei Wang
Kleen Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/include/asm/kvm_host.h | 2 + arch/x86/kvm/pmu.c | 6 ++ arch/x86/kvm/pmu.h | 2 + arch/x86/kvm/vmx/pmu_intel.c| 146 arch

[PATCH v6 08/12] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2019-06-06 Thread Wei Wang
) and finds it's non-zero, it simply returns. Signed-off-by: Like Xu Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/events/intel/lbr.c | 13 +++-- arch/x86/events/perf_event.h| 1 + arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/pmu.h

[PATCH v6 03/12] KVM/x86: KVM_CAP_X86_GUEST_LBR

2019-06-06 Thread Wei Wang
Introduce KVM_CAP_X86_GUEST_LBR to allow per-VM enabling of the guest lbr feature. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/x86.c | 14 ++ include/uapi/linux/kvm.h

[PATCH v6 11/12] KVM/x86: remove the common handling of the debugctl msr

2019-06-06 Thread Wei Wang
The debugctl msr is not completely identical on AMD and Intel CPUs, for example, FREEZE_LBRS_ON_PMI is supported by Intel CPUs only. Now, this msr is handled separatedly in svm.c and intel_pmu.c. So remove the common debugctl msr handling code in kvm_get/set_msr_common. Signed-off-by: Wei Wang

[PATCH v6 01/12] perf/x86: fix the variable type of the LBR MSRs

2019-06-06 Thread Wei Wang
The MSR variable type can be "unsigned int", which uses less memory than the longer unsigned long. The lbr nr won't be a negative number, so make it "unsigned int" as well. Suggested-by: Peter Zijlstra Signed-off-by: Wei Wang Cc: Peter Zijlstra Cc: Andi Kleen --- arch/x86

[PATCH v6 12/12] KVM/VMX/vPMU: support to report GLOBAL_STATUS_LBRS_FROZEN

2019-06-06 Thread Wei Wang
Arch v4 supports streamlined Freeze_LBR_on_PMI. According to the SDM, the LBR_FRZ bit is set to global status when debugctl.freeze_lbr_on_pmi has been set and a PMI is generated. The CTR_FRZ bit is set when debugctl.freeze_perfmon_on_pmi is set and a PMI is generated. Signed-off-by: Wei Wang Cc

[PATCH v6 00/12] Guest LBR Enabling

2019-06-06 Thread Wei Wang
nt without the need of a perf counter - Patch 12: set the GLOBAL_STATUS_COUNTERS_FROZEN bit when injecting a vPMI. previous: https://lkml.org/lkml/2019/2/14/210 Like Xu (1): KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack We

[PATCH v6 05/12] KVM/x86/vPMU: tweak kvm_pmu_get_msr

2019-06-06 Thread Wei Wang
This patch changes kvm_pmu_get_msr to get the msr_data struct, because The host_initiated field from the struct could be used by get_msr. This also makes this API be consistent with kvm_pmu_set_msr. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen --- arch/x86/kvm/pmu.c | 4

[PATCH v6 04/12] KVM/x86: intel_pmu_lbr_enable

2019-06-06 Thread Wei Wang
and guest see different lbr stack msr indices. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/kvm/cpuid.h | 8 +++ arch/x86/kvm/pmu.c | 8 +++ arch/x86/kvm/pmu.h | 2 + arch/x86/kvm/vmx/pmu_intel.c | 136

[PATCH v6 02/12] perf/x86: add a function to get the lbr stack

2019-06-06 Thread Wei Wang
for the guest. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/events/intel/lbr.c | 23 +++ arch/x86/include/asm/perf_event.h | 14 ++ 2 files changed, 37 insertions(+) diff --git a/arch/x86/events/intel/lbr.c b/arch/x86

[PATCH v6 06/12] KVM/x86: expose MSR_IA32_PERF_CAPABILITIES to the guest

2019-06-06 Thread Wei Wang
Bits [0, 5] of MSR_IA32_PERF_CAPABILITIES tell about the format of the addresses stored in the LBR stack. Expose those bits to the guest when the guest lbr feature is enabled. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen --- arch/x86/include/asm/perf_event.h | 2 ++ arch/x86/kvm

Re: [PATCH v1] KVM: x86: PMU Whitelist

2019-06-06 Thread Wei Wang
On 06/06/2019 05:35 AM, Eric Hankland wrote: Right - I'm aware there are other ways of detecting this - it's still a class of events that some people don't want to surface. I'll ask if there are any better examples. I asked and it sounds like we are treating all events as potentially insecure

Re: [PATCH v1] KVM: x86: PMU Whitelist

2019-06-03 Thread Wei Wang
On 06/04/2019 01:30 AM, Eric Hankland wrote: On Sat, Jun 1, 2019 at 3:50 AM Wei Wang wrote: My question is that have we proved that this indirect info leakage indeed happens? The spec states that the counter will count the related events generated by the logical CPU with AnyThread=0. I would

Re: [PATCH v1] KVM: x86: PMU Whitelist

2019-06-01 Thread Wei Wang
On 06/01/2019 03:59 AM, Eric Hankland wrote: With anythread=0, I'm not aware of any events that directly give info about other VMs, but monitoring events related to shared resources (e.g. LLC References and LLC Misses) could indirectly give you info about how heavily other users are using that

Re: [PATCH v1] KVM: x86: PMU Whitelist

2019-05-30 Thread Wei Wang
On 05/30/2019 01:11 AM, Eric Hankland wrote: On Wed, May 29, 2019 at 12:49 AM Wei Wang wrote: On 05/29/2019 02:14 AM, Eric Hankland wrote: On Mon, May 27, 2019 at 6:56 PM Wei Wang wrote: On 05/23/2019 06:23 AM, Eric Hankland wrote: - Add a VCPU ioctl that can control which events the guest

Re: [PATCH v1] KVM: x86: PMU Whitelist

2019-05-29 Thread Wei Wang
On 05/29/2019 02:14 AM, Eric Hankland wrote: On Mon, May 27, 2019 at 6:56 PM Wei Wang wrote: On 05/23/2019 06:23 AM, Eric Hankland wrote: - Add a VCPU ioctl that can control which events the guest can monitor. Signed-off-by: ehankland --- Some events can provide a guest with information

Re: [PATCH v1] KVM: x86: PMU Whitelist

2019-05-27 Thread Wei Wang
On 05/23/2019 06:23 AM, Eric Hankland wrote: - Add a VCPU ioctl that can control which events the guest can monitor. Signed-off-by: ehankland --- Some events can provide a guest with information about other guests or the host (e.g. L3 cache stats); providing the capability to restrict access

Re: [PATCH] thermal: core: skip update disabled thermal zones after suspend

2019-04-23 Thread Wei Wang
On Mon, Apr 22, 2019 at 11:15 PM Zhang Rui wrote: > > On 一, 2019-04-22 at 09:44 -0700, Wei Wang wrote: > > On Mon, Apr 22, 2019 at 2:03 AM Zhang Rui > > wrote: > > > > > > > > > On 二, 2019-04-16 at 10:07 -0700, Wei Wang wrote: > > > > &

Re: [PATCH] thermal: core: skip update disabled thermal zones after suspend

2019-04-22 Thread Wei Wang
On Mon, Apr 22, 2019 at 2:03 AM Zhang Rui wrote: > > On 二, 2019-04-16 at 10:07 -0700, Wei Wang wrote: > > It is unnecessary to update disabled thermal zones post suspend and > > sometimes leads error/warning in bad behaved thermal drivers. > > > a good catch, and in

[PATCH] thermal: core: skip update disabled thermal zones after suspend

2019-04-16 Thread Wei Wang
It is unnecessary to update disabled thermal zones post suspend and sometimes leads error/warning in bad behaved thermal drivers. Signed-off-by: Wei Wang --- drivers/thermal/thermal_core.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers

Re: [RFC] [PATCH v2 0/5] Intel Virtual PMU Optimization

2019-04-01 Thread Wei Wang
On 03/25/2019 03:19 PM, Peter Zijlstra wrote: On Mon, Mar 25, 2019 at 02:47:32PM +0800, Like Xu wrote: On 2019/3/24 1:28, Peter Zijlstra wrote: On Sat, Mar 23, 2019 at 10:18:03PM +0800, Like Xu wrote: === Brief description === This proposal for Intel vPMU is still committed to optimize the

Re: [RFC][Patch v8 0/7] KVM: Guest Free Page Hinting

2019-02-17 Thread Wei Wang
On 02/18/2019 10:36 AM, Wei Wang wrote: On 02/15/2019 05:41 PM, David Hildenbrand wrote: On 15.02.19 10:05, Wang, Wei W wrote: On Thursday, February 14, 2019 5:43 PM, David Hildenbrand wrote: Yes indeed, that is the important bit. They must not be put pack to the buddy before they have been

Re: [RFC][Patch v8 0/7] KVM: Guest Free Page Hinting

2019-02-17 Thread Wei Wang
On 02/15/2019 05:41 PM, David Hildenbrand wrote: On 15.02.19 10:05, Wang, Wei W wrote: On Thursday, February 14, 2019 5:43 PM, David Hildenbrand wrote: Yes indeed, that is the important bit. They must not be put pack to the buddy before they have been processed by the hypervisor. But as the

Re: [PATCH v5 12/12] KVM/VMX/vPMU: support to report GLOBAL_STATUS_LBRS_FROZEN

2019-02-17 Thread Wei Wang
On 02/15/2019 09:10 PM, Andi Kleen wrote: OK. The freeze bits need to be cleared by IA32_PERF_GLOBAL_STATUS_RESET, which seems not supported by the perf code yet (thus guest won't clear them). Would handle_irq_v4 also need to be changed to support that? In Arch Perfmon v4 it is cleared by

[PATCH v5 03/12] KVM/x86: KVM_CAP_X86_GUEST_LBR

2019-02-14 Thread Wei Wang
Introduce KVM_CAP_X86_GUEST_LBR to allow per-VM enabling of the guest lbr feature. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/x86.c | 15 +++ include/uapi/linux/kvm.h

[PATCH v5 02/12] perf/x86: add a function to get the lbr stack

2019-02-14 Thread Wei Wang
for the guest. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/events/intel/lbr.c | 23 +++ arch/x86/include/asm/perf_event.h | 14 ++ 2 files changed, 37 insertions(+) diff --git a/arch/x86/events/intel/lbr.c b/arch/x86

[PATCH v5 00/12] Guest LBR Enabling

2019-02-14 Thread Wei Wang
GLOBAL_STATUS_LBRS_FROZEN. previous: https://lkml.org/lkml/2018/12/26/82 Like Xu (1): KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack Wei Wang (11): perf/x86: fix the variable type of the LBR MSRs perf/x86: add a function to get the lbr stack KVM/x86: KVM_CAP_X86_GUEST_LBR KVM/x86

[PATCH v5 12/12] KVM/VMX/vPMU: support to report GLOBAL_STATUS_LBRS_FROZEN

2019-02-14 Thread Wei Wang
Arch v4 supports streamlined Freeze_LBR_on_PMI, so we set the GLOBAL_STATUS_LBRS_FROZEN bit when the guest reads the global status msr with freezing lbr in use. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen --- arch/x86/kvm/vmx/pmu_intel.c | 21 - 1 file changed

[PATCH v5 05/12] KVM/x86/vPMU: tweak kvm_pmu_get_msr

2019-02-14 Thread Wei Wang
This patch changes kvm_pmu_get_msr to get the msr_data struct, because The host_initiated field from the struct could be used by get_msr. This also makes this API be consistent with kvm_pmu_set_msr. Signed-off-by: Wei Wang --- arch/x86/kvm/pmu.c | 4 ++-- arch/x86/kvm/pmu.h

[PATCH v5 06/12] KVM/x86: expose MSR_IA32_PERF_CAPABILITIES to the guest

2019-02-14 Thread Wei Wang
Bits [0, 5] of MSR_IA32_PERF_CAPABILITIES tell about the format of the addresses stored in the LBR stack. Expose those bits to the guest when the guest lbr feature is enabled. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen --- arch/x86/include/asm/perf_event.h | 2 ++ arch/x86/kvm

[PATCH v5 08/12] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2019-02-14 Thread Wei Wang
s non-zero, it simply returns. Signed-off-by: Like Xu Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/events/intel/lbr.c | 12 ++-- arch/x86/events/perf_event.h| 1 + arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/pmu.h

[PATCH v5 07/12] perf/x86: no counter allocation support

2019-02-14 Thread Wei Wang
perf core that no counter is needed. Signed-off-by: Wei Wang --- arch/x86/events/core.c | 12 include/linux/perf_event.h | 5 + include/uapi/linux/perf_event.h | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/core.c b/arch/

[PATCH v5 04/12] KVM/x86: intel_pmu_lbr_enable

2019-02-14 Thread Wei Wang
and guest see different lbr stack msr indices. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/kvm/cpuid.h | 8 +++ arch/x86/kvm/pmu.c | 8 +++ arch/x86/kvm/pmu.h | 2 + arch/x86/kvm/vmx/pmu_intel.c | 136

[PATCH v5 09/12] perf/x86: save/restore LBR_SELECT on vCPU switching

2019-02-14 Thread Wei Wang
The vCPU lbr event relies on the host to save/restore all the lbr related MSRs. So add the LBR_SELECT save/restore to the related functions for the vCPU case. Signed-off-by: Wei Wang Cc: Peter Zijlstra Cc: Andi Kleen --- arch/x86/events/intel/lbr.c | 7 +++ arch/x86/events/perf_event.h

[PATCH v5 11/12] KVM/x86: remove the common handling of the debugctl msr

2019-02-14 Thread Wei Wang
The debugctl msr is not completely identical on AMD and Intel CPUs, for example, FREEZE_LBRS_ON_PMI is supported by Intel CPUs only. Now, this msr is handled separatedly in svm.c and intel_pmu.c. So remove the common debugctl msr handling code in kvm_get/set_msr_common. Signed-off-by: Wei Wang

[PATCH v5 10/12] KVM/x86/lbr: lazy save the guest lbr stack

2019-02-14 Thread Wei Wang
Kleen Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/include/asm/kvm_host.h | 2 + arch/x86/kvm/pmu.c | 6 ++ arch/x86/kvm/pmu.h | 2 + arch/x86/kvm/vmx/pmu_intel.c| 146 arch

[PATCH v5 01/12] perf/x86: fix the variable type of the LBR MSRs

2019-02-14 Thread Wei Wang
The MSR variable type can be "unsigned int", which uses less memory than the longer unsigned long. The lbr nr won't be a negative number, so make it "unsigned int" as well. Suggested-by: Peter Zijlstra Signed-off-by: Wei Wang Cc: Peter Zijlstra Cc: Andi Kleen --- arch/x86

Re: [PATCH v3 2/3] virtio-balloon: improve update_balloon_size_func

2019-01-14 Thread Wei Wang
On 01/15/2019 09:00 AM, Michael S. Tsirkin wrote: On Mon, Jan 07, 2019 at 03:01:05PM +0800, Wei Wang wrote: There is no need to update the balloon actual register when there is no ballooning request. This patch avoids update_balloon_size when diff is 0. Signed-off-by: Wei Wang Reviewed

Re: [virtio-dev] [PATCH 2/2] virtio: document virtio_config_ops restrictions

2019-01-14 Thread Wei Wang
/ + * @finalize_features are NOT safe to be called from an atomic + * context. * @get: read the value of a configuration field *vdev: the virtio_device *offset: the offset of the configuration field Reviewed-by: Wei Wang Best, Wei

Re: [PATCH 1/2] virtio: fix virtio_config_ops description

2019-01-14 Thread Wei Wang
); Ping. Any feedback on that patch? Reviewed-by: Wei Wang Best, Wei

Re: [PATCH v3 1/3] virtio-balloon: tweak config_changed implementation

2019-01-09 Thread Wei Wang
On 01/08/2019 04:46 PM, Christian Borntraeger wrote: On 08.01.2019 06:35, Wei Wang wrote: On 01/07/2019 09:49 PM, Christian Borntraeger wrote: On 07.01.2019 08:01, Wei Wang wrote: virtio-ccw has deadlock issues with reading the config space inside the interrupt context, so we tweak

Re: [PATCH v4 04/10] KVM/x86: intel_pmu_lbr_enable

2019-01-08 Thread Wei Wang
On 01/08/2019 10:08 PM, Liang, Kan wrote: On 1/8/2019 1:13 AM, Wei Wang wrote: On 01/07/2019 10:22 PM, Liang, Kan wrote: Thanks for sharing. I understand the point of maintaining those models at one place, but this factor-out doesn't seem very elegant to me, like below __intel_pmu_init

Re: [PATCH v4 05/10] KVM/x86: expose MSR_IA32_PERF_CAPABILITIES to the guest

2019-01-07 Thread Wei Wang
On 01/08/2019 02:48 AM, Jim Mattson wrote: On Mon, Jan 7, 2019 at 10:20 AM Andi Kleen wrote: The issue is compatibility. Prior to your change, reading this MSR from a VM would raise #GP. After your change, it won't. That means that if you have a VM migrating between hosts with kernel versions

Re: [PATCH v4 04/10] KVM/x86: intel_pmu_lbr_enable

2019-01-07 Thread Wei Wang
On 01/07/2019 10:22 PM, Liang, Kan wrote: Thanks for sharing. I understand the point of maintaining those models at one place, but this factor-out doesn't seem very elegant to me, like below __intel_pmu_init (int model, struct x86_pmu *x86_pmu) { ... switch (model) case INTEL_FAM6_NEHALEM:

Re: [PATCH v3 1/3] virtio-balloon: tweak config_changed implementation

2019-01-07 Thread Wei Wang
On 01/07/2019 09:49 PM, Christian Borntraeger wrote: On 07.01.2019 08:01, Wei Wang wrote: virtio-ccw has deadlock issues with reading the config space inside the interrupt context, so we tweak the virtballoon_changed implementation by moving the config read operations into the related

[PATCH v4 3/3] virtio_balloon: remove the unnecessary 0-initialization

2019-01-07 Thread Wei Wang
We've changed to kzalloc the vb struct, so no need to 0-initialize this field one more time. Signed-off-by: Wei Wang Reviewed-by: Cornelia Huck --- drivers/virtio/virtio_balloon.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio

[PATCH v4 0/3] virtio-balloon: tweak config_changed

2019-01-07 Thread Wei Wang
since vb is allocated via kzalloc. v1->v2 ChangeLog: - add config_read_bitmap to indicate to the workqueue callbacks about the necessity of reading the related config fields. Wei Wang (3): virtio-balloon: tweak config_changed implementation virtio-balloon: improve update_ballo

[PATCH v4 2/3] virtio-balloon: improve update_balloon_size_func

2019-01-07 Thread Wei Wang
There is no need to update the balloon actual register when there is no ballooning request. This patch avoids update_balloon_size when diff is 0. Signed-off-by: Wei Wang Reviewed-by: Cornelia Huck Reviewed-by: Halil Pasic Tested-by: Christian Borntraeger --- drivers/virtio/virtio_balloon.c

[PATCH v4 1/3] virtio-balloon: tweak config_changed implementation

2019-01-07 Thread Wei Wang
the related config fields that need to be read. The cmd_id_received is also renamed to cmd_id_received_cache, and the value should be obtained via virtio_balloon_cmd_id_received. Fixes: 86a559787e6f ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT") Reported-by: Christian Borntraeger Signed-o

Re: [PATCH v4 05/10] KVM/x86: expose MSR_IA32_PERF_CAPABILITIES to the guest

2019-01-07 Thread Wei Wang
On 01/03/2019 11:25 PM, Jim Mattson wrote: On Wed, Jan 2, 2019 at 11:55 PM Wei Wang wrote: Right, thanks. Probably better to change it to below: msr_info->data = 0; data = native_read_msr(MSR_IA32_PERF_CAPABILITIES); if (vcpu->kvm->arch.lbr_in_guest) msr_info->d

[PATCH v3 2/3] virtio-balloon: improve update_balloon_size_func

2019-01-06 Thread Wei Wang
There is no need to update the balloon actual register when there is no ballooning request. This patch avoids update_balloon_size when diff is 0. Signed-off-by: Wei Wang Reviewed-by: Cornelia Huck Reviewed-by: Halil Pasic --- drivers/virtio/virtio_balloon.c | 5 - 1 file changed, 4

[PATCH v3 3/3] virtio_balloon: remove the unnecessary 0-initialization

2019-01-06 Thread Wei Wang
We've changed to kzalloc the vb struct, so no need to 0-initialize this field one more time. Signed-off-by: Wei Wang --- drivers/virtio/virtio_balloon.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index e33dc8e..f19061b

[PATCH v3 1/3] virtio-balloon: tweak config_changed implementation

2019-01-06 Thread Wei Wang
the related config fields that need to be read. The cmd_id_received is also renamed to cmd_id_received_cache, and the value should be obtained via virtio_balloon_cmd_id_received. Reported-by: Christian Borntraeger Signed-off-by: Wei Wang Reviewed-by: Cornelia Huck Reviewed-by: Halil Pasic --- drivers

[PATCH v3 0/3] virtio-balloon: tweak config_changed

2019-01-06 Thread Wei Wang
indicate to the workqueue callbacks about the necessity of reading the related config fields. Wei Wang (3): virtio-balloon: tweak config_changed implementation virtio-balloon: improve update_balloon_size_func virtio_balloon: remove the unnecessary 0-initialization drivers/virtio/virtio_

Re: [PATCH v4 04/10] KVM/x86: intel_pmu_lbr_enable

2019-01-05 Thread Wei Wang
On 01/04/2019 11:57 PM, Liang, Kan wrote: On 1/4/2019 4:58 AM, Wei Wang wrote: On 01/03/2019 12:33 AM, Liang, Kan wrote: On 12/26/2018 4:25 AM, Wei Wang wrote: + +/* + * It could be possible that people have vcpus of old model run on + * physcal cpus of newer model

Re: [PATCH v4 04/10] KVM/x86: intel_pmu_lbr_enable

2019-01-04 Thread Wei Wang
On 01/03/2019 11:34 PM, Jim Mattson wrote: On Wed, Jan 2, 2019 at 11:16 PM Wei Wang wrote: On 01/03/2019 07:26 AM, Jim Mattson wrote: On Wed, Dec 26, 2018 at 2:01 AM Wei Wang wrote: The lbr stack is architecturally specific, for example, SKX has 32 lbr stack entries while HSW has 16 entries

Re: [PATCH v4 04/10] KVM/x86: intel_pmu_lbr_enable

2019-01-04 Thread Wei Wang
On 01/03/2019 12:33 AM, Liang, Kan wrote: On 12/26/2018 4:25 AM, Wei Wang wrote: + +/* + * It could be possible that people have vcpus of old model run on + * physcal cpus of newer model, for example a BDW guest on a SKX + * machine (but not possible to be the other way around

[PATCH v2 0/2] virtio-balloon: tweak config_changed

2019-01-03 Thread Wei Wang
out the necessity of reading the related config fields. Wei Wang (2): virtio-balloon: tweak config_changed implementation virtio-balloon: improve update_balloon_size_func drivers/virtio/virtio_balloon.c | 86 +++-- 1 file changed, 57 insertions(+),

[PATCH v2 1/2] virtio-balloon: tweak config_changed implementation

2019-01-03 Thread Wei Wang
the related config fields that need to be read. Reported-by: Christian Borntraeger Signed-off-by: Wei Wang --- drivers/virtio/virtio_balloon.c | 81 +++-- 1 file changed, 53 insertions(+), 28 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio

[PATCH v2 2/2] virtio-balloon: improve update_balloon_size_func

2019-01-03 Thread Wei Wang
There is no need to update the balloon actual register when there is no ballooning request. This patch avoids update_balloon_size when diff is 0. Signed-off-by: Wei Wang Reviewed-by: Cornelia Huck Reviewed-by: Halil Pasic --- drivers/virtio/virtio_balloon.c | 5 - 1 file changed, 4

Re: [virtio-dev] Re: [PATCH v1 1/2] virtio-balloon: tweak config_changed implementation

2019-01-03 Thread Wei Wang
On 01/04/2019 12:42 AM, Michael S. Tsirkin wrote: On Thu, Jan 03, 2019 at 01:31:01PM +0800, Wei Wang wrote: virtio-ccw has deadlock issues with reading config registers inside the interrupt context, so we tweak the virtballoon_changed implementation by moving the config read operations

Re: [PATCH v1 1/2] virtio-balloon: tweak config_changed implementation

2019-01-03 Thread Wei Wang
On 01/03/2019 05:40 PM, Cornelia Huck wrote: On Thu, 3 Jan 2019 13:31:01 +0800 Wei Wang wrote: virtio-ccw has deadlock issues with reading config registers inside the s/config registers/the config space/ ? Sounds good. interrupt context, so we tweak the virtballoon_changed

Re: [PATCH v4 05/10] KVM/x86: expose MSR_IA32_PERF_CAPABILITIES to the guest

2019-01-02 Thread Wei Wang
On 01/03/2019 07:40 AM, Jim Mattson wrote: On Wed, Dec 26, 2018 at 2:01 AM Wei Wang wrote: Bits [0, 5] of MSR_IA32_PERF_CAPABILITIES tell about the format of the addresses stored in the LBR stack. Expose those bits to the guest when the guest lbr feature is enabled. Signed-off-by: Wei Wang

Re: [PATCH v4 04/10] KVM/x86: intel_pmu_lbr_enable

2019-01-02 Thread Wei Wang
On 01/03/2019 07:26 AM, Jim Mattson wrote: On Wed, Dec 26, 2018 at 2:01 AM Wei Wang wrote: The lbr stack is architecturally specific, for example, SKX has 32 lbr stack entries while HSW has 16 entries, so a HSW guest running on a SKX machine may not get accurate perf results. Currently, we

Re: [PATCH v1 0/2] Virtio: fix some vq allocation issues

2019-01-02 Thread Wei Wang
On 12/28/2018 03:57 PM, Christian Borntraeger wrote: On 28.12.2018 03:26, Wei Wang wrote: Some vqs don't need to be allocated when the related feature bits are disabled. Callers notice the vq allocation layer by setting the related names[i] to be NULL. This patch series fixes the find_vqs

[PATCH v1 1/2] virtio-balloon: tweak config_changed implementation

2019-01-02 Thread Wei Wang
virtio-ccw has deadlock issues with reading config registers inside the interrupt context, so we tweak the virtballoon_changed implementation by moving the config read operations into the related workqueue contexts. Signed-off-by: Wei Wang --- drivers/virtio/virtio_balloon.c | 54

[PATCH v1 2/2] virtio-balloon: improve update_balloon_size_func

2019-01-02 Thread Wei Wang
There is no need to update the balloon actual register when there is no ballooning request. This patch avoids update_balloon_size when diff is 0. Signed-off-by: Wei Wang --- drivers/virtio/virtio_balloon.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/virtio

[PATCH v1 0/2] virtio-balloon: tweak config_changed

2019-01-02 Thread Wei Wang
Since virtio-ccw doesn't work with accessing to the config registers inside an interrupt context, this patch series avoids that issue by moving the config register accesses to the related workqueue contexts. Wei Wang (2): virtio-balloon: tweak config_changed implementation virtio-balloon

Re: [PATCH v37 0/3] Virtio-balloon: support free page reporting

2018-12-27 Thread Wei Wang
On 12/27/2018 08:17 PM, Christian Borntraeger wrote: On 27.12.2018 12:59, Christian Borntraeger wrote: On 27.12.2018 12:31, Christian Borntraeger wrote: This patch triggers random crashes in the guest kernel on s390 early during boot. No migration and no setting of the balloon is involved.

Re: [PATCH v4 10/10] KVM/x86/lbr: lazy save the guest lbr stack

2018-12-27 Thread Wei Wang
On 12/28/2018 04:51 AM, Andi Kleen wrote: Thanks. This looks a lot better than the earlier versions. Some more comments. On Wed, Dec 26, 2018 at 05:25:38PM +0800, Wei Wang wrote: When the vCPU is scheduled in: - if the lbr feature was used in the last vCPU time slice, set the lbr stack

Re: [PATCH v37 1/3] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT

2018-12-27 Thread Wei Wang
On 12/27/2018 08:03 PM, Christian Borntraeger wrote: On 27.08.2018 03:32, Wei Wang wrote: static int init_vqs(struct virtio_balloon *vb) { - struct virtqueue *vqs[3]; - vq_callback_t *callbacks[] = { balloon_ack, balloon_ack, stats_request }; - static const char * const

[PATCH v1 2/2] virtio: don't allocate vqs when names[i] = NULL

2018-12-27 Thread Wei Wang
Some vqs may not need to be allocated when their related feature bits are disabled. So callers may pass in such vqs with "names = NULL". Then we skip such vq allocations. Signed-off-by: Wei Wang --- drivers/misc/mic/vop/vop_main.c| 9 +++-- drivers/remoteproc/remotepro

[PATCH v1 0/2] Virtio: fix some vq allocation issues

2018-12-27 Thread Wei Wang
Some vqs don't need to be allocated when the related feature bits are disabled. Callers notice the vq allocation layer by setting the related names[i] to be NULL. This patch series fixes the find_vqs implementations to handle this case. Wei Wang (2): virtio_pci: use queue idx instead of array

[PATCH v1 1/2] virtio_pci: use queue idx instead of array idx to set up the vq

2018-12-27 Thread Wei Wang
to the 3rd queue on the device. So we use queue_idx as the queue index, which is increased only when the queue exists. Signed-off-by: Wei Wang --- drivers/virtio/virtio_pci_common.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/virtio/virtio_pci_common.c b/drivers

[PATCH v4 05/10] KVM/x86: expose MSR_IA32_PERF_CAPABILITIES to the guest

2018-12-26 Thread Wei Wang
Bits [0, 5] of MSR_IA32_PERF_CAPABILITIES tell about the format of the addresses stored in the LBR stack. Expose those bits to the guest when the guest lbr feature is enabled. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen --- arch/x86/include/asm/perf_event.h | 2 ++ arch/x86/kvm

[PATCH v4 10/10] KVM/x86/lbr: lazy save the guest lbr stack

2018-12-26 Thread Wei Wang
the stack through to the guest. Suggested-by: Andi Kleen Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/include/asm/kvm_host.h | 4 ++ arch/x86/kvm/pmu.h | 5 ++ arch/x86/kvm/vmx.c | 138

[PATCH v4 08/10] perf/x86: save/restore LBR_SELECT on vCPU switching

2018-12-26 Thread Wei Wang
The vCPU lbr event relies on the host to save/restore all the lbr related MSRs. So add the LBR_SELECT save/restore to the related functions for the vCPU case. Signed-off-by: Wei Wang Cc: Peter Zijlstra Cc: Andi Kleen --- arch/x86/events/intel/lbr.c | 7 +++ arch/x86/events/perf_event.h

[PATCH v4 02/10] perf/x86: add a function to get the lbr stack

2018-12-26 Thread Wei Wang
for the guest. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/events/intel/lbr.c | 23 +++ arch/x86/include/asm/perf_event.h | 14 ++ 2 files changed, 37 insertions(+) diff --git a/arch/x86/events/intel/lbr.c b/arch/x86

[PATCH v4 09/10] perf/x86: function to check lbr user callstack mode

2018-12-26 Thread Wei Wang
This patch adds a function to check if the lbr_sel value has the user callstack mode set. The related LBR_* macros are moved to the perf_event.h as well. Signed-off-by: Wei Wang Cc: Peter Zijlstra Cc: Andi Kleen --- arch/x86/events/intel/lbr.c | 38 --- arch

[PATCH v4 07/10] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2018-12-26 Thread Wei Wang
s non-zero, it simply returns. Signed-off-by: Like Xu Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/events/intel/lbr.c | 14 +++-- arch/x86/events/perf_event.h| 1 + arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/pmu.h

[PATCH v4 06/10] perf/x86: no counter allocation support

2018-12-26 Thread Wei Wang
perf core that no counter is needed. Signed-off-by: Wei Wang --- arch/x86/events/core.c | 12 include/linux/perf_event.h | 5 + include/uapi/linux/perf_event.h | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/core.c b/arch/

[PATCH v4 01/10] perf/x86: fix the variable type of the LBR MSRs

2018-12-26 Thread Wei Wang
The MSR variable type can be "unsigned int", which uses less memory than the longer unsigned long. The lbr nr won't be a negative number, so make it "unsigned int" as well. Suggested-by: Peter Zijlstra Signed-off-by: Wei Wang Cc: Peter Zijlstra Cc: Andi Kleen --- arch/x86

[PATCH v4 03/10] KVM/x86: KVM_CAP_X86_GUEST_LBR

2018-12-26 Thread Wei Wang
Introduce KVM_CAP_X86_GUEST_LBR to allow per-VM enabling of the guest lbr feature. Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/x86.c | 15 +++ include/uapi/linux/kvm.h

[PATCH v4 00/10] Guest LBR Enabling

2018-12-26 Thread Wei Wang
- Patch 10: in guest_access_lbr_msr, pass through the lbr stack only when it has been passed through (i.e. add the check !vcpu->arch.lbr_used). previous: https://lkml.org/lkml/2018/9/20/507 Like Xu (1): KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

[PATCH v4 04/10] KVM/x86: intel_pmu_lbr_enable

2018-12-26 Thread Wei Wang
-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen Cc: Peter Zijlstra --- arch/x86/kvm/cpuid.h | 8 arch/x86/kvm/pmu.c | 8 arch/x86/kvm/pmu.h | 2 + arch/x86/kvm/pmu_intel.c | 117 +++ arch/x86/kvm/x86.c | 3 +- 5

Re: virtio-balloon: VIRTIO_BALLOON_F_PAGE_POISON discussion

2018-11-07 Thread Wei Wang
On 11/08/2018 10:50 AM, Michael S. Tsirkin wrote: On Thu, Nov 08, 2018 at 10:49:20AM +0800, Wei Wang wrote: On 11/07/2018 11:27 PM, Michael S. Tsirkin wrote: + LKML On Wed, Nov 07, 2018 at 02:29:02PM +, Wang, Wei W wrote: Hi Michael, Thanks again for reviewing so many versions

Re: virtio-balloon: VIRTIO_BALLOON_F_PAGE_POISON discussion

2018-11-07 Thread Wei Wang
On 11/08/2018 10:50 AM, Michael S. Tsirkin wrote: On Thu, Nov 08, 2018 at 10:49:20AM +0800, Wei Wang wrote: On 11/07/2018 11:27 PM, Michael S. Tsirkin wrote: + LKML On Wed, Nov 07, 2018 at 02:29:02PM +, Wang, Wei W wrote: Hi Michael, Thanks again for reviewing so many versions

Re: virtio-balloon: VIRTIO_BALLOON_F_PAGE_POISON discussion

2018-11-07 Thread Wei Wang
On 11/07/2018 11:27 PM, Michael S. Tsirkin wrote: + LKML On Wed, Nov 07, 2018 at 02:29:02PM +, Wang, Wei W wrote: Hi Michael, Thanks again for reviewing so many versions of patches, and I learnt a lot from your comments. While I’m writing the virtio-balloon spec patches, I’m

Re: virtio-balloon: VIRTIO_BALLOON_F_PAGE_POISON discussion

2018-11-07 Thread Wei Wang
On 11/07/2018 11:27 PM, Michael S. Tsirkin wrote: + LKML On Wed, Nov 07, 2018 at 02:29:02PM +, Wang, Wei W wrote: Hi Michael, Thanks again for reviewing so many versions of patches, and I learnt a lot from your comments. While I’m writing the virtio-balloon spec patches, I’m

[PATCH] Thermal: do not clear passive state during system sleep

2018-11-07 Thread Wei Wang
From: Wei Wang commit ff140fea847e ("Thermal: handle thermal zone device properly during system sleep") added PM hook to call thermal zone reset during sleep. However reseting thermal zone will also clear the passive state and thus cancel the polling queue which leads the passive cool

[PATCH] Thermal: do not clear passive state during system sleep

2018-11-07 Thread Wei Wang
From: Wei Wang commit ff140fea847e ("Thermal: handle thermal zone device properly during system sleep") added PM hook to call thermal zone reset during sleep. However reseting thermal zone will also clear the passive state and thus cancel the polling queue which leads the passive cool

Re: [PATCH v1 1/8] perf/x86: add support to mask counters from host

2018-11-05 Thread Wei Wang
On 11/05/2018 05:34 PM, Peter Zijlstra wrote: On Fri, Nov 02, 2018 at 05:08:31PM +0800, Wei Wang wrote: On 11/01/2018 10:52 PM, Peter Zijlstra wrote: @@ -723,6 +724,9 @@ static void perf_sched_init(struct perf_sched *sched, struct event_constraint ** sched->max_weight= w

Re: [PATCH v1 1/8] perf/x86: add support to mask counters from host

2018-11-05 Thread Wei Wang
On 11/05/2018 05:34 PM, Peter Zijlstra wrote: On Fri, Nov 02, 2018 at 05:08:31PM +0800, Wei Wang wrote: On 11/01/2018 10:52 PM, Peter Zijlstra wrote: @@ -723,6 +724,9 @@ static void perf_sched_init(struct perf_sched *sched, struct event_constraint ** sched->max_weight= w

<    1   2   3   4   5   6   7   8   9   10   >