From: Marc Zyngier <maz@kernel.org>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: Oliver Upton <oliver.upton@linux.dev>,
Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
devel@daynix.com
Subject: Re: [PATCH RFC] KVM: arm64: PMU: Use multiple host PMUs
Date: Thu, 20 Mar 2025 17:14:48 +0000 [thread overview]
Message-ID: <86cyebmxo7.wl-maz@kernel.org> (raw)
In-Reply-To: <ba9cd6d2-1ee5-478a-8102-42b4dac411ce@daynix.com>
On Thu, 20 Mar 2025 09:52:59 +0000,
Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
>
> On 2025/03/20 18:10, Marc Zyngier wrote:
> > On Thu, 20 Mar 2025 06:03:35 +0000,
> > Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
> >>
> >> On 2025/03/20 3:51, Oliver Upton wrote:
> >>> On Wed, Mar 19, 2025 at 06:38:38PM +0000, Marc Zyngier wrote:
> >>>> On Wed, 19 Mar 2025 11:51:21 +0000, Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
> >>>>> What about setting the flag automatically when a user fails to pin
> >>>>> vCPUs to CPUs that are covered by one PMU? There would be no change if
> >>>>> a user correctly pins vCPUs as it is. Otherwise, they will see a
> >>>>> correct feature set advertised to the guest and the cycle counter
> >>>>> working.
> >>>>
> >>>> How do you know that the affinity is "correct"? VCPU affinity can be
> >>>> changed at any time. I, for one, do not want my VMs to change
> >>>> behaviour because I let the vcpus bounce around as the scheduler sees
> >>>> fit.
> >>
> >> Checking the affinity when picking the default PMU; the vCPU affinity
> >> is the only thing that rules the choice of the default PMU even now.
> >>
> >> Perhaps we may model the API as follows: introduce another "composite"
> >> PMU that works on any core but only exposes the cycle counter. Robust
> >> VMMs will choose it or one of hardware PMUs with
> >> KVM_ARM_VCPU_PMU_V3_SET_PMU. KVM will choose the default PMU according
> >> to the vCPU affinity at the point of KVM_ARM_VCPU_INIT otherwise. If
> >> the affinity is covered by one hardware PMU, that PMU will be chosen
> >> as the default. The "composite" PMU will be the default otherwise.
> >
> > This makes no sense to me. A VCPU is always affine to a PMU, because
> > we do not support configurations where only some CPUs have a PMU. This
> > is an all-or-nothing situation.
>
> At least isn't it fine to have the composite PMU with a new value for
> KVM_ARM_VCPU_PMU_V3_SET_PMU?
Not sure KVM_ARM_VCPU_PMU_V3_SET_PMU is the right hook (it takes a PMU
'type', which is under control of the perf subsystem). But if we can
find a value that is guaranteed to be unique, why not.
> > More importantly, you keep suggesting the same "new default", and I
> > keep saying NO.
> >
> > My position is clear: if you want a *new* behaviour, you *must* add a
> > new flag that the VMM explicitly provides to enable this CC-only PMU.
> > No change in default behaviour at all.
> >
> > I'm not going to move from that.
>
> Why not? It will not break anything guaranteed to work in the past.
It doesn't have to be guaranteed. It just has to *exist*. That's the
Linux ABI for you.
> Currently KVM only guarantees that the emulated PMU correctly counts
> only when
> 1) the vCPU affinity is contained by one PMU and
> 2) it will not expand
>
> Breaking these conditions will make the behavior of the emulated PMU
> undefined. Now I'm proposing to remove 1).
And I'm saying no to that. I'm also getting tired of arguing the same
point on and on.
We currently have two different behaviours:
- either you explicitly set a PMU, and the affinity of this PMU
constraints the affinity of the vcpus. The vcpus are not allowed to
run outside of this affinity. Everything counts all the time.
- or you don't explicitly set a PMU, and a default PMU will be picked
from the current affinity of the first vcpu. Your vcpus will be able
to run anywhere, but the virtual PMU will *only* count when the
vcpus are affine to the default PMU. When the vcpus are not affine
to default PMU, *nothing* counts.
These two behaviours are ABI. They are not changing. They don't get
relaxed, they don't get tightened, they stay just as they are,
forever.
You want a *third* behaviour, go ahead. Define it the way you want.
But the behaviours described above will stay unchanged.
I'm looking forward to your patches implementing it, but I am also
done arguing on it.
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2025-03-20 17:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 6:33 [PATCH RFC] KVM: arm64: PMU: Use multiple host PMUs Akihiko Odaki
2025-03-19 7:34 ` Oliver Upton
2025-03-19 8:37 ` Akihiko Odaki
2025-03-19 9:47 ` Marc Zyngier
2025-03-19 10:26 ` Akihiko Odaki
2025-03-19 11:07 ` Marc Zyngier
2025-03-19 11:26 ` Akihiko Odaki
2025-03-19 11:41 ` Marc Zyngier
2025-03-19 11:51 ` Akihiko Odaki
2025-03-19 18:38 ` Marc Zyngier
2025-03-19 18:51 ` Oliver Upton
2025-03-20 6:03 ` Akihiko Odaki
2025-03-20 9:10 ` Marc Zyngier
2025-03-20 9:52 ` Akihiko Odaki
2025-03-20 17:14 ` Marc Zyngier [this message]
2025-03-21 6:20 ` Akihiko Odaki
2025-03-21 10:59 ` Marc Zyngier
2025-03-20 9:19 ` Marc Zyngier
2025-03-20 17:44 ` Oliver Upton
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=86cyebmxo7.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=akihiko.odaki@daynix.com \
--cc=catalin.marinas@arm.com \
--cc=devel@daynix.com \
--cc=gustavoars@kernel.org \
--cc=joey.gouly@arm.com \
--cc=kees@kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oliver.upton@linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.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.