From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796146575; b=YpFVd1gOidITiaRwT4caUqcBHqWRExIc0ri7aDbFDcIS9yeyiQ1dEqNE1Ns5nUFgTE2x rUF8Phyv3ZkJ/NDuldoK0AB4jawiKnkDOVnA3mteybhJB3/5y0Vnzg0tEb2mNjD1jrSVl pQ6uf2K3X45AD+WI8ySbVrhx8+YkoRYVTj4+W3QlGCFH69WbTTL9KjWxeH/uBoznGsr6I lOyNAGZq6kTbJxnp9SvOP73nEA/9LKuCiIRmqrdWIHsZfNHkpwSjg5ZQNx/QC58f+onuo bgF9rH0GNeyRBvUHSLD+HaoZbwa7b/SMbglp4UjuneCOzhRyhiUoheoJVDnl6ov9kmQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796146575; h=DMARC-Filter:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=9gK+Ok6BT2T/Q3gKXWo3P2A37M51T8YkuXMPKmbEUNw=; b=q7t81pGqAofkEWyHGkfp01M53FkmuDD5er8QiBSG9o1565mvV/MgE6kEjOlIvYQELf3x Y7YEcXxLzziRvEJzFcxbmPv2L8yofr4JwSFJ2fdEmPQlntTp5ySVFgqGH7eMgdN9m5Tk0 tXvC+2CEvUm82Ho38Haug18o+MLBQ5a3C6ESoXWSLnbM8q58f1MeMDpnIW23YmIXknTp4 o84yp6BvO30fHshzHL/TAszf61tj78KzkGL03R4xjSsrwgBAyOxSjzMfseDuTr4jgHHF3 s2PFpufyk+fZrF26T9TwnnWthw31GrQyTI+Ep5+gPmv7tyScmlLVbmJM/zTtyeHUffQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=UAKLiMSa; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA800606A6A5 for ; Tue, 1 Dec 2026 17:36:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DA800606A6A5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=UAKLiMSa Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 21523339; Tue, 1 Dec 2026 09:36:10 -0800 (PST) Received: from raptor (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F1883F632; Tue, 1 Dec 2026 09:36:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796146572; bh=GZWdioGZHvgnXMlpfJa536Pvgodsynqiano8h1LSHbU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UAKLiMSaQqsDp+CLAIg4236COtVPMuIqYWc+WpI1XqXlwo4slVhdJWGpd9iZBpF5j mggs3VfX2G13XtWjDC/3lv3SAjgfAb2aVZ07RWmRFaOLf/wlXksNP+OyzYWUEyB4cW mRCsQVnqiey5S9zm+sK8fkUMlHiHhe8I9vsPgIDY= Date: Tue, 1 Dec 2026 17:36:05 +0000 From: Alexandru Elisei To: "Lorenzo Stoakes (ARM)" Cc: maz@kernel.org, oupton@kernel.org, fuad.tabba@linux.dev, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, will@kernel.org, mark.rutland@arm.com, linux-perf-users@vger.kernel.org, catalin.marinas@arm.com, james.clark@linaro.org Subject: Re: [RFC PATCH v7 13/28] KVM: arm64: Add SPE VCPU device attribute to set the SPE device Message-ID: References: <20260903160623.315525-1-alexandru.elisei@arm.com> <20260903160623.315525-14-alexandru.elisei@arm.com> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi, While I was refactoring the patch, I reconsidered some things, below. On Fri, Nov 27, 2026 at 03:10:28PM +0000, Alexandru Elisei wrote: > Hi Lorenzo, > > On Wed, Oct 28, 2026 at 01:11:54PM +0000, Lorenzo Stoakes (ARM) wrote: > > On Thu, Sep 03, 2026 at 05:06:08PM +0100, Alexandru Elisei wrote: > > > [..] > > > diff --git a/arch/arm64/include/asm/kvm_spe.h b/arch/arm64/include/asm/kvm_spe.h > > > index 8ded2d821bff..b8afb419c851 100644 > > > --- a/arch/arm64/include/asm/kvm_spe.h > > > +++ b/arch/arm64/include/asm/kvm_spe.h > > > @@ -11,6 +11,11 @@ struct kvm_vcpu; > > > struct kvm_device_attr; > > > > > > #ifdef CONFIG_KVM_ARM_SPE > > > +struct arm_spe_pmu; > > > +struct kvm_spe { > > > + struct arm_spe_pmu *spe_pmu; > > > > I feel like 'spe_pmu' as a name is pretty confusing as there is PMU as > > regards the perf driver thing, which SPE is implemented as, and also the > > general PMUv3 architecture :) > > > > Maybe the _pmu suffix makes sense then on the type (which has to be a > > performance monitoring unit driver), but could we replace '_pmu' with > > '_instance' in the field, etc. names? > > The driver that KVM depends on calls it a spe_pmu, and this comes directly from > the driver. I think the name is appropriate. I have settled on calling it spe_dev and started replacing all references to SPE 'instance' with 'device': that's what it is from the kernel's point of view, and the device lives under /sys/devices, where userspace interacts with it. > > > [..] > > > diff --git a/arch/arm64/kvm/spe.c b/arch/arm64/kvm/spe.c > > > index dd5f80318ba4..87fcdbbcbd67 100644 > > > --- a/arch/arm64/kvm/spe.c > > > +++ b/arch/arm64/kvm/spe.c > > > +static int kvm_spe_set_spe_id(struct kvm_vcpu *vcpu, int spe_id) > > > +{ > > > + struct kvm *kvm = vcpu->kvm; > > > + struct kvm_spe *kvm_spe = &kvm->arch.kvm_spe; > > > + struct arm_spe_pmu *existing_spe_pmu, *spe_pmu = NULL; > > > + struct spe_pmu_entry *entry; > > > + > > > + if (kvm_vm_has_ran_once(kvm)) > > > + return -EBUSY; > > > + > > > + guard(mutex)(&spe_pmus_lock); > > > + > > > + list_for_each_entry(entry, &spe_pmus, link) { > > > + if (entry->spe_pmu->pmu.type == spe_id) { > > > + spe_pmu = entry->spe_pmu; > > > + break; > > > + } > > > + } > > > + > > > + if (!spe_pmu) > > > + return -ENXIO; > > > + > > > + existing_spe_pmu = kvm_spe->spe_pmu; > > > + if (existing_spe_pmu) { > > > + if (existing_spe_pmu != spe_pmu) > > > + return -EINVAL; > > > + return 0; > > > + } > > > + > > > + if (!try_module_get(spe_pmu->pmu.module)) > > > + return -ENXIO; > > > + > > > + if (kvm_spe_update_supported_cpus(kvm, &spe_pmu->supported_cpus)) { > > > > You're ignoring the error here, better to do: > > I'm not ignoring the error, I am deliberately choosing to return -EINVAL to > userspace, as per the documentation, instead of propagating the error code from > the internal function. I reconsidered this, and documented -ENOMEM as a possible return return code for the ioctl. Thanks, Alex