Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp662504rdh; Wed, 14 Feb 2024 07:57:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWCsC5ZF1WzuvWTUSO8jfB4k0jrRuqrMls3VDm/pXGAthObpJoM+IDuaELgrPZmfk0yx/s13ofcK0qBsy+cY/F2GjTbrf84vBG8bYeqBg== X-Google-Smtp-Source: AGHT+IGf9MONDbmobgRjWAOeJA4GQKhMgSPQqermZ3kUa60J9ve0QKm8BD1secFA+oEKGGmyE5ur X-Received: by 2002:a1f:ea83:0:b0:4c0:2d32:612f with SMTP id i125-20020a1fea83000000b004c02d32612fmr2565151vkh.15.1707926250820; Wed, 14 Feb 2024 07:57:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707926250; cv=pass; d=google.com; s=arc-20160816; b=qJwunlqmksS48TnvhIJ+YzG7Fte7pxVdE6kaNXkhWbxD5aVUDthj8v3eV3Iezh+AWd Eh+Tn6w4+pkVNW0u5KMYG17kQX3Qe0sk7gpa5l93AgGSlB66bUbTq2lj265UXFkcvAqi eshIPeXgwKGtGkcfWSuqK/wZespdKNUFYCrPnhWy/rphzhoKj6bQLqpxr5UoWmeH2GTg hDbLnk4D3jTL9EtpfI61xG9S+aTTlJCxF3eb7rMpk/UT7ScHafoE/Six5x7ifod4mtAk POlGmvvhSel4YucBXk4yzfVX1sDupEuNevByzx8URFlxL2ELqS6sUa3KnoUs+D4eMc78 76WQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=mdc1M0ewAJZGGc63Rte7qW6kmgzfOG2LAcdJKazcEZs=; fh=419uGCyIZbGZ/fAs73r9ZrPxjVSIRhpv9JUiuO7i6p4=; b=Dd1FQPhBNoEh6/AHAoTW9D7xOon8q3Phtzmpi0W35Sttw0cpxI7xaa3XXyzetinpHY 7sVEt2Ys7xPJAjqlA/Kp4cq8tmrqVffWdGm1Qsu/bHuU4DBLETgxTVs9bC4dgZBq78d9 LRrzBH+G17tLYjagzVUQvZ1wzhtpM6UkELMfChpbXs9kU2zBlXE/dJ6p+yTK4oFxEvc2 EGuCrKe86klTcXezcE8DvbIbKbnNS7iMbdTKQumjHtd1D4jlrf0Ykq+s1HfrkyZ5n386 KusC7Dwb45L76y8h4qX3BkQTRiqUJF3sxAzemWowTygi+pj4m7OYtXgtmFOOR7VeJFl4 to/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PDRU0t6i; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65467-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65467-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUKWp/T/9QxHa8bvs9BIV5hdqv3zO8Bg2OuAT7bqtEkmc8+ud/7onMistMkg74e+CBYkxbukK0jQYdVANaM5NVY9HNZ8xGv+CnD+/Huhw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id kk19-20020a056214509300b0068eda269640si4661705qvb.448.2024.02.14.07.57.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 07:57:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65467-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PDRU0t6i; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65467-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65467-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A5A031C28E9F for ; Wed, 14 Feb 2024 15:55:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F1425F48C; Wed, 14 Feb 2024 15:55:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PDRU0t6i" 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 92F225B5DB; Wed, 14 Feb 2024 15:55:37 +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=1707926137; cv=none; b=VFw7sMwUku4NU0Z/84X5AGgNbDTs+0ol1bxaZGe9VniBHnehB6fmgzV/iE55Z1flcyyBHBzTAyXMxOO4rF4fQKWHsNgr4Z1OSNEFeVT37zNYI+PfUbqXlWyqW9MIZwtOD8TrYbjihqXat4krFRb7e4mbyDjoBwJkSFqdqqy9zQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707926137; c=relaxed/simple; bh=3nBeVvDzPWSYkBUuAMGRboAigFEsz79F7jZ+9eTr11k=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=KFKJ17cZAaVM/gTWUOBPLe8fPwmNe2kfmgL9JWoOPgDYk3lPUFxz43YOJUe7rzUr0dtlQabeArETjW+aImSsWqdnXSr9bQYBDeXac49v50gjwQDiHDyshkq/mNoJW8HfIYS16kPbIvaUN2qUl2ebtTw5klRC6CYv0USAC0qL0gA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PDRU0t6i; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E806C433C7; Wed, 14 Feb 2024 15:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707926137; bh=3nBeVvDzPWSYkBUuAMGRboAigFEsz79F7jZ+9eTr11k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PDRU0t6iSS5gndYGuN7noRJU4+3sY22cJUlXpmJS0WbshlislZBuL+WOH78XbW4OQ 2HKYlgz29AjLMgMt4FOTHonoqy8kkblX0mhaatZ9fv/L+oQVLhKBzwrpBJ/Y/Jhg30 RBuNY8YlFdnOkIDmTia/G9nIEcEhf2d6lY+0AXhgYoP/wdpiiA5Br5RLbFIKk2m7ba Tf8k+tDS3NtMvxyIPx0MOOpZhuZNQ15yAFqkinuJlS89qseh9P1Dun2l9HiXRiNwgq dYQ2zD7ixKYVA5cVGgZRcxe8Omw/gJ6ZEKCbhYvGEv4usmNE5Ie8sH02Fx/wSTnwmN fSNtoIgjBWg1Q== 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 1raHbi-003Bjv-UN; Wed, 14 Feb 2024 15:55:35 +0000 Date: Wed, 14 Feb 2024 15:55:33 +0000 Message-ID: <864jeb59ca.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 01/23] KVM: arm64: Add tracepoints + stats for LPI cache effectiveness In-Reply-To: <20240213093250.3960069-2-oliver.upton@linux.dev> References: <20240213093250.3960069-1-oliver.upton@linux.dev> <20240213093250.3960069-2-oliver.upton@linux.dev> 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.1 (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: oliver.upton@linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Tue, 13 Feb 2024 09:32:38 +0000, Oliver Upton wrote: > > LPI translation and injection has been shown to have a significant > impact on the performance of VM workloads, so it probably makes sense to > add some signals in this area. > > Introduce the concept of a KVM tracepoint that associates with a VM > stat and use it for the LPI translation cache tracepoints. It isn't too > uncommon for a kernel hacker to attach to tracepoints, while at the same > time userspace may open a 'binary stats' FD to peek at the corresponding > VM stats. > > Signed-off-by: Oliver Upton > --- > arch/arm64/include/asm/kvm_host.h | 3 ++ > arch/arm64/kvm/guest.c | 5 ++- > arch/arm64/kvm/vgic/trace.h | 66 +++++++++++++++++++++++++++++++ > arch/arm64/kvm/vgic/vgic-its.c | 14 ++++++- > include/linux/kvm_host.h | 4 ++ > 5 files changed, 89 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 21c57b812569..6f88b76373a5 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -966,6 +966,9 @@ static inline bool __vcpu_write_sys_reg_to_cpu(u64 val, int reg) > > struct kvm_vm_stat { > struct kvm_vm_stat_generic generic; > + u64 vgic_its_trans_cache_hit; > + u64 vgic_its_trans_cache_miss; > + u64 vgic_its_trans_cache_victim; > }; > > struct kvm_vcpu_stat { > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > index aaf1d4939739..354d67251fc2 100644 > --- a/arch/arm64/kvm/guest.c > +++ b/arch/arm64/kvm/guest.c > @@ -30,7 +30,10 @@ > #include "trace.h" > > const struct _kvm_stats_desc kvm_vm_stats_desc[] = { > - KVM_GENERIC_VM_STATS() > + KVM_GENERIC_VM_STATS(), > + STATS_DESC_COUNTER(VM, vgic_its_trans_cache_hit), > + STATS_DESC_COUNTER(VM, vgic_its_trans_cache_miss), > + STATS_DESC_COUNTER(VM, vgic_its_trans_cache_victim) > }; We've talked about this offline, but I thought I'd make my position public on these. I've very concerned that exposing these statistic, however useful they may be at a given point in time, will eventually become all wrong and/or misleading. Case in point, our discussion about this very series, where we landed on a potential reimplementation of the translation cache as a per-ITS xarray. If this comes to fruition, these stats will probably be totally useless (hit monotonically increasing at the rate of 1 per interrupt, miss being 0 or 1, victim being stuck to 0). I'm *not* saying that such stats are totally useless. Just that they are, by definition, tied to a kernel-side implementation choice, which will evolve. The trouble is that they create an ABI that we need to support forever. I wish we could work on something that would allow such statistics to be *extracted* (as opposed to published). Something like this as a discussion subject for a future KVM Forum or LPC uConf would get my full backing (and I'm pretty sure the networking folks have solved that problem a long time ago). Thanks, M. -- Without deviation from the norm, progress is not possible.