From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EC15187FEC; Wed, 19 Mar 2025 18:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742409522; cv=none; b=slexWZiyV//ERwbEAxJVlP6kKClH7Whb4JnLcNtolr2g1PuHYk5UJtYwfqT0Jnj/TYAFaKVliFOSFX5PwHk2FHQwcLs/lq8gGZQEw0DGywlFWVojiJZ+Yuafg0gfwimo3eXBLZ6OX4Dh82AHYIgO28SsDsXEIELW68sfXomu9AY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742409522; c=relaxed/simple; bh=xxc1VsGnvFXqzw9zxTVKLq0ZNRg09z107d4U6coGVOE=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=eEvyJQTH8VPoUAWSTXnEO5HnImD0Iniarq1AsFNC0ILtiV7G0PgK+ODWd9lqqhQY8en8mzeg9o6TkCjL4hj6o1d/bnTpbYCCdbIUh4mDQJ61FQwrNo5spIoHZ1SNaUhogiijEf0+/lX1JL004S1w5MMcEyio2Nee2vljvu1b96M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cP/s+lF8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cP/s+lF8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B2F4C4CEE4; Wed, 19 Mar 2025 18:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742409521; bh=xxc1VsGnvFXqzw9zxTVKLq0ZNRg09z107d4U6coGVOE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cP/s+lF8HISnXacs9ZPUuzigjGTgQ1p+XwdHZHgTAzH9gt3CJUABlgR426eWV4Yw7 KJKH+LG8vUAJzLDYQwCrwRVFrTKjKN/JEcKYuQc8QXtvu7+VOIt72ic+2ePQk/LDr+ dm9AyCDaRdkqQ9AGemNrE/VEawK3KZP+cePFOGWAj7X7eHUhDJtggVFg4Qzy032X4C pzVMtAtk/EOpX/RWukuuvzZt3LCXbpRrcbd9lN5PfqxIuoLTdFG6tAGSWcG7gTkyCA e/DAavfGqxgVV1Jxx49/u0qrgU/izRFICLPc5KCtRq9DE5SSF1lDrqBUYFVQYPjiIK Yd+Rj4Zu08Dww== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tuyJL-00FBqr-6X; Wed, 19 Mar 2025 18:38:39 +0000 Date: Wed, 19 Mar 2025 18:38:38 +0000 Message-ID: <86ldt0n9w1.wl-maz@kernel.org> From: Marc Zyngier To: Akihiko Odaki Cc: Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Kees Cook , "Gustavo A. R. Silva" , 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 In-Reply-To: References: <20250319-hybrid-v1-1-4d1ada10e705@daynix.com> <86plidmjwh.wl-maz@kernel.org> <86o6xxmg87.wl-maz@kernel.org> <86msdhmemw.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: akihiko.odaki@daynix.com, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, kees@kernel.org, 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 X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Wed, 19 Mar 2025 11:51:21 +0000, Akihiko Odaki wrote: > > On 2025/03/19 20:41, Marc Zyngier wrote: > > On Wed, 19 Mar 2025 11:26:18 +0000, > > Akihiko Odaki wrote: > >> > >> On 2025/03/19 20:07, Marc Zyngier wrote: > >>> On Wed, 19 Mar 2025 10:26:57 +0000, > >>>> > >>> But that'd be a new ABI, which again would require buy-in from > >>> userspace. Maybe there is scope for an all CPUs, cycle-counter only > >>> PMUv3 exposed to the guest, but that cannot be set automatically, as > >>> we would otherwise regress existing setups. > >>> > >>> At this stage, and given that you need to change userspace, I'm not > >>> sure what the best course of action is. > >> > >> Having an explicit flag for the userspace is fine for QEMU, which I > >> care. It can flip the flag if and only if threads are not pinned to > >> one PMU and the machine is a new setup. > >> > >> I also wonder what regression you think setting it automatically causes. > > > > The current behaviour is that if you don't specify anything other than > > creating a PMUv3 (without KVM_ARM_VCPU_PMU_V3_SET_PMU), you get *some* > > PMU, and userspace is responsible for running the vcpu on CPUs that > > will implement that PMU. When if does, all the counters, all the > > events are valid. If it doesn't, nothing counts, but the > > counters/events are still valid. > > > > If you now add this flag automatically, the guest doesn't see the full > > PMU anymore. Only the cycle counter. That's the regression. > > 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. Honestly, this is not a can of worm I want to open. We already have a pretty terrible userspace API for the PMU, let's not add to the confusion. *If* we are going down the road of presenting a dumbed-down PMU to the guest, it has to be an explicit buy-in from userspace. M. -- Without deviation from the norm, progress is not possible.