From: Like Xu <like.xu.linux@gmail.com>
To: Xiong Zhang <xiong.y.zhang@intel.com>,
Sean Christopherson <seanjc@google.com>
Cc: pbonzini@redhat.com, peterz@infradead.org,
kan.liang@linux.intel.com, zhenyuw@linux.intel.com,
zhiyuan.lv@intel.com, kvm list <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/4] perf/x86/intel: Get shared reg constraints first for vLBR
Date: Wed, 28 Jun 2023 12:25:16 +0800 [thread overview]
Message-ID: <ca71fc1f-280e-19ff-ce0f-8befa29f45cd@gmail.com> (raw)
In-Reply-To: <20230616113353.45202-2-xiong.y.zhang@intel.com>
On 16/6/2023 7:33 pm, Xiong Zhang wrote:
> When host has per cpu pinned LBR event and guest use LBR also, host
> couldn't get correct LBR data, as the physical LBR is preempted by
> guest.
>
> The rule for multi events sharing LBR is defined in
> __intel_shared_reg_get_constraints(), but guest vLBR event skips this
> function, so even if host has per cpu pinned LBR event, guest vLBR event
> could get constraints successfully and make vlbr_exclude_host returns true,
> finally host couldn't enable LBR in intel_pmu_lbr_enable_all().
Although it goes against the "per cpu pinned LBR event" priority expectation,
the order is intentionally specified. For two reasons:
- vlbr uses the fake event mechanism in its implementation, a presence similar to
BTS event, thus the question here is whether we can get the per cpu pinned BTS
event to work as expected;
- this change should not be applied first before KVM has done a good job
of making guest lbr and other lbr events coexist correctly;
In treating vlbr event as an ordinary perf_event behind a guest counter that
is expected to comply equally with the scheduling rules of host perf, the first
thing we need to address is how a guest counter should continue to function
during the time when the backend event is preempted by a higher priority one.
>
> This commit move intel_vlbr_constraints() behind
> intel_shared_regs_constraints(), guest vLBR event will use LBR also and it
> should get LBR resource through intel_shared_regs_constraints().
>
> Fixes: 097e4311cda9 ("perf/x86: Add constraint to create guest LBR event without hw counter")
> Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
> ---
> arch/x86/events/intel/core.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
> index 6fd3cd97a6ac..2e27a69e9725 100644
> --- a/arch/x86/events/intel/core.c
> +++ b/arch/x86/events/intel/core.c
> @@ -3347,15 +3347,15 @@ __intel_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
> {
> struct event_constraint *c;
>
> - c = intel_vlbr_constraints(event);
> + c = intel_bts_constraints(event);
> if (c)
> return c;
>
> - c = intel_bts_constraints(event);
> + c = intel_shared_regs_constraints(cpuc, event);
> if (c)
> return c;
>
> - c = intel_shared_regs_constraints(cpuc, event);
> + c = intel_vlbr_constraints(event);
> if (c)
> return c;
>
next prev parent reply other threads:[~2023-06-28 8:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-16 11:33 [PATCH 0/4] Part of fix for host and guest LBR event coexist Xiong Zhang
2023-06-16 11:33 ` [PATCH 1/4] perf/x86/intel: Get shared reg constraints first for vLBR Xiong Zhang
2023-06-28 4:25 ` Like Xu [this message]
2023-06-29 2:11 ` Zhang, Xiong Y
2023-06-16 11:33 ` [PATCH 2/4] KVM: VMX/pmu: Save host debugctlmsr just before vm entry Xiong Zhang
2023-06-23 20:15 ` Sean Christopherson
2023-06-25 4:03 ` Zhang, Xiong Y
2023-06-28 5:37 ` Like Xu
2023-06-16 11:33 ` [PATCH 3/4] KVM: VMX/pmu: Enable inactive vLBR event in guest LBR MSR emulation Xiong Zhang
2023-06-23 20:38 ` Sean Christopherson
2023-06-25 6:54 ` Zhang, Xiong Y
2023-06-26 17:00 ` Sean Christopherson
2023-06-27 3:29 ` Zhang, Xiong Y
2023-06-27 15:07 ` Sean Christopherson
2023-06-28 6:07 ` Like Xu
2023-06-28 5:50 ` Like Xu
2023-06-16 11:33 ` [PATCH 4/4] KVM: selftests: Add test case for guest and host LBR preemption Xiong Zhang
2023-06-28 6:27 ` Like Xu
2023-06-29 2:39 ` Zhang, Xiong Y
2023-06-28 9:27 ` Yang, Weijiang
2023-06-29 2:52 ` Zhang, Xiong Y
2023-06-30 2:05 ` Yang, Weijiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ca71fc1f-280e-19ff-ce0f-8befa29f45cd@gmail.com \
--to=like.xu.linux@gmail.com \
--cc=kan.liang@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=xiong.y.zhang@intel.com \
--cc=zhenyuw@linux.intel.com \
--cc=zhiyuan.lv@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.