Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1292212lqj; Mon, 3 Jun 2024 17:18:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWb+oY+4Mwy3nqKDhnlGBIDLdpWP2WHIvqVURVVJoyyc/Gqq9ikmWeDrOy6oamRTOe0CANlyD7PxdtkQWYtYF16uBSeqdOektS7WpX0ZA== X-Google-Smtp-Source: AGHT+IG8rO/7ptM4+511Arw5Te+uqw1Vvi4dNCmDa0Xc+u88Sob91r9y93adAizlkB+B7ySINuya X-Received: by 2002:a05:6870:9a11:b0:24d:e85b:c9fd with SMTP id 586e51a60fabf-2508b9a36d6mr11771532fac.1.1717460315943; Mon, 03 Jun 2024 17:18:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717460315; cv=pass; d=google.com; s=arc-20160816; b=hax+nT/F+WYIMNWPoehnlTVcFpgDph1QoCOycxW3v0h2MeJIgvj9bh2dSLZ8+aJZ5E UImpYB7RzXR4tdH+yy9m8DHkLKmonSWO80mTDAAEE9PEcbr1jOdlj0nTF97xXUd5Q1hN wwCR0cPHPBIC4pbJfAil8jMMHP9sjuUEZ01D2S45teoe6C+VQemKLjROOIhII+tf4E07 I2Uj6H2iHbICuaWntsDdJS0cQovPyYZT/utVOlKjeyfroSojLHO8CnHNKONGw1muAIh1 AUHG2wTZOISKORorshcUsR0lktkGlGvcfu192UojnlMpkTC2ZmXMyS9Wcp2O/sL+LVDD 8EgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=G/TfS4/60UepRstkKEdbSidSYhzWazLDql3xTTEsWh4=; fh=K91f2pgT413qfFM1YaMHTF50Ov7O+m+Eny0+Vp3IuWc=; b=d4GI7c9naDzmm6I3eNJYgiuAXJ5yYTEgxClMU5PS+OcbrBzI7GXhak+vmy0lnVxUTN p2jcuv+VKVtktIXkBgdEm5VT3bVE/zBs3Bq6FeUjGYzQEq9l2/9QBoKeIojZgfCxZD/I azW0Y+XvQoW5l25+TQ1q55JRDYDWusOuPL3MbPkx2Xvd/YtEMYomAKHP96yOGRuWfl+9 VG+jMEEz3MGtcOpD+uSr/ms+4o6wVs5gle6Gz2cnvrQGKXCKHzjc8OmUDCzEBnQAl+Yz Mwy+PjpvftC1Y1oTkMnOoDTo+ac+Ui+XVv8RqoyoY9qu1RWnymDMTW7Lr3up+QtX8gXA gGyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YOtUEOUs; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-199865-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199865-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c359e0973esi1241277a12.249.2024.06.03.17.18.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 17:18:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199865-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YOtUEOUs; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-199865-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199865-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B910FB2353C for ; Tue, 4 Jun 2024 00:17:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 017278F45; Tue, 4 Jun 2024 00:16:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YOtUEOUs" Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D152B4A2C for ; Tue, 4 Jun 2024 00:16:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717460195; cv=none; b=cFJq/WaMlTx/FQV36TQJqn8zdZ5++Du2U+XYwQ1/8Nud3yIxECEj+ni8ZgaKn8u2pZ6fo7eME0m92nt4r0reoPpdG2F45Dbx+7oluxXAwGltcP7JDR3L+HU6WVaReLibUGO/JAuuq2smn9FmwONSSXIXlnoBPfc5VDtZgugo+28= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717460195; c=relaxed/simple; bh=nwUxXuGO/V+qs74FXe4f9EFw4ZB9RigLc/DpnKdr0IQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=C5eByLCcGpOtV1g4BukK0GucsqDktE459kx8R7aAFRYia9B8+bWCTItFlud2kaSwTnuaJ2L8Yn6uEGMGqG7zSFRHAIeAi9H9bLDUVIcPrmNrCrpzZi9CsybVEIIqMirFRmsi2Hp9+n6cBQj3JaEBILExLwt7Ttx4RRKB9fUCGDw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=YOtUEOUs; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-702345d4ad2so3491993b3a.0 for ; Mon, 03 Jun 2024 17:16:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717460193; x=1718064993; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=G/TfS4/60UepRstkKEdbSidSYhzWazLDql3xTTEsWh4=; b=YOtUEOUs+eu1Cfex72x1qvNEl0TRqacvHAxUdT/ssuKZ4v1OBk37LmCGDjnt6BROfw r4SJBnEBw0Pkdo/ocMS9ehi2Taq2oA5hVTynI72yIlyx2btF6R34clqT5TS56RYHSLqQ 4rkS7nUpddBVM+1cKbxKE8gT5JVmnfySHhEGVsT+jKFKnLYpy22zTL7cSoXK2EQ7ZQFl 3YwOAZSyi6CkInPVA0c7yvUVkeKwir7NyAkzLjL4HxvAWey1qAyLXMfWOoXDrq3bVFFl bUMoecTJ8n1f0vtVRcTi+z79aun+5KHvWojHk8o/wpGIGPklAeeUEvpUI1w+TkN/w7rB nupg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717460193; x=1718064993; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=G/TfS4/60UepRstkKEdbSidSYhzWazLDql3xTTEsWh4=; b=b0CIBsPuvgrq2pOGDatniXfZp+lrmApGF/KDvMArmJPQmn6hwFH5JdA6QQvpuBJlpR 2Ou3uNomPZ5PSEZBTci2fDm0gJbdkMPgmiHos85blHlaGyz86qJNjGhZzOISL3Cggfu/ 50qWAaoBRvBnO/cI+zYDAJIEChFQqhIEIfFC0WA6H+botd9/66HtFYpTIpNTA37s4Npc RQJF8goKC5Jmob84jOAIuUnv7U4i82tYpKx5vFw/omNswAyTsUF7XmgEEczPVNqGSPLn fRUyg0xMPC6U7CITUVcl1gqNI/hnTQCH9QUV5k4svd4RZi/ToRKswcLXUITCW6rZp2R8 cUbQ== X-Forwarded-Encrypted: i=1; AJvYcCW2Igu/ROdHlDC074mprSLIQB7PiyJAIcqiG3E+dIZacjTbf91wWm+N8CixBvTNhzxeOg2vFsAPQ+MJrUYo228ZJ78SrkLAcv7pyLo9 X-Gm-Message-State: AOJu0YxnvVEBPUJSSq2hcASG6Pa6df5NS3n/e5aR8Gk8jTjjdkwTKLTt b/btcA+FEI5unHykf/i4HE0+Y5xGiFAFIcMCjuwMne1Ke9wfdkxlDQEIHxpc0vOx90f5LIpoSRA Dmw== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:2d15:b0:6f3:ea4b:d232 with SMTP id d2e1a72fcca58-7024765c8f2mr419284b3a.0.1717460193037; Mon, 03 Jun 2024 17:16:33 -0700 (PDT) Date: Mon, 3 Jun 2024 17:16:31 -0700 In-Reply-To: <20240429155738.990025-2-alejandro.j.jimenez@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240429155738.990025-1-alejandro.j.jimenez@oracle.com> <20240429155738.990025-2-alejandro.j.jimenez@oracle.com> Message-ID: Subject: Re: [PATCH 1/4] KVM: x86: Expose per-vCPU APICv status From: Sean Christopherson To: Alejandro Jimenez Cc: kvm@vger.kernel.org, pbonzini@redhat.com, linux-kernel@vger.kernel.org, suravee.suthikulpanit@amd.com, vashegde@amd.com, mlevitsk@redhat.com, joao.m.martins@oracle.com, boris.ostrovsky@oracle.com, mark.kanda@oracle.com Content-Type: text/plain; charset="us-ascii" On Mon, Apr 29, 2024, Alejandro Jimenez wrote: > Expose the APICv activation status of individual vCPUs via the stats > subsystem. In special cases a vCPU's APICv can be deactivated/disabled > even though there are no VM-wide inhibition reasons. The only current > example of this is AVIC for a vCPU running in nested mode. This type of > inhibition is not recorded in the VM inhibit reasons or visible in > current tracepoints. > > Signed-off-by: Alejandro Jimenez > --- > arch/x86/include/asm/kvm_host.h | 1 + > arch/x86/kvm/lapic.c | 1 + > arch/x86/kvm/x86.c | 2 ++ > 3 files changed, 4 insertions(+) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 1d13e3cd1dc5..12f30cb5c842 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1573,6 +1573,7 @@ struct kvm_vcpu_stat { > u64 preemption_other; > u64 guest_mode; > u64 notify_window_exits; > + u64 apicv_active; Hrm, do we really have no way to effectively symlink stats to internal state? That seems like a flaw. It's obviously not the end of the world, but having to burn 8 bytes per vCPU for boolean stats that are 1:1 reflections of KVM state is going to be a deterrent for future stats. > }; > > struct x86_instruction_info; > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index cf37586f0466..37fe75a5db8c 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -2872,6 +2872,7 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu, int timer_advance_ns) > */ > if (enable_apicv) { > apic->apicv_active = true; > + vcpu->stat.apicv_active = apic->apicv_active; > kvm_make_request(KVM_REQ_APICV_UPDATE, vcpu); > } > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index e9ef1fa4b90b..0451c4c8d731 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -304,6 +304,7 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { > STATS_DESC_COUNTER(VCPU, preemption_other), > STATS_DESC_IBOOLEAN(VCPU, guest_mode), > STATS_DESC_COUNTER(VCPU, notify_window_exits), > + STATS_DESC_IBOOLEAN(VCPU, apicv_active), > }; > > const struct kvm_stats_header kvm_vcpu_stats_header = { > @@ -10625,6 +10626,7 @@ void __kvm_vcpu_update_apicv(struct kvm_vcpu *vcpu) > goto out; > > apic->apicv_active = activate; > + vcpu->stat.apicv_active = apic->apicv_active; > kvm_apic_update_apicv(vcpu); > static_call(kvm_x86_refresh_apicv_exec_ctrl)(vcpu); > > -- > 2.39.3 >