Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3456675ybb; Mon, 13 Apr 2020 08:27:09 -0700 (PDT) X-Google-Smtp-Source: APiQypLbgZSe+RL26mappSw7p4x9pHCV7ggxIj+npCZZi2Nc5wXEEPKsp4TPXa2uDpHllchUhIBl X-Received: by 2002:a17:906:18a2:: with SMTP id c2mr16577576ejf.167.1586791629511; Mon, 13 Apr 2020 08:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586791629; cv=none; d=google.com; s=arc-20160816; b=owmzkU137Wv9L0ga+D9rh7Wm8rdZndGokV772bAn5ld4ntj+092NFmsTfrCSNzyzwf 3XAEqxdiPfcUDTxbWuJMPk86ASommEk9dKi26LvQ+Eq+acLpAUTdfk+81yNoArOyAknw aEylEgpuh5dfaL0gDy48aQDHO4pSd2hDrqBnES4mIUxD7MBiMOfROXLUjVYf3FDSrs/n 8E6iCUR6Dfkswa3L/nDoKb0rKgmxGWtiVeE0xifxoE0n0psJC0AaZkfA/foxgu5auviE DsRXrclbBdJw0xJUkb0JVrhvo4SeajcGPxoG4d4KYZ9LmwteVBbu+1KDO3oA0nd1sPwE ci/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=DMxjnALOO+13jpd4EXyv1/+VreDyJBNjIrO01oQGGFU=; b=zMJQnOFXCbpK7efWxm1TRQ3Iu+9NeyY/xxTw8Dd7XJl9oog4G58oYsg1YTNQWltpjg 5q5fNhjXExzHC0uBiLDAmJ7zu2ZdYeKvFZ7MqksonI7EdW6UWPQp/A72PYRpL85W1EuA PHhC4qBpoM+Wo1NsgnPk6Va7zeBfQ/5QSGZJINjmcQSk9B0S6rYniwHLTj7DKncJ/7Yx WINT4v9Dy+MRJy+AGtl85VJ1DSxsVCw2Glk9hk8XYyW82/4wmNZwcF7xLZDdK0njTQ9L Cta3wioO+lgZ5lHxEwmBV3lyZ8r7P4Qzemox+yjfmznQ4cTQggUEz6Kiyue1gieVyFR+ NwjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LllGleyi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u23si6697926edo.122.2020.04.13.08.26.45; Mon, 13 Apr 2020 08:27:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LllGleyi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730249AbgDMOEB (ORCPT + 99 others); Mon, 13 Apr 2020 10:04:01 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:52782 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730261AbgDMOEA (ORCPT ); Mon, 13 Apr 2020 10:04:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586786637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=DMxjnALOO+13jpd4EXyv1/+VreDyJBNjIrO01oQGGFU=; b=LllGleyit1IfVZMQ5DZY2OMkI+OxhklPPVCjm0deGUj2wOvNS5HY5jrzJBM3e5jF2mOy77 vciUMD9DbzgWgDxB+CTvTMvl2Kl/SDAuQT3t9ZUOlCmboXHOLMqrSrwYjyYl2jizwM8eys YHjWE/NMhbfTmktYWoCnnvuKY6Pk9+w= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-66-qdnw0b3EMEaWdeEfvnsDWA-1; Mon, 13 Apr 2020 10:03:56 -0400 X-MC-Unique: qdnw0b3EMEaWdeEfvnsDWA-1 Received: by mail-wr1-f69.google.com with SMTP id r17so6740635wrg.19 for ; Mon, 13 Apr 2020 07:03:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DMxjnALOO+13jpd4EXyv1/+VreDyJBNjIrO01oQGGFU=; b=kf1f7XpqiHJhsL0bYs6SGL3KK5Bigeuze5Ex3zF8e7OPRxqRHzptbfurWduglf/Zg7 5HZoWUh7Aybi0eY5TSbTba6UsLNDdehDcHt7wPntVF3vAt4qoVWbhSY9gGOtwOY3OvJl GEiG8z++My/AqRdtOo4vuBX1MH3chgU5uc6H4zjrQDR86AZan3PU+ZDur2jtNlprHYr5 I4d+9C1m1UPQiUemoDXDyb5fjYLVo5aO54vx9eFhJc1d0Mc63tSu21IBN5coodFiR8vG MuCnNwWswh+FXUZl7gLde3NC9X3zE94O3UaRn3rIVULZmf3es2xKyo1yJo7kXo3qxZrq XPBg== X-Gm-Message-State: AGi0PubnAJwyyvueh05dq8OAEbDlVnLfIJ10m05YOYjrzzWw0YjMG2NH t1rn3xeUZAdwSlH+d0AEDmPxsgBxwha8mD54Vp3j/a6KXVO1z62iRC7wE392uKK8g+mrymaqr6I zL3aAn4l3QNfS8n5x4P7bZhSa X-Received: by 2002:adf:fc4c:: with SMTP id e12mr18660278wrs.265.1586786634644; Mon, 13 Apr 2020 07:03:54 -0700 (PDT) X-Received: by 2002:adf:fc4c:: with SMTP id e12mr18660255wrs.265.1586786634361; Mon, 13 Apr 2020 07:03:54 -0700 (PDT) Received: from emanuele-MacBookPro.redhat.com ([194.230.155.239]) by smtp.gmail.com with ESMTPSA id j10sm11726263wmi.18.2020.04.13.07.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 07:03:53 -0700 (PDT) From: Emanuele Giuseppe Esposito To: kvm@vger.kernel.org Cc: Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Paul Mackerras , Michael Ellerman , Benjamin Herrenschmidt , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Emanuele Giuseppe Esposito , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Subject: [PATCH] kvm_host: unify VM_STAT and VCPU_STAT definitions in a single place Date: Mon, 13 Apr 2020 16:03:32 +0200 Message-Id: <20200413140332.22896-1-eesposit@redhat.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The macros VM_STAT and VCPU_STAT are redundantly implemented in multiple files, each used by a different architecure to initialize the debugfs entries for statistics. Since they all have the same purpose, they can be unified in a single common definition in include/linux/kvm_host.h Signed-off-by: Emanuele Giuseppe Esposito --- arch/arm64/kvm/guest.c | 23 +++++++-------- arch/mips/kvm/mips.c | 61 +++++++++++++++++++-------------------- arch/powerpc/kvm/book3s.c | 3 -- arch/powerpc/kvm/booke.c | 3 -- arch/s390/kvm/kvm-s390.c | 3 -- arch/x86/kvm/x86.c | 3 -- include/linux/kvm_host.h | 3 ++ 7 files changed, 43 insertions(+), 56 deletions(-) diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 23ebe51410f0..3e3aee8b37c0 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -29,20 +29,17 @@ #include "trace.h" -#define VM_STAT(x) { #x, offsetof(struct kvm, stat.x), KVM_STAT_VM } -#define VCPU_STAT(x) { #x, offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU } - struct kvm_stats_debugfs_item debugfs_entries[] = { - VCPU_STAT(halt_successful_poll), - VCPU_STAT(halt_attempted_poll), - VCPU_STAT(halt_poll_invalid), - VCPU_STAT(halt_wakeup), - VCPU_STAT(hvc_exit_stat), - VCPU_STAT(wfe_exit_stat), - VCPU_STAT(wfi_exit_stat), - VCPU_STAT(mmio_exit_user), - VCPU_STAT(mmio_exit_kernel), - VCPU_STAT(exits), + { "halt_successful_poll", VCPU_STAT(halt_successful_poll) }, + { "halt_attempted_poll", VCPU_STAT(halt_attempted_poll) }, + { "halt_poll_invalid", VCPU_STAT(halt_poll_invalid) }, + { "halt_wakeup", VCPU_STAT(halt_wakeup) }, + { "hvc_exit_stat", VCPU_STAT(hvc_exit_stat) }, + { "wfe_exit_stat", VCPU_STAT(wfe_exit_stat) }, + { "wfi_exit_stat", VCPU_STAT(wfi_exit_stat) }, + { "mmio_exit_user", VCPU_STAT(mmio_exit_user) }, + { "mmio_exit_kernel", VCPU_STAT(mmio_exit_kernel) }, + { "exits", VCPU_STAT(exits) }, { NULL } }; diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index 8f05dd0a0f4e..f14b93d02f02 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c @@ -39,40 +39,39 @@ #define VECTORSPACING 0x100 /* for EI/VI mode */ #endif -#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x) struct kvm_stats_debugfs_item debugfs_entries[] = { - { "wait", VCPU_STAT(wait_exits), KVM_STAT_VCPU }, - { "cache", VCPU_STAT(cache_exits), KVM_STAT_VCPU }, - { "signal", VCPU_STAT(signal_exits), KVM_STAT_VCPU }, - { "interrupt", VCPU_STAT(int_exits), KVM_STAT_VCPU }, - { "cop_unusable", VCPU_STAT(cop_unusable_exits), KVM_STAT_VCPU }, - { "tlbmod", VCPU_STAT(tlbmod_exits), KVM_STAT_VCPU }, - { "tlbmiss_ld", VCPU_STAT(tlbmiss_ld_exits), KVM_STAT_VCPU }, - { "tlbmiss_st", VCPU_STAT(tlbmiss_st_exits), KVM_STAT_VCPU }, - { "addrerr_st", VCPU_STAT(addrerr_st_exits), KVM_STAT_VCPU }, - { "addrerr_ld", VCPU_STAT(addrerr_ld_exits), KVM_STAT_VCPU }, - { "syscall", VCPU_STAT(syscall_exits), KVM_STAT_VCPU }, - { "resvd_inst", VCPU_STAT(resvd_inst_exits), KVM_STAT_VCPU }, - { "break_inst", VCPU_STAT(break_inst_exits), KVM_STAT_VCPU }, - { "trap_inst", VCPU_STAT(trap_inst_exits), KVM_STAT_VCPU }, - { "msa_fpe", VCPU_STAT(msa_fpe_exits), KVM_STAT_VCPU }, - { "fpe", VCPU_STAT(fpe_exits), KVM_STAT_VCPU }, - { "msa_disabled", VCPU_STAT(msa_disabled_exits), KVM_STAT_VCPU }, - { "flush_dcache", VCPU_STAT(flush_dcache_exits), KVM_STAT_VCPU }, + { "wait", VCPU_STAT(wait_exits) }, + { "cache", VCPU_STAT(cache_exits) }, + { "signal", VCPU_STAT(signal_exits) }, + { "interrupt", VCPU_STAT(int_exits) }, + { "cop_unusable", VCPU_STAT(cop_unusable_exits) }, + { "tlbmod", VCPU_STAT(tlbmod_exits) }, + { "tlbmiss_ld", VCPU_STAT(tlbmiss_ld_exits) }, + { "tlbmiss_st", VCPU_STAT(tlbmiss_st_exits) }, + { "addrerr_st", VCPU_STAT(addrerr_st_exits) }, + { "addrerr_ld", VCPU_STAT(addrerr_ld_exits) }, + { "syscall", VCPU_STAT(syscall_exits) }, + { "resvd_inst", VCPU_STAT(resvd_inst_exits) }, + { "break_inst", VCPU_STAT(break_inst_exits) }, + { "trap_inst", VCPU_STAT(trap_inst_exits) }, + { "msa_fpe", VCPU_STAT(msa_fpe_exits) }, + { "fpe", VCPU_STAT(fpe_exits) }, + { "msa_disabled", VCPU_STAT(msa_disabled_exits) }, + { "flush_dcache", VCPU_STAT(flush_dcache_exits) }, #ifdef CONFIG_KVM_MIPS_VZ - { "vz_gpsi", VCPU_STAT(vz_gpsi_exits), KVM_STAT_VCPU }, - { "vz_gsfc", VCPU_STAT(vz_gsfc_exits), KVM_STAT_VCPU }, - { "vz_hc", VCPU_STAT(vz_hc_exits), KVM_STAT_VCPU }, - { "vz_grr", VCPU_STAT(vz_grr_exits), KVM_STAT_VCPU }, - { "vz_gva", VCPU_STAT(vz_gva_exits), KVM_STAT_VCPU }, - { "vz_ghfc", VCPU_STAT(vz_ghfc_exits), KVM_STAT_VCPU }, - { "vz_gpa", VCPU_STAT(vz_gpa_exits), KVM_STAT_VCPU }, - { "vz_resvd", VCPU_STAT(vz_resvd_exits), KVM_STAT_VCPU }, + { "vz_gpsi", VCPU_STAT(vz_gpsi_exits) }, + { "vz_gsfc", VCPU_STAT(vz_gsfc_exits) }, + { "vz_hc", VCPU_STAT(vz_hc_exits) }, + { "vz_grr", VCPU_STAT(vz_grr_exits) }, + { "vz_gva", VCPU_STAT(vz_gva_exits) }, + { "vz_ghfc", VCPU_STAT(vz_ghfc_exits) }, + { "vz_gpa", VCPU_STAT(vz_gpa_exits) }, + { "vz_resvd", VCPU_STAT(vz_resvd_exits) }, #endif - { "halt_successful_poll", VCPU_STAT(halt_successful_poll), KVM_STAT_VCPU }, - { "halt_attempted_poll", VCPU_STAT(halt_attempted_poll), KVM_STAT_VCPU }, - { "halt_poll_invalid", VCPU_STAT(halt_poll_invalid), KVM_STAT_VCPU }, - { "halt_wakeup", VCPU_STAT(halt_wakeup), KVM_STAT_VCPU }, + { "halt_successful_poll", VCPU_STAT(halt_successful_poll) }, + { "halt_attempted_poll", VCPU_STAT(halt_attempted_poll) }, + { "halt_poll_invalid", VCPU_STAT(halt_poll_invalid) }, + { "halt_wakeup", VCPU_STAT(halt_wakeup) }, {NULL} }; diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 5690a1f9b976..55cb728ba06e 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -36,9 +36,6 @@ #include "book3s.h" #include "trace.h" -#define VM_STAT(x, ...) offsetof(struct kvm, stat.x), KVM_STAT_VM, ## __VA_ARGS__ -#define VCPU_STAT(x, ...) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU, ## __VA_ARGS__ - /* #define EXIT_DEBUG */ struct kvm_stats_debugfs_item debugfs_entries[] = { diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 6c18ea88fd25..fb8fa7060804 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -35,9 +35,6 @@ unsigned long kvmppc_booke_handlers; -#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM -#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU - struct kvm_stats_debugfs_item debugfs_entries[] = { { "mmio", VCPU_STAT(mmio_exits) }, { "sig", VCPU_STAT(signal_exits) }, diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 19a81024fe16..1a7bf8759750 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -57,9 +57,6 @@ #define VCPU_IRQS_MAX_BUF (sizeof(struct kvm_s390_irq) * \ (KVM_MAX_VCPUS + LOCAL_IRQS)) -#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU -#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM - struct kvm_stats_debugfs_item debugfs_entries[] = { { "userspace_handled", VCPU_STAT(exit_userspace) }, { "exit_null", VCPU_STAT(exit_null) }, diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b8124b562dea..fb035d304004 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -97,9 +97,6 @@ static u64 __read_mostly efer_reserved_bits = ~((u64)EFER_SCE); static u64 __read_mostly cr4_reserved_bits = CR4_RESERVED_BITS; -#define VM_STAT(x, ...) offsetof(struct kvm, stat.x), KVM_STAT_VM, ## __VA_ARGS__ -#define VCPU_STAT(x, ...) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU, ## __VA_ARGS__ - #define KVM_X2APIC_API_VALID_FLAGS (KVM_X2APIC_API_USE_32BIT_IDS | \ KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 6d58beb65454..e02d38c7fff1 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1130,6 +1130,9 @@ struct kvm_stats_debugfs_item { #define KVM_DBGFS_GET_MODE(dbgfs_item) \ ((dbgfs_item)->mode ? (dbgfs_item)->mode : 0644) +#define VM_STAT(x, ...) offsetof(struct kvm, stat.x), KVM_STAT_VM, ## __VA_ARGS__ +#define VCPU_STAT(x, ...) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU, ## __VA_ARGS__ + extern struct kvm_stats_debugfs_item debugfs_entries[]; extern struct dentry *kvm_debugfs_dir; -- 2.17.1