Message ID | 20240215160136.1256084-1-alejandro.j.jimenez@oracle.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-67250-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp497893dyb; Thu, 15 Feb 2024 08:02:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWxEaqyMGLo6qIeoBWsvsXGdgOZAZHLQu4csH6ZScA01KhijXeIrwVadUmGaw5fuXdbT94RTHDBGvy9WRJwmHzPANCPHQ== X-Google-Smtp-Source: AGHT+IFumhUF5nFVaUJP5/h5HFqMhRSpCsETDWFOlqA3R9Xwy6iCJMibLFBQp/9QIijRBIj2lCoU X-Received: by 2002:aa7:c517:0:b0:561:ff30:2d44 with SMTP id o23-20020aa7c517000000b00561ff302d44mr1992953edq.17.1708012959436; Thu, 15 Feb 2024 08:02:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708012959; cv=pass; d=google.com; s=arc-20160816; b=bc8gtHKz2pQwjEzg8AWy+ocQvk++pSIUUiHQdYrlvIxKZooCMJzoh2pbZR+M0U34Yu oa3Vjf2WgGJOWwhaaIQmucWxkrY1kXJsY7/M2ZfP3cCQIBnEwklH3WhLLmcw31hcL0ks 78EPCKuY4xwnyeEMz4tuJ26qyfiFTEYvdVkcEwuFrArWjO7q9+hr92MDww3pHgy05X/U iMQCyECG/x1r+a/TqKhuwb70zxZOiOObzZ+ud6AtDHdmFmqy77NEdEda1Kh7L6Ch7vBH 0rJjNgW4fSdaTmrSIZuZg+5ue8iE4BLFKmDZFIGjtzJ/2v0Y9Jf7pjnqLe89hL8kPxC2 Vm/g== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=+NjmOTX3CsrKN1v5/+XuTP0aoVY5fQmXlmcThaiCXH4=; fh=ymAMBhZFm6ec5ziNEh7TItdAbNlAOEinVl2jZLuT8nk=; b=bapH5e2rnNsu7c48CX6/X5QjW8nk1byrU8O4pE2WTzU9kd6NPw9f1QCQEbUUcXql0Z Qv70JlMDorpYegibZX5mUeOFez2zSlhnf5CfY8qW1UFTT6/P8whVQgr1sPug2D6bBe1f qktyTdIFI4aBLDfA/4wFMIFaBiceCu4bc92lrLKEF95x63lBOovQ2iwjRi3qeOiurs7B +v6eMak/dZgEK1bYNiqyIy0vEq+tWc/li53zyfzHuyM0tgQ5tVnGtrF2pI9rmADntT0z 3SFto63hiPced0pDHN36Pl8FUmNYR3tPvq4ZwYAITO7uwv/SOucmI6ua1OS2n9aRJVMp 1NQg==; 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=NFkFYSZL; 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-67250-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67250-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u2-20020aa7d982000000b00563d681b717si30217eds.686.2024.02.15.08.02.39 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 08:02:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67250-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=NFkFYSZL; 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-67250-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67250-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B7FCC1F23AA3 for <ouuuleilei@gmail.com>; Thu, 15 Feb 2024 16:02:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 849EE13475C; Thu, 15 Feb 2024 16:01:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="NFkFYSZL" 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 A677D20B3D; Thu, 15 Feb 2024 16:01:47 +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=1708012909; cv=none; b=BTLa1M6o0cKg6eFSGsgJCEdq+hGjFvouCieS7SiJJND3tBYitlGqyn4GgtJp93U2mWGWIEXC3ATehgO4m4xV8tJ4NxGcTL2kSAa4VG9oWqqacBgAKUAuT4NNZX03TxP0t6cbGTp/O6UqK4qtM8GzIrz+V83kszlNa4QgT5T3aq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708012909; c=relaxed/simple; bh=V3kpBue3P3meAyX+1HSi9AH3VSVEyzeJ+FuYYhoELcE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=lO4FXJyvjAjH0UDvaIDq/Z17eJ+etOAil441iNYg/UWMbKkhCxwiPrSIO53rFx9kXH2gOdDkMMK15iV/3ynZW6Tkp4OHC67rwYKG6wC7F7nownXFDX3Ks75TMu7RqXeXUYxaxv/8RRmSKbIUrffPv/3dXP1rArEUHMoizH8axG4= 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=NFkFYSZL; 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 41FFTYlw030199; Thu, 15 Feb 2024 16:01:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=+NjmOTX3CsrKN1v5/+XuTP0aoVY5fQmXlmcThaiCXH4=; b=NFkFYSZLrPtrxgh2N8fN+nX/gLb4b2KU4Bk++MesbmxvSabk1AyZQHh3jHbi9OQGrGAF YyG/Vtf/YAxVRgVlZZIZSD8gs5sopt5Ey0pauMOqN9149BYUygPxWcl3FoaWqBGeuy+O 90n5DU9Xw9kBG5qj+NCX8pf/pW+H8X70rpgG6vCBWEaWbhoDukbH/AOcbU2pkLillhNF c89HUllMJ8w33R5z2e9axw7mFw63LvoUkNB7f/mv62f3CUIprOz4CZ/p6an7fYJCR8zW ZRsXA8FE/koV6iatHRKx1GgSJcCA/n+xPttM+n6tM18GR+AGbjjjD5LpsMXCcWJdwhJM oA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w91f02t8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Feb 2024 16:01:39 +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 41FFZh9Z013875; Thu, 15 Feb 2024 16:01:38 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3w6apdker0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Feb 2024 16:01:38 +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 41FG1cZS031601; Thu, 15 Feb 2024 16:01:38 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-1; Thu, 15 Feb 2024 16:01:38 +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 0/3] Export APICv-related state via binary stats interface Date: Thu, 15 Feb 2024 16:01:33 +0000 Message-Id: <20240215160136.1256084-1-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 2.39.3 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=939 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: j0Kt_fpUjNlkODnGPzdp7ycg9RdnpFVL X-Proofpoint-GUID: j0Kt_fpUjNlkODnGPzdp7ycg9RdnpFVL X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790981396782081769 X-GMAIL-MSGID: 1790981396782081769 |
Series |
Export APICv-related state via binary stats interface
|
|
Message
Alejandro Jimenez
Feb. 15, 2024, 4:01 p.m. UTC
The goal of this RFC is to agree on a mechanism for querying the state (and related stats) of APICv/AVIC. I clearly have an AVIC bias when approaching this topic since that is the side that I have mostly looked at, and has the greater number of possible inhibits, but I believe the argument applies for both vendor's technologies. Currently, a user or monitoring app trying to determine if APICv is actually being used needs implementation-specific knowlegde in order to look for specific types of #VMEXIT (i.e. AVIC_INCOMPLETE_IPI/AVIC_NOACCEL), checking GALog events by watching /proc/interrupts for AMD-Vi*-GA, etc. There are existing tracepoints (e.g. kvm_apicv_accept_irq, kvm_avic_ga_log) that make this task easier, but tracefs is not viable in some scenarios. Adding kvm debugfs entries has similar downsides. Suravee has previously proposed a new IOCTL interface[0] to expose this information, but there has not been any development in that direction. Sean has mentioned a preference for using BPF to extract info from the current tracepoints, which would require reworking existing structs to access some desired data, but as far as I know there isn't any work done on that approach yet. Recently Joao mentioned another alternative: the binary stats framework that is already supported by kernel[1] and QEMU[2]. This RFC has minimal code changes to expose the relevant info based on the existing data types the framework already supports. If there is consensus on using this approach, I can expand the fd stats subsystem to include other data types (e.g. a bitmap type for exposing the inhibit reasons), as well as adding documentation on KVM explaining which stats are relevant for APICv and how to query them. A basic example of retrieving the stats via qmp-shell, showing both a VM and per-vCPU case: # /usr/local/bin/qmp-shell --pretty ./qmp-sock (QEMU) query-stats target=vm providers=[{'provider':'kvm','names':['apicv_inhibited']}] { "return": [ { "provider": "kvm", "stats": [ { "name": "apicv_inhibited", "value": false } ] } ] } (QEMU) query-stats target=vcpu vcpus=['/machine/unattached/device[0]'] providers=[{'provider':'kvm','names':['apicv_accept_irq','ga_log_event']}] { "return": [ { "provider": "kvm", "qom-path": "/machine/unattached/device[0]", "stats": [ { "name": "ga_log_event", "value": 98 }, { "name": "apicv_accept_irq", "value": 166920 } ] } ] } If other alternatives are preferred, please let's use this thread to discuss and I can take a shot at implementing the desired solution. Regards, Alejandro [0] https://lore.kernel.org/qemu-devel/7e0d22fa-b9b0-ad1a-3a37-a450ec5d73e8@amd.com/ [1] https://lore.kernel.org/all/20210618222709.1858088-1-jingzhangos@google.com/ [2] https://lore.kernel.org/qemu-devel/20220530150714.756954-1-pbonzini@redhat.com/ Alejandro Jimenez (3): x86: KVM: stats: Add a stat to report status of APICv inhibition x86: KVM: stats: Add stat counter for IRQs injected via APICv x86: KVM: stats: Add a stat counter for GALog events arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/svm/avic.c | 4 +++- arch/x86/kvm/svm/svm.c | 3 +++ arch/x86/kvm/vmx/vmx.c | 2 ++ arch/x86/kvm/x86.c | 12 +++++++++++- 5 files changed, 22 insertions(+), 2 deletions(-) base-commit: 7455665a3521aa7b56245c0a2810f748adc5fdd4