From patchwork Thu Aug 31 08:30:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhaotianrui X-Patchwork-Id: 137327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c792:0:b0:3f2:4152:657d with SMTP id b18csp388978vqu; Thu, 31 Aug 2023 10:24:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFeWGnZJSqG4RD3mVxm7+TZattJtU6NMTxZRuYGh7FIWIAjbXrylDyh3kwN0f2/rmjHqMpr X-Received: by 2002:a92:d90b:0:b0:34c:e5c2:918b with SMTP id s11-20020a92d90b000000b0034ce5c2918bmr153946iln.13.1693502694150; Thu, 31 Aug 2023 10:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693502694; cv=none; d=google.com; s=arc-20160816; b=Jy2M4A+QwKA5KoEhi31k8Q6bdzWK6kMpGKQEMsqUsVgAQdgwTKuZtl7SUycvhVQ87V 5CRbDc/csLDnjAOoQDWxGIAVvNq6WO3AQWFON4hsHYOUFSS8QkluA41UtnFPvaUFznog YABHGqY7N4IKmSlOjw+i/40lqda6EEEXdgnKmwj9pS2F+8YhcNQFxGG33TBkZZ25RWa0 MKtHK9ojfcq9ylrtH7TKkRgDLZz5GhSiwHB/E8+OYxOTzaxmBpmT2X65yMPOXjP9YdWq o7vwUsUUmylFdUHJmbnn7qeuKy4h98gNAhOcA8C0hhVuz6ILR55KW0uduMA0febBQy3L LrVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3zmQQG7VfEWBwNMHK0tSqS6shlFJngXdRue/sBCLOJI=; fh=ejoaVAUUbBXsA/6jM/beuI9xCYtV2osdR9SpI7hjY84=; b=XWcqm3z2YzRFsrej3MnLwRpHOTiRtNNILIrs6E7KOVy6TE1MSjaZ6PghGSAY4dHtKT fGZxoC0be+rDkMB9xeXz+o7Wen3uAF8XLUjILuwunpy6db7DWDdeXR/8AyicEEtEqt7G RtmREf3PhAqKL2qkj08ymFysxnLYgCoR/2tRbCAwizpy9LwDRnir/Cr7NvmTyJTwMmtA 9DXwa64+ZAe9kVRLwYSSIsHTCuUvifUCZh5kqes4NWuk7PnvIWPksyGo8qSAjRNJkiml aUSkhvRrFLvD7urrx1WeA56heJt/vKXwtwlX5cg2TunwiUlbn8HCed0BB47SxgwnETme z1XA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 203-20020a6301d4000000b00565e386ff44si1478368pgb.702.2023.08.31.10.24.38; Thu, 31 Aug 2023 10:24:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242308AbjHaIbe (ORCPT + 99 others); Thu, 31 Aug 2023 04:31:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244373AbjHaIbQ (ORCPT ); Thu, 31 Aug 2023 04:31:16 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 795EFE5E; Thu, 31 Aug 2023 01:30:39 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8AxDOupT_Bkbl4dAA--.54712S3; Thu, 31 Aug 2023 16:30:33 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Ax3c6gT_BkOPVnAA--.55892S17; Thu, 31 Aug 2023 16:30:32 +0800 (CST) From: Tianrui Zhao To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Huacai Chen , WANG Xuerui , Greg Kroah-Hartman , loongarch@lists.linux.dev, Jens Axboe , Mark Brown , Alex Deucher , Oliver Upton , maobibo@loongson.cn, Xi Ruoyao , zhaotianrui@loongson.cn Subject: [PATCH v20 15/30] LoongArch: KVM: Implement vcpu status description Date: Thu, 31 Aug 2023 16:30:05 +0800 Message-Id: <20230831083020.2187109-16-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230831083020.2187109-1-zhaotianrui@loongson.cn> References: <20230831083020.2187109-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Ax3c6gT_BkOPVnAA--.55892S17 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775766281045942790 X-GMAIL-MSGID: 1775766281045942790 Implement LoongArch vcpu status description such as idle exits counter, signal exits counter, cpucfg exits counter, etc. Reviewed-by: Bibo Mao Signed-off-by: Tianrui Zhao --- arch/loongarch/kvm/vcpu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c index 79e4e22773..60b2e584c6 100644 --- a/arch/loongarch/kvm/vcpu.c +++ b/arch/loongarch/kvm/vcpu.c @@ -13,6 +13,23 @@ #define CREATE_TRACE_POINTS #include "trace.h" +const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { + KVM_GENERIC_VCPU_STATS(), + STATS_DESC_COUNTER(VCPU, idle_exits), + STATS_DESC_COUNTER(VCPU, signal_exits), + STATS_DESC_COUNTER(VCPU, int_exits), + STATS_DESC_COUNTER(VCPU, cpucfg_exits), +}; + +const struct kvm_stats_header kvm_vcpu_stats_header = { + .name_size = KVM_STATS_NAME_SIZE, + .num_desc = ARRAY_SIZE(kvm_vcpu_stats_desc), + .id_offset = sizeof(struct kvm_stats_header), + .desc_offset = sizeof(struct kvm_stats_header) + KVM_STATS_NAME_SIZE, + .data_offset = sizeof(struct kvm_stats_header) + KVM_STATS_NAME_SIZE + + sizeof(kvm_vcpu_stats_desc), +}; + int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) { return !!(vcpu->arch.irq_pending) &&