Message ID | 20240215160136.1256084-3-alejandro.j.jimenez@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-67251-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp498185dyb; Thu, 15 Feb 2024 08:02:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXL70sSwyATTTab8cYCIOcEtjzeIvlrcroUB8m7lnLdMDrUz4F827EL/CH2CWDacqgtL5wmJ7aFSFE5BoFmXsELF7dlaQ== X-Google-Smtp-Source: AGHT+IEiij0XmMhM28liH2r8ZVavejtoRWcQ3LhL8RM0faqiwG0ZXDrhmYx3oLQ1UfeOT/jRTHES X-Received: by 2002:a17:90b:3a8f:b0:299:aae:b58a with SMTP id om15-20020a17090b3a8f00b002990aaeb58amr1719258pjb.22.1708012977670; Thu, 15 Feb 2024 08:02:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708012977; cv=pass; d=google.com; s=arc-20160816; b=WW2BfDyu+FAZlsXy/OcdCJyF9ar9rmiXLN04Bx0/M3DEhGGaU156qPUuL3UX1PtwTW lK07hPRH9D7aGTU6gzQ0nNurdIkS5Z7glAsZ0OYahojsADGY7qCzmG/Dxhu31nz2B2Yb 01Ewldp7SNsk8EikuYTQU/MPBT8O9gy2kqS/064rdzRwGLTag5zR53UQmuof1jlsUTAG FoJ3vXZYXyXektqtQYxIB/HS5aCyi3MaR4zPv0Yy1GdYJ95+OP0t0d7WKSAEKuftq3d0 EI/nktRq84be7ZDpYa9V5fJWsymUPhRy3Cwepl8EeYKWZhYm3PACOgsEAPcILmLKG5ht 056w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=tFGju7bPNchiqt2tnKGa3v1xLt3nHlirTspnDjTX6L4=; fh=ymAMBhZFm6ec5ziNEh7TItdAbNlAOEinVl2jZLuT8nk=; b=C4B0ZTztkUpOBoJEVTKQj1UVZRnUanPOTAs1ac4o31u7Ow/bCFoNxVM6Qzbxq6bEN0 oU1iOtj/xiHrXMaLz9hRiIS3LJRoiu/T6tWUZdELXVfUnUCsxbBrDhltjeFrPgfiPOxc 8HVOjsin44w8wmiz9ijdnSxUWuVTF/aiMMuyvrUT8RWHqtvsEmojE+EJkLjB3YRUCzZn THtxvv2nb/+GWpCGLfRRCPY3KaXOSb2kIUqctqCQ7DJO6SzVzN7hD59ihKcnD9p4WR8/ UAnB/pYqlYh2EbaJ4tdBVv/bqO7nIy338REW5pd2XpoqSdS004t5ItzfpPKLKn66VVrT lJVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=icbN689W; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-67251-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67251-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s68-20020a635e47000000b005dc85fb4f55si1298312pgb.432.2024.02.15.08.02.57 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 08:02:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67251-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=icbN689W; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-67251-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67251-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 446F2290EA6 for <ouuuleilei@gmail.com>; Thu, 15 Feb 2024 16:02:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDA051350C6; Thu, 15 Feb 2024 16:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="icbN689W" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 6A8B953369; Thu, 15 Feb 2024 16:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708012911; cv=none; b=Ar8jkNk1L9d2uP8U7MUI0UHag7LCqoNF3QWii/AgXgFfP8ieETm+3i0k5EMB7aQqbmgd41ZbWSqUsITdVAs5jSov4ZK1mdoZ/CHUStmLRoU004XsgBGHnEr27WCmMTWNAic6vlelZYnwYVZG/VnfOvbX1fGsD0kgwiIFST4Kl78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708012911; c=relaxed/simple; bh=R8BSvkkG8B1Q3ey87bWjhKkTTn8tS5TYT9HTwPNq0CU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lAD9D63ZCNE4hUM2e9czlmszgqxZjtKpGdL6JJa5KUZAT7SVP19pts1L1LmMZ7569LD8PoYzF4B4IUo9DLXb47TaM6qdJRIHTESG/maTesGfwz/qZ5fCiARE8khClI+aBAksMAJXKvTXj/RiuA/YE9DHECM73fz/MhWMLh1XcEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=icbN689W; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41FFTYmv030204; Thu, 15 Feb 2024 16:01:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=tFGju7bPNchiqt2tnKGa3v1xLt3nHlirTspnDjTX6L4=; b=icbN689W0HGSoYorX178SmDDUqn6jZmge5q+bcM0X0oZiDe9tZjsIvbs+Uto87U6SeN2 PLChoH/tE98WMJRO/iKEMgat0y5gm6ReImvfARef6reYqA0JVWLM+gcEweAsqxle1rfx zhPxqN8Qfoey/tB5fNXxH7tY6fwHwe4cPcN+r3dma/9nSGispnc1znu0rdHHxh2CHAZn mo5E8CNjVa5yqrq4OyrykYlfUF3EnJWJ3HQzDxVCsKQaevAJzmy9c0nAdzPPqYg176gP eEe6S/KgYQpr6f4LBY0yJA60DFYY2V3zZJwgV186Dz1Qw6dH9cGblVEAcqcHNHHMsm8B Ig== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w91f02t93-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Feb 2024 16:01:42 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 41FFecT6013775; Thu, 15 Feb 2024 16:01:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3w6apdkeup-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Feb 2024 16:01:41 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 41FG1cZW031601; Thu, 15 Feb 2024 16:01:41 GMT Received: from alaljime-dev-e4flex-vm.osdevelopmeniad.oraclevcn.com (alaljime-dev-e4flex-vm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.249.106]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3w6apdkep6-3; Thu, 15 Feb 2024 16:01:41 +0000 From: Alejandro Jimenez <alejandro.j.jimenez@oracle.com> To: kvm@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.com, linux-kernel@vger.kernel.org, joao.m.martins@oracle.com, boris.ostrovsky@oracle.com, mark.kanda@oracle.com, suravee.suthikulpanit@amd.com, mlevitsk@redhat.com, alejandro.j.jimenez@oracle.com Subject: [RFC 2/3] x86: KVM: stats: Add stat counter for IRQs injected via APICv Date: Thu, 15 Feb 2024 16:01:35 +0000 Message-Id: <20240215160136.1256084-3-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240215160136.1256084-1-alejandro.j.jimenez@oracle.com> References: <20240215160136.1256084-1-alejandro.j.jimenez@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-15_14,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402150128 X-Proofpoint-ORIG-GUID: ecyd8N_T40VKvEXxh8sQtaG9KXfqb93D X-Proofpoint-GUID: ecyd8N_T40VKvEXxh8sQtaG9KXfqb93D X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790981415704822222 X-GMAIL-MSGID: 1790981415704822222 |
Series |
Export APICv-related state via binary stats interface
|
|
Commit Message
Alejandro Jimenez
Feb. 15, 2024, 4:01 p.m. UTC
Export binary stat counting how many interrupts have been delivered via
APICv/AVIC acceleration from the host. This is one of the most reliable
methods to detect when hardware accelerated interrupt delivery is active,
since APIC timer interrupts are regularly injected and exercise these
code paths.
Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
---
arch/x86/include/asm/kvm_host.h | 1 +
arch/x86/kvm/svm/svm.c | 3 +++
arch/x86/kvm/vmx/vmx.c | 2 ++
arch/x86/kvm/x86.c | 1 +
4 files changed, 7 insertions(+)
Comments
Hi Alejandro, Is there any use case of this counter in the bug? E.g., there are already trace_kvm_apicv_accept_irq() there. The ftrace or ebpf would be able to tell if the hardware accelerated interrupt delivery is active?. Any extra benefits? E.g., if this counter may need to match with any other counter in the KVM/guest so that a bug can be detected? That will be very helpful. Thank you very much! Dongli Zhang On 2/15/24 08:01, Alejandro Jimenez wrote: > Export binary stat counting how many interrupts have been delivered via > APICv/AVIC acceleration from the host. This is one of the most reliable > methods to detect when hardware accelerated interrupt delivery is active, > since APIC timer interrupts are regularly injected and exercise these > code paths. > > Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com> > --- > arch/x86/include/asm/kvm_host.h | 1 + > arch/x86/kvm/svm/svm.c | 3 +++ > arch/x86/kvm/vmx/vmx.c | 2 ++ > arch/x86/kvm/x86.c | 1 + > 4 files changed, 7 insertions(+) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 9b960a523715..b6f18084d504 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1564,6 +1564,7 @@ struct kvm_vcpu_stat { > u64 preemption_other; > u64 guest_mode; > u64 notify_window_exits; > + u64 apicv_accept_irq; > }; > > struct x86_instruction_info; > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index e90b429c84f1..2243af08ed39 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -3648,6 +3648,9 @@ void svm_complete_interrupt_delivery(struct kvm_vcpu *vcpu, int delivery_mode, > } > > trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode, trig_mode, vector); > + > + ++vcpu->stat.apicv_accept_irq; > + > if (in_guest_mode) { > /* > * Signal the doorbell to tell hardware to inject the IRQ. If > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index d4e6625e0a9a..f7db75ae2c55 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -4275,6 +4275,8 @@ static void vmx_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode, > } else { > trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode, > trig_mode, vector); > + > + ++vcpu->stat.apicv_accept_irq; > } > } > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index f7f598f066e7..2ad70cf6e52c 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_COUNTER(VCPU, apicv_accept_irq), > }; > > const struct kvm_stats_header kvm_vcpu_stats_header = {
Hi Dongli On 2/15/24 11:16, Dongli Zhang wrote: > Hi Alejandro, > > Is there any use case of this counter in the bug? I don't have a specific bug in mind that this is trying to address. This patch is just an example is to show how existing data points (i.e. the trace_kvm_apicv_accept_irq tracepoint) can also be exposed via the stats framework with minimal overhead, and to support the point in the cover letter that querying the binary stats could be the best choice for a "single source" that tells us the full status of APICv/AVIC (i.e. is SVM and IOMMU AVIC both working, are there any inhibits set, etc) > > E.g., there are already trace_kvm_apicv_accept_irq() there. The ftrace or ebpf > would be able to tell if the hardware accelerated interrupt delivery is active?. Yes, the tracepoint already provides information if you know it exists AND have sufficient privileges to use tracefs or ebpf. The purpose of the RFC is to agree on a mechanism by which to expose all the apicv relevant data (and any new additions) via a single interface so that the sources of information are not scattered across tracepoints, debugfs entries, or in data structures that need to be read via BPF. My understanding is that the stats subsystem method can work when using ftrace of bpftrace is not possible, so that is why I am suggesting that is used as the "standard" method to expose this info. There will of course be some duplication with existing tracepoints, but there is already precedent in KVM where both stats and tracepoints are updated simultaneously (e.g. mmu_{un}sync_page(), {svm|vmx}_inject_irq()). > > Any extra benefits? E.g., if this counter may need to match with any other > counter in the KVM/guest so that a bug can be detected? That will be very helpful. Again, I didn't have a specific scenario for using this counter other than the associated tracepoint is the one I typically use to determine if APICv is active. But let's think of an example on the spot: In a hypothetical scenario where I want to determine the ratio that a vCPU spends blocking or in guest mode, I could add another stat e.g.: + + ++vcpu->stat.apicv_accept_irq; + if (in_guest_mode) { /* * Signal the doorbell to tell hardware to inject the IRQ. If * the vCPU exits the guest before the doorbell chimes, hardware * will automatically process AVIC interrupts at the next VMRUN. */ avic_ring_doorbell(vcpu); + ++vcpu->stat.avic_doorbell_rung; } else { /* * Wake the vCPU if it was blocking. KVM will then detect the * pending IRQ when checking if the vCPU has a wake event. */ kvm_vcpu_wake_up(vcpu); } and then the ratio of (avic_doorbell_rung / apicv_accept_irq) lets me estimate a percentage of time the target vCPU is idle or running. There are likely better ways of determining this, but you get the idea. The goal is to have a general consensus for whether or not I should opt to add a new tracepoint (trace_kvm_avic_ring_doorbell) or a new stat as the "preferred" solution. Obviously there are still cases where a tracepoint is the best approach (e.g. it transfers more information). Hopefully I didn't stray too far from your question/point. Alejandro > > Thank you very much! > > Dongli Zhang > > On 2/15/24 08:01, Alejandro Jimenez wrote: >> Export binary stat counting how many interrupts have been delivered via >> APICv/AVIC acceleration from the host. This is one of the most reliable >> methods to detect when hardware accelerated interrupt delivery is active, >> since APIC timer interrupts are regularly injected and exercise these >> code paths. >> >> Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com> >> --- >> arch/x86/include/asm/kvm_host.h | 1 + >> arch/x86/kvm/svm/svm.c | 3 +++ >> arch/x86/kvm/vmx/vmx.c | 2 ++ >> arch/x86/kvm/x86.c | 1 + >> 4 files changed, 7 insertions(+) >> >> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h >> index 9b960a523715..b6f18084d504 100644 >> --- a/arch/x86/include/asm/kvm_host.h >> +++ b/arch/x86/include/asm/kvm_host.h >> @@ -1564,6 +1564,7 @@ struct kvm_vcpu_stat { >> u64 preemption_other; >> u64 guest_mode; >> u64 notify_window_exits; >> + u64 apicv_accept_irq; >> }; >> >> struct x86_instruction_info; >> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c >> index e90b429c84f1..2243af08ed39 100644 >> --- a/arch/x86/kvm/svm/svm.c >> +++ b/arch/x86/kvm/svm/svm.c >> @@ -3648,6 +3648,9 @@ void svm_complete_interrupt_delivery(struct kvm_vcpu *vcpu, int delivery_mode, >> } >> >> trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode, trig_mode, vector); >> + >> + ++vcpu->stat.apicv_accept_irq; >> + >> if (in_guest_mode) { >> /* >> * Signal the doorbell to tell hardware to inject the IRQ. If >> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c >> index d4e6625e0a9a..f7db75ae2c55 100644 >> --- a/arch/x86/kvm/vmx/vmx.c >> +++ b/arch/x86/kvm/vmx/vmx.c >> @@ -4275,6 +4275,8 @@ static void vmx_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode, >> } else { >> trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode, >> trig_mode, vector); >> + >> + ++vcpu->stat.apicv_accept_irq; >> } >> } >> >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index f7f598f066e7..2ad70cf6e52c 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_COUNTER(VCPU, apicv_accept_irq), >> }; >> >> const struct kvm_stats_header kvm_vcpu_stats_header = {
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 9b960a523715..b6f18084d504 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1564,6 +1564,7 @@ struct kvm_vcpu_stat { u64 preemption_other; u64 guest_mode; u64 notify_window_exits; + u64 apicv_accept_irq; }; struct x86_instruction_info; diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index e90b429c84f1..2243af08ed39 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3648,6 +3648,9 @@ void svm_complete_interrupt_delivery(struct kvm_vcpu *vcpu, int delivery_mode, } trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode, trig_mode, vector); + + ++vcpu->stat.apicv_accept_irq; + if (in_guest_mode) { /* * Signal the doorbell to tell hardware to inject the IRQ. If diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index d4e6625e0a9a..f7db75ae2c55 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4275,6 +4275,8 @@ static void vmx_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode, } else { trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode, trig_mode, vector); + + ++vcpu->stat.apicv_accept_irq; } } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f7f598f066e7..2ad70cf6e52c 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_COUNTER(VCPU, apicv_accept_irq), }; const struct kvm_stats_header kvm_vcpu_stats_header = {