From patchwork Wed Jan 18 17:52:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13106761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04CDDC32793 for ; Wed, 18 Jan 2023 17:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbjARRxQ (ORCPT ); Wed, 18 Jan 2023 12:53:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbjARRxI (ORCPT ); Wed, 18 Jan 2023 12:53:08 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 937F74AA7C for ; Wed, 18 Jan 2023 09:53:07 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id p204-20020a2574d5000000b007f1def880b0so5503137ybc.10 for ; Wed, 18 Jan 2023 09:53:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Xxm/orB7LUO4GbG3GXDW9zqBQZYJZAY27FDyiH6MiwU=; b=WhEOyvhdwbIBkXwCJqOo7JOsZ+49EE4uRplRC8Tnxu3ELQMlKr/meSG9pzssds8q7f /uiYaQIH6Di9d/XO/XkKw8jBqL9R871EWSWtVMe6s4VFHHOUD2v06rKkyXp9RPED2YP9 wC58FNnVn2mXwFrEiQXoA6hcn2Y4as/HfHBpYSVCJKYKNbtFqFHJWOaPHM/HcUkKpzpC IZ+mWyZ+mWY4CEWOzgBP+RM4SZGEoiZND26R7tcP0XCwaMfpeoT/zQfb+rRvg22QbC0C aGKn7d6Den6pBwb0DRKqrZG8PMxrO1qx4V7iEjQI7ynzZtgytDGZKOF9i6JKUXiiarUo miFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Xxm/orB7LUO4GbG3GXDW9zqBQZYJZAY27FDyiH6MiwU=; b=JmzW2sS/P0VJMKWx7y3NF/Jlvqk8BR7v4MVo/ZM7v2p9yOHh4LKoLrjgFsUaVpDiqk 44hjNXKkiu3rsL/JX6CEpIqHdNHXCdez9E1q2yfyUB6OK7/Kosl0DANjQkDiih2cHQPQ chI77m3JbSV/u2Iab90EWv20yoxby/0md0Yewab4sZXMeNFOxasgexzjgc8xoeSFfFSZ dEdpedOuSLww6wK5fDzr+JHf2sbXfpztDBP3/0HbwfTMzheIwZJx3RWSZgXNzR/i0sS4 5zR7c4jNgWALYZxKFpogsHUfS8nYv/Gpjv7QIU+n07v1URhC71WXTAhUgwF9M67c3aF3 DrKQ== X-Gm-Message-State: AFqh2kp/+mjCX0RUQZbK/qGoKZu1nmjf+m3VcrCLnd75DCxnDCRlbMT5 x/ajbw4AW2MU0ORRv/Q/xDFJJP1HjLp8Zg== X-Google-Smtp-Source: AMrXdXuJvato0uhpkPkbFNJCZbzmev1u5D+kL5lpxK0ZLR3cqt+l1BD9MTkr8KqIgz7MtHcOs+k02lKiZgsWzA== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a0d:d90c:0:b0:4d7:cc6f:f8db with SMTP id b12-20020a0dd90c000000b004d7cc6ff8dbmr1009459ywe.509.1674064386021; Wed, 18 Jan 2023 09:53:06 -0800 (PST) Date: Wed, 18 Jan 2023 09:52:56 -0800 In-Reply-To: <20230118175300.790835-1-dmatlack@google.com> Mime-Version: 1.0 References: <20230118175300.790835-1-dmatlack@google.com> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog Message-ID: <20230118175300.790835-2-dmatlack@google.com> Subject: [PATCH 1/5] KVM: Consistently use "stat" name in stats macros From: David Matlack To: Paolo Bonzini Cc: Sean Christopherson , kvm@vger.kernel.org, David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Consistently use "stat" instead of a mix of "stat" and "name" in the various KVM stats macros. This improves the readability, and also enables a future commit to add a separate "name" parameter. No functional change intended. Signed-off-by: David Matlack --- include/linux/kvm_host.h | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 109b18e2789c..e0f21bf8ff72 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1789,55 +1789,55 @@ struct _kvm_stats_desc { #define STATS_DESC(SCOPE, stat, type, unit, base, exp, sz, bsz) \ SCOPE##_STATS_DESC(stat, type, unit, base, exp, sz, bsz) -#define STATS_DESC_CUMULATIVE(SCOPE, name, unit, base, exponent) \ - STATS_DESC(SCOPE, name, KVM_STATS_TYPE_CUMULATIVE, \ +#define STATS_DESC_CUMULATIVE(SCOPE, stat, unit, base, exponent) \ + STATS_DESC(SCOPE, stat, KVM_STATS_TYPE_CUMULATIVE, \ unit, base, exponent, 1, 0) -#define STATS_DESC_INSTANT(SCOPE, name, unit, base, exponent) \ - STATS_DESC(SCOPE, name, KVM_STATS_TYPE_INSTANT, \ +#define STATS_DESC_INSTANT(SCOPE, stat, unit, base, exponent) \ + STATS_DESC(SCOPE, stat, KVM_STATS_TYPE_INSTANT, \ unit, base, exponent, 1, 0) -#define STATS_DESC_PEAK(SCOPE, name, unit, base, exponent) \ - STATS_DESC(SCOPE, name, KVM_STATS_TYPE_PEAK, \ +#define STATS_DESC_PEAK(SCOPE, stat, unit, base, exponent) \ + STATS_DESC(SCOPE, stat, KVM_STATS_TYPE_PEAK, \ unit, base, exponent, 1, 0) -#define STATS_DESC_LINEAR_HIST(SCOPE, name, unit, base, exponent, sz, bsz) \ - STATS_DESC(SCOPE, name, KVM_STATS_TYPE_LINEAR_HIST, \ +#define STATS_DESC_LINEAR_HIST(SCOPE, stat, unit, base, exponent, sz, bsz) \ + STATS_DESC(SCOPE, stat, KVM_STATS_TYPE_LINEAR_HIST, \ unit, base, exponent, sz, bsz) -#define STATS_DESC_LOG_HIST(SCOPE, name, unit, base, exponent, sz) \ - STATS_DESC(SCOPE, name, KVM_STATS_TYPE_LOG_HIST, \ +#define STATS_DESC_LOG_HIST(SCOPE, stat, unit, base, exponent, sz) \ + STATS_DESC(SCOPE, stat, KVM_STATS_TYPE_LOG_HIST, \ unit, base, exponent, sz, 0) /* Cumulative counter, read/write */ -#define STATS_DESC_COUNTER(SCOPE, name) \ - STATS_DESC_CUMULATIVE(SCOPE, name, KVM_STATS_UNIT_NONE, \ +#define STATS_DESC_COUNTER(SCOPE, stat) \ + STATS_DESC_CUMULATIVE(SCOPE, stat, KVM_STATS_UNIT_NONE, \ KVM_STATS_BASE_POW10, 0) /* Instantaneous counter, read only */ -#define STATS_DESC_ICOUNTER(SCOPE, name) \ - STATS_DESC_INSTANT(SCOPE, name, KVM_STATS_UNIT_NONE, \ +#define STATS_DESC_ICOUNTER(SCOPE, stat) \ + STATS_DESC_INSTANT(SCOPE, stat, KVM_STATS_UNIT_NONE, \ KVM_STATS_BASE_POW10, 0) /* Peak counter, read/write */ -#define STATS_DESC_PCOUNTER(SCOPE, name) \ - STATS_DESC_PEAK(SCOPE, name, KVM_STATS_UNIT_NONE, \ +#define STATS_DESC_PCOUNTER(SCOPE, stat) \ + STATS_DESC_PEAK(SCOPE, stat, KVM_STATS_UNIT_NONE, \ KVM_STATS_BASE_POW10, 0) /* Instantaneous boolean value, read only */ -#define STATS_DESC_IBOOLEAN(SCOPE, name) \ - STATS_DESC_INSTANT(SCOPE, name, KVM_STATS_UNIT_BOOLEAN, \ +#define STATS_DESC_IBOOLEAN(SCOPE, stat) \ + STATS_DESC_INSTANT(SCOPE, stat, KVM_STATS_UNIT_BOOLEAN, \ KVM_STATS_BASE_POW10, 0) /* Peak (sticky) boolean value, read/write */ -#define STATS_DESC_PBOOLEAN(SCOPE, name) \ - STATS_DESC_PEAK(SCOPE, name, KVM_STATS_UNIT_BOOLEAN, \ +#define STATS_DESC_PBOOLEAN(SCOPE, stat) \ + STATS_DESC_PEAK(SCOPE, stat, KVM_STATS_UNIT_BOOLEAN, \ KVM_STATS_BASE_POW10, 0) /* Cumulative time in nanosecond */ -#define STATS_DESC_TIME_NSEC(SCOPE, name) \ - STATS_DESC_CUMULATIVE(SCOPE, name, KVM_STATS_UNIT_SECONDS, \ +#define STATS_DESC_TIME_NSEC(SCOPE, stat) \ + STATS_DESC_CUMULATIVE(SCOPE, stat, KVM_STATS_UNIT_SECONDS, \ KVM_STATS_BASE_POW10, -9) /* Linear histogram for time in nanosecond */ -#define STATS_DESC_LINHIST_TIME_NSEC(SCOPE, name, sz, bsz) \ - STATS_DESC_LINEAR_HIST(SCOPE, name, KVM_STATS_UNIT_SECONDS, \ +#define STATS_DESC_LINHIST_TIME_NSEC(SCOPE, stat, sz, bsz) \ + STATS_DESC_LINEAR_HIST(SCOPE, stat, KVM_STATS_UNIT_SECONDS, \ KVM_STATS_BASE_POW10, -9, sz, bsz) /* Logarithmic histogram for time in nanosecond */ -#define STATS_DESC_LOGHIST_TIME_NSEC(SCOPE, name, sz) \ - STATS_DESC_LOG_HIST(SCOPE, name, KVM_STATS_UNIT_SECONDS, \ +#define STATS_DESC_LOGHIST_TIME_NSEC(SCOPE, stat, sz) \ + STATS_DESC_LOG_HIST(SCOPE, stat, KVM_STATS_UNIT_SECONDS, \ KVM_STATS_BASE_POW10, -9, sz) #define KVM_GENERIC_VM_STATS() \ From patchwork Wed Jan 18 17:52:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13106762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C5FBC32793 for ; Wed, 18 Jan 2023 17:53:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230095AbjARRxX (ORCPT ); Wed, 18 Jan 2023 12:53:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230147AbjARRxJ (ORCPT ); Wed, 18 Jan 2023 12:53:09 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E3504ED35 for ; Wed, 18 Jan 2023 09:53:08 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-4c8e781bc0aso322282387b3.22 for ; Wed, 18 Jan 2023 09:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=y/aQGEWhRuKhdU97tjUDWVkirnC+I4AXp7DO2Wsa4lo=; b=XB/p1AALtI3X6uMMPvWkOozCAOCgk7D+y2dD88nHIrKGVLH7+GMDLhpuw20+r46Chw XpVFNY0K+3PpyjWpDh0HP4zveVwARtmDS/SLUyWSlOiSB6ZbtSqnk9iWxmCdSk7UVUzM +nJXXTMQp+MCiX9f7kEBr/3FP/opoGzUpmuxS7lGih51URv7jFRJNyeRaDMx6OYa62E/ AM4Pm6VHuS/QLdkkSSKihT/Ap/YWJNBdOICM+OQdr2ENnshLtyRbIZuHj3F+RmQOKdxp kNfTIHXhEtnOCGrN9CcCWMQa/TFn08Yot6EN5L/89Zh/6fPTNt8Mv/3WaPVJh1Rv7Vi/ K3wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=y/aQGEWhRuKhdU97tjUDWVkirnC+I4AXp7DO2Wsa4lo=; b=VrMEWpLLtoeK+M2Op3AndXW0oprARiR4pjmMSdh45xtagKwrrYgxmTRem/k5KjppJ/ 56+G1Y3NzVh20gN4Fz9ZLo9judC2fqa92m505JuiwbU7bIJHlnW/oZX+FJKjFD4QNbeS ntp5zQDgHTSA+saBL1FSoxuT6qwGrWZ6VZMlavZabxvTQSWZYmVObyt1NB3HSwcT36Wu Q+CKuLPPcLjj+g9GPB5iEXN8kY4YDg8kW2Q3KcggLoufXy798GRkbOL8TUVQTEmXHdF8 EC9TKylCCAtC0dUHPIBKUzJKFs/limNAp2khlWDmu/mjG0zDc1RcldKgD1hYuF8KJ3zB cgSA== X-Gm-Message-State: AFqh2kpo8fVP6y2YbbfvnQ00a2e3uPoldLVkYWWsV+jifREqU2PDUzpS f6OlI0GVk8coeOkDvgfERtMc4TYS42AJnw== X-Google-Smtp-Source: AMrXdXupYn9/EOVE+uCqOkz9ARFLJbZM9eXjDoFO9rf0yqlHYPP6TuDXjwwLqlNKNkjlHAAz2w2agcziAZDptA== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a0d:dd88:0:b0:391:4ea8:d99 with SMTP id g130-20020a0ddd88000000b003914ea80d99mr1026327ywe.441.1674064387874; Wed, 18 Jan 2023 09:53:07 -0800 (PST) Date: Wed, 18 Jan 2023 09:52:57 -0800 In-Reply-To: <20230118175300.790835-1-dmatlack@google.com> Mime-Version: 1.0 References: <20230118175300.790835-1-dmatlack@google.com> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog Message-ID: <20230118175300.790835-3-dmatlack@google.com> Subject: [PATCH 2/5] KVM: Spell out parameter names in stats macros From: David Matlack To: Paolo Bonzini Cc: Sean Christopherson , kvm@vger.kernel.org, David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Spell out the parameter names in the various KVM stats macros. This increases readability (e.g. _bucket_size vs. bsz). Opportunistically add an underscore to all the macro parameter names for consistency. Since these macros generate designated initializers, the underscores are important to avoid clashing with field names. No functional change intended. Signed-off-by: David Matlack --- include/linux/kvm_host.h | 134 +++++++++++++++++++++------------------ 1 file changed, 73 insertions(+), 61 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index e0f21bf8ff72..7ce196d69f64 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1744,101 +1744,113 @@ struct _kvm_stats_desc { char name[KVM_STATS_NAME_SIZE]; }; -#define STATS_DESC_COMMON(type, unit, base, exp, sz, bsz) \ - .flags = type | unit | base | \ - BUILD_BUG_ON_ZERO(type & ~KVM_STATS_TYPE_MASK) | \ - BUILD_BUG_ON_ZERO(unit & ~KVM_STATS_UNIT_MASK) | \ - BUILD_BUG_ON_ZERO(base & ~KVM_STATS_BASE_MASK), \ - .exponent = exp, \ - .size = sz, \ - .bucket_size = bsz - -#define VM_GENERIC_STATS_DESC(stat, type, unit, base, exp, sz, bsz) \ +#define STATS_DESC_COMMON(_type, _unit, _base, _exponent, _size, _bucket_size) \ + .flags = _type | _unit | _base | \ + BUILD_BUG_ON_ZERO(_type & ~KVM_STATS_TYPE_MASK) | \ + BUILD_BUG_ON_ZERO(_unit & ~KVM_STATS_UNIT_MASK) | \ + BUILD_BUG_ON_ZERO(_base & ~KVM_STATS_BASE_MASK), \ + .exponent = _exponent, \ + .size = _size, \ + .bucket_size = _bucket_size + +#define VM_GENERIC_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ { \ { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vm_stat, generic.stat) \ + STATS_DESC_COMMON(_type, _unit, _base, _exponent, \ + _size, _bucket_size), \ + .offset = offsetof(struct kvm_vm_stat, generic._stat) \ }, \ - .name = #stat, \ + .name = #_stat, \ } -#define VCPU_GENERIC_STATS_DESC(stat, type, unit, base, exp, sz, bsz) \ +#define VCPU_GENERIC_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ { \ { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vcpu_stat, generic.stat) \ + STATS_DESC_COMMON(_type, _unit, _base, _exponent, \ + _size, _bucket_size), \ + .offset = \ + offsetof(struct kvm_vcpu_stat, generic._stat) \ }, \ - .name = #stat, \ + .name = #_stat, \ } -#define VM_STATS_DESC(stat, type, unit, base, exp, sz, bsz) \ +#define VM_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ { \ { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vm_stat, stat) \ + STATS_DESC_COMMON(_type, _unit, _base, _exponent, \ + _size, _bucket_size), \ + .offset = offsetof(struct kvm_vm_stat, _stat) \ }, \ - .name = #stat, \ + .name = #_stat, \ } -#define VCPU_STATS_DESC(stat, type, unit, base, exp, sz, bsz) \ +#define VCPU_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ { \ { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vcpu_stat, stat) \ + STATS_DESC_COMMON(_type, _unit, _base, _exponent, \ + _size, _bucket_size), \ + .offset = offsetof(struct kvm_vcpu_stat, _stat) \ }, \ - .name = #stat, \ + .name = #_stat, \ } /* SCOPE: VM, VM_GENERIC, VCPU, VCPU_GENERIC */ -#define STATS_DESC(SCOPE, stat, type, unit, base, exp, sz, bsz) \ - SCOPE##_STATS_DESC(stat, type, unit, base, exp, sz, bsz) - -#define STATS_DESC_CUMULATIVE(SCOPE, stat, unit, base, exponent) \ - STATS_DESC(SCOPE, stat, KVM_STATS_TYPE_CUMULATIVE, \ - unit, base, exponent, 1, 0) -#define STATS_DESC_INSTANT(SCOPE, stat, unit, base, exponent) \ - STATS_DESC(SCOPE, stat, KVM_STATS_TYPE_INSTANT, \ - unit, base, exponent, 1, 0) -#define STATS_DESC_PEAK(SCOPE, stat, unit, base, exponent) \ - STATS_DESC(SCOPE, stat, KVM_STATS_TYPE_PEAK, \ - unit, base, exponent, 1, 0) -#define STATS_DESC_LINEAR_HIST(SCOPE, stat, unit, base, exponent, sz, bsz) \ - STATS_DESC(SCOPE, stat, KVM_STATS_TYPE_LINEAR_HIST, \ - unit, base, exponent, sz, bsz) -#define STATS_DESC_LOG_HIST(SCOPE, stat, unit, base, exponent, sz) \ - STATS_DESC(SCOPE, stat, KVM_STATS_TYPE_LOG_HIST, \ - unit, base, exponent, sz, 0) +#define STATS_DESC(SCOPE, _stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ + SCOPE##_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) + +#define STATS_DESC_CUMULATIVE(SCOPE, _stat, _unit, _base, exponent) \ + STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_CUMULATIVE, \ + _unit, _base, exponent, 1, 0) +#define STATS_DESC_INSTANT(SCOPE, _stat, _unit, _base, exponent) \ + STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_INSTANT, \ + _unit, _base, exponent, 1, 0) +#define STATS_DESC_PEAK(SCOPE, _stat, _unit, _base, exponent) \ + STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_PEAK, \ + _unit, _base, exponent, 1, 0) +#define STATS_DESC_LINEAR_HIST(SCOPE, _stat, _unit, _base, exponent, _size, \ + _bucket_size) \ + STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_LINEAR_HIST, \ + _unit, _base, exponent, _size, _bucket_size) +#define STATS_DESC_LOG_HIST(SCOPE, _stat, _unit, _base, exponent, _size) \ + STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_LOG_HIST, \ + _unit, _base, exponent, _size, 0) /* Cumulative counter, read/write */ -#define STATS_DESC_COUNTER(SCOPE, stat) \ - STATS_DESC_CUMULATIVE(SCOPE, stat, KVM_STATS_UNIT_NONE, \ +#define STATS_DESC_COUNTER(SCOPE, _stat) \ + STATS_DESC_CUMULATIVE(SCOPE, _stat, KVM_STATS_UNIT_NONE, \ KVM_STATS_BASE_POW10, 0) /* Instantaneous counter, read only */ -#define STATS_DESC_ICOUNTER(SCOPE, stat) \ - STATS_DESC_INSTANT(SCOPE, stat, KVM_STATS_UNIT_NONE, \ +#define STATS_DESC_ICOUNTER(SCOPE, _stat) \ + STATS_DESC_INSTANT(SCOPE, _stat, KVM_STATS_UNIT_NONE, \ KVM_STATS_BASE_POW10, 0) /* Peak counter, read/write */ -#define STATS_DESC_PCOUNTER(SCOPE, stat) \ - STATS_DESC_PEAK(SCOPE, stat, KVM_STATS_UNIT_NONE, \ +#define STATS_DESC_PCOUNTER(SCOPE, _stat) \ + STATS_DESC_PEAK(SCOPE, _stat, KVM_STATS_UNIT_NONE, \ KVM_STATS_BASE_POW10, 0) /* Instantaneous boolean value, read only */ -#define STATS_DESC_IBOOLEAN(SCOPE, stat) \ - STATS_DESC_INSTANT(SCOPE, stat, KVM_STATS_UNIT_BOOLEAN, \ +#define STATS_DESC_IBOOLEAN(SCOPE, _stat) \ + STATS_DESC_INSTANT(SCOPE, _stat, KVM_STATS_UNIT_BOOLEAN, \ KVM_STATS_BASE_POW10, 0) /* Peak (sticky) boolean value, read/write */ -#define STATS_DESC_PBOOLEAN(SCOPE, stat) \ - STATS_DESC_PEAK(SCOPE, stat, KVM_STATS_UNIT_BOOLEAN, \ +#define STATS_DESC_PBOOLEAN(SCOPE, _stat) \ + STATS_DESC_PEAK(SCOPE, _stat, KVM_STATS_UNIT_BOOLEAN, \ KVM_STATS_BASE_POW10, 0) /* Cumulative time in nanosecond */ -#define STATS_DESC_TIME_NSEC(SCOPE, stat) \ - STATS_DESC_CUMULATIVE(SCOPE, stat, KVM_STATS_UNIT_SECONDS, \ +#define STATS_DESC_TIME_NSEC(SCOPE, _stat) \ + STATS_DESC_CUMULATIVE(SCOPE, _stat, KVM_STATS_UNIT_SECONDS, \ KVM_STATS_BASE_POW10, -9) /* Linear histogram for time in nanosecond */ -#define STATS_DESC_LINHIST_TIME_NSEC(SCOPE, stat, sz, bsz) \ - STATS_DESC_LINEAR_HIST(SCOPE, stat, KVM_STATS_UNIT_SECONDS, \ - KVM_STATS_BASE_POW10, -9, sz, bsz) +#define STATS_DESC_LINHIST_TIME_NSEC(SCOPE, _stat, _size, _bucket_size) \ + STATS_DESC_LINEAR_HIST(SCOPE, _stat, KVM_STATS_UNIT_SECONDS, \ + KVM_STATS_BASE_POW10, -9, _size, _bucket_size) /* Logarithmic histogram for time in nanosecond */ -#define STATS_DESC_LOGHIST_TIME_NSEC(SCOPE, stat, sz) \ - STATS_DESC_LOG_HIST(SCOPE, stat, KVM_STATS_UNIT_SECONDS, \ - KVM_STATS_BASE_POW10, -9, sz) +#define STATS_DESC_LOGHIST_TIME_NSEC(SCOPE, _stat, _size) \ + STATS_DESC_LOG_HIST(SCOPE, _stat, KVM_STATS_UNIT_SECONDS, \ + KVM_STATS_BASE_POW10, -9, _size) #define KVM_GENERIC_VM_STATS() \ STATS_DESC_COUNTER(VM_GENERIC, remote_tlb_flush), \ From patchwork Wed Jan 18 17:52:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13106763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A5B8C38147 for ; Wed, 18 Jan 2023 17:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229607AbjARRxZ (ORCPT ); Wed, 18 Jan 2023 12:53:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230181AbjARRxM (ORCPT ); Wed, 18 Jan 2023 12:53:12 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA484DE0A for ; Wed, 18 Jan 2023 09:53:10 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id w14-20020a25ac0e000000b007d519140f18so12938045ybi.3 for ; Wed, 18 Jan 2023 09:53:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=yQJqGyKMVZBnVtnX5pQVog8PyIcLu+fjz+wxKZGn5E8=; b=o+82nZCzxGaEG+l0JTCDWWE0LucXLNOrsxfPruiVK24eCoCK4joFkAF94zkhfI9+hY F0bwoj67XoJAMZcEwS/ptOnbO34LnQ2sA5d9t+sR+MHATaXuhrdfuW79aadb7xLKoisb a8NRDE3oPQPMkXFIbn2PmGzvc9tQDXTi6Uln4hTkEgG4rYP03SHLZGxdD51fhTMLH51A cU42c87J+WVSKgOUj99ZVnofaz57hWd6gTOhi6WDflEnlQFHkUYYb/AOXC9v731urbl9 0aogSoGGWESuSA4TOwMPIj2HcazdbFC2DIO/93TJBPRXhfa3WjfWseyNPfS6q6rvXrON r78A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=yQJqGyKMVZBnVtnX5pQVog8PyIcLu+fjz+wxKZGn5E8=; b=A3KVMV9bLTVUhFtZpK+LLrCihiSyhfxmc5KNK3nkUTG3wQb46r0CkrZUcA6vTp/OlA YwbzjEAby9djl8iAMpKnvRycC/h5Yx8h/4PzK45fUBj8sbsFR2xfwhvG7GZfstQR3vl6 TkOPrAKpDOHUucS3aN8Qhf8QnDwkoLHTIvQzkLN9SsVYwK1G76mBAnhQhYlQ6tQRyGkN V4hbaF02H0Y2/M7dhytI6v+2fjbCM0SKIsZmGZCwDnRjVipWpSAsVEM28vsA0GyOed57 qOcA1Y3vUsu5zBKbOi1OWdUvi9rPoiWcT2iWSZjZXk9kMS73ROWOwWE8bHofWrU0UO4E omww== X-Gm-Message-State: AFqh2kp4l1smCAFXq34lup3otpL+tMDN9C2OpkLnlMW+Qq+P6vHZOXIe BYma0CuP0xJa6oDYC+NDQt6azmzCkhRG8A== X-Google-Smtp-Source: AMrXdXvC7yXxhjAj3GmMBrxMAtaDLYpi3mTEq23uqtP464YKWjMUEWuhcMWdGtuyZstMYNt2oetaf1SgshV12A== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a25:d809:0:b0:74e:c305:653e with SMTP id p9-20020a25d809000000b0074ec305653emr1012866ybg.113.1674064389484; Wed, 18 Jan 2023 09:53:09 -0800 (PST) Date: Wed, 18 Jan 2023 09:52:58 -0800 In-Reply-To: <20230118175300.790835-1-dmatlack@google.com> Mime-Version: 1.0 References: <20230118175300.790835-1-dmatlack@google.com> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog Message-ID: <20230118175300.790835-4-dmatlack@google.com> Subject: [PATCH 3/5] KVM: Fix indentation in stats macros From: David Matlack To: Paolo Bonzini Cc: Sean Christopherson , kvm@vger.kernel.org, David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Fix the indentation in the various stats macros so that parameter lists that are split across lines are aligned with the open parenthesis on the previous line. No functional change intended. Signed-off-by: David Matlack --- include/linux/kvm_host.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 7ce196d69f64..cceb159727b5 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1802,55 +1802,55 @@ struct _kvm_stats_desc { #define STATS_DESC_CUMULATIVE(SCOPE, _stat, _unit, _base, exponent) \ STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_CUMULATIVE, \ - _unit, _base, exponent, 1, 0) + _unit, _base, exponent, 1, 0) #define STATS_DESC_INSTANT(SCOPE, _stat, _unit, _base, exponent) \ STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_INSTANT, \ - _unit, _base, exponent, 1, 0) + _unit, _base, exponent, 1, 0) #define STATS_DESC_PEAK(SCOPE, _stat, _unit, _base, exponent) \ STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_PEAK, \ - _unit, _base, exponent, 1, 0) + _unit, _base, exponent, 1, 0) #define STATS_DESC_LINEAR_HIST(SCOPE, _stat, _unit, _base, exponent, _size, \ _bucket_size) \ STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_LINEAR_HIST, \ - _unit, _base, exponent, _size, _bucket_size) + _unit, _base, exponent, _size, _bucket_size) #define STATS_DESC_LOG_HIST(SCOPE, _stat, _unit, _base, exponent, _size) \ STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_LOG_HIST, \ - _unit, _base, exponent, _size, 0) + _unit, _base, exponent, _size, 0) /* Cumulative counter, read/write */ #define STATS_DESC_COUNTER(SCOPE, _stat) \ STATS_DESC_CUMULATIVE(SCOPE, _stat, KVM_STATS_UNIT_NONE, \ - KVM_STATS_BASE_POW10, 0) + KVM_STATS_BASE_POW10, 0) /* Instantaneous counter, read only */ #define STATS_DESC_ICOUNTER(SCOPE, _stat) \ STATS_DESC_INSTANT(SCOPE, _stat, KVM_STATS_UNIT_NONE, \ - KVM_STATS_BASE_POW10, 0) + KVM_STATS_BASE_POW10, 0) /* Peak counter, read/write */ #define STATS_DESC_PCOUNTER(SCOPE, _stat) \ STATS_DESC_PEAK(SCOPE, _stat, KVM_STATS_UNIT_NONE, \ - KVM_STATS_BASE_POW10, 0) + KVM_STATS_BASE_POW10, 0) /* Instantaneous boolean value, read only */ #define STATS_DESC_IBOOLEAN(SCOPE, _stat) \ STATS_DESC_INSTANT(SCOPE, _stat, KVM_STATS_UNIT_BOOLEAN, \ - KVM_STATS_BASE_POW10, 0) + KVM_STATS_BASE_POW10, 0) /* Peak (sticky) boolean value, read/write */ #define STATS_DESC_PBOOLEAN(SCOPE, _stat) \ STATS_DESC_PEAK(SCOPE, _stat, KVM_STATS_UNIT_BOOLEAN, \ - KVM_STATS_BASE_POW10, 0) + KVM_STATS_BASE_POW10, 0) /* Cumulative time in nanosecond */ #define STATS_DESC_TIME_NSEC(SCOPE, _stat) \ STATS_DESC_CUMULATIVE(SCOPE, _stat, KVM_STATS_UNIT_SECONDS, \ - KVM_STATS_BASE_POW10, -9) + KVM_STATS_BASE_POW10, -9) /* Linear histogram for time in nanosecond */ #define STATS_DESC_LINHIST_TIME_NSEC(SCOPE, _stat, _size, _bucket_size) \ STATS_DESC_LINEAR_HIST(SCOPE, _stat, KVM_STATS_UNIT_SECONDS, \ - KVM_STATS_BASE_POW10, -9, _size, _bucket_size) + KVM_STATS_BASE_POW10, -9, _size, _bucket_size) /* Logarithmic histogram for time in nanosecond */ #define STATS_DESC_LOGHIST_TIME_NSEC(SCOPE, _stat, _size) \ STATS_DESC_LOG_HIST(SCOPE, _stat, KVM_STATS_UNIT_SECONDS, \ - KVM_STATS_BASE_POW10, -9, _size) + KVM_STATS_BASE_POW10, -9, _size) #define KVM_GENERIC_VM_STATS() \ STATS_DESC_COUNTER(VM_GENERIC, remote_tlb_flush), \ From patchwork Wed Jan 18 17:52:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13106764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5275C38147 for ; Wed, 18 Jan 2023 17:53:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbjARRx3 (ORCPT ); Wed, 18 Jan 2023 12:53:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbjARRxM (ORCPT ); Wed, 18 Jan 2023 12:53:12 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 659C04AA7C for ; Wed, 18 Jan 2023 09:53:11 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id q9-20020a17090a304900b00226e84c4880so14690212pjl.4 for ; Wed, 18 Jan 2023 09:53:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eLQ7+1VQS0cnnGkFkJF2+BG9BNqWWsu6xKEgIL21Bxk=; b=H1vFFmoUYuI5vo6OHlxhe/Tr92InVnObougeDuC2X8uxNmFi3r1PD9w5SMxZQX5UH/ ES6nxOBUAd+Q+eNnpmIvh014clJP1z9z2buEQ1MxubhmYGQuNTsqTRw45Fo8O/cTQZus BKUt26F1qaszKfAhruboQH779o0Y92KAmRTWRAA8hJlRarn8XmyWJj59itQlbPc00XRD B2EA7jG5IIA2et8FUbb1zeh6KoccFy5Jf2VWqp7xaOAGB1ZXnjpY3Wn/y9bH5jx6Rh1K W7zhp4Y9lZX8EtlDNCxqSM6pqBfNT4gPH05/XFDToknHOnH84DivC6vrDMwn079Zp6Kr 12VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=eLQ7+1VQS0cnnGkFkJF2+BG9BNqWWsu6xKEgIL21Bxk=; b=s2Td3ouMxjQN89KJdES70UWR7gSk+oVT5N5H5apSYEjPJpenqSPCHp7R4ElKpliibz WNSJmT0c19lqSMLapu+rwLhee5ugvI3GFDlTwemyz75a3wjAKHPyx60J0HyhVRu04rSI NW8pr9Gq4BxHo1Ko9H7fls6ebJwxTnxurHC5e2q3TpcM9ObcgAZUN4r02xEBkmbdG3Qr +pEUEPDJZrhkOTUs7HHGwnLmeGuQh+1T7o06DtKqv9rIQ9E8IebFpFRIBHwq+991mazB XQpFEbxU5LcyM2R9MujO5P09MaQUaEdUzYTod//6DXkq4W09MxD89ry0/4ZR7vtDKA/u 3tHg== X-Gm-Message-State: AFqh2koGOajJpTIn0YkQaKPlW0iaZcHBmgMtFmvNj16897nHrp+zmb2O YrEg4LFT3KG+8VerK9EPJAWvNo4hhvNeMA== X-Google-Smtp-Source: AMrXdXtakeitXu8drONjerlJUIDenxKRRsZYSOoLlORelDRvY/VQ0QWBghyfH9sVjkWoToU5RaOGqcz6+K7Gag== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a63:2707:0:b0:477:c8ea:b734 with SMTP id n7-20020a632707000000b00477c8eab734mr513332pgn.294.1674064390885; Wed, 18 Jan 2023 09:53:10 -0800 (PST) Date: Wed, 18 Jan 2023 09:52:59 -0800 In-Reply-To: <20230118175300.790835-1-dmatlack@google.com> Mime-Version: 1.0 References: <20230118175300.790835-1-dmatlack@google.com> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog Message-ID: <20230118175300.790835-5-dmatlack@google.com> Subject: [PATCH 4/5] KVM: Allow custom names for stats From: David Matlack To: Paolo Bonzini Cc: Sean Christopherson , kvm@vger.kernel.org, David Matlack , Jing Zhang Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Allow custom names to be specified for stats by providing inner macros that allow passing a custom name. e.g. STATS_DESC_COUNTER(VM, foo), __STATS_DESC_COUNTER(VM, bar, "custom_name") Custom name support enables decoupling the userspace-visible stat names from their internal representation in C. This can allow future commits to refactor the various stats structs without impacting userspace tools that read KVM stats. This also allows stats to be stored in data structures such as arrays, without needing unions to access specific stats. For example, the union for pages_{4k,2m,1g} is no longer necessary. At Google, we have several other out-of-tree stats that would benefit from this support. Support for stat names could be added incrementally (as needed) for all the different STAT_DESC_*() macros. But doing it all at once avoids future churn and ensures the different stat macros have a consistent interface for specifying the name. No functional change intended. Link: https://lore.kernel.org/all/20211019000459.3163029-1-jingzhangos@google.com/ Suggested-by: Jing Zhang Signed-off-by: David Matlack --- include/linux/kvm_host.h | 104 ++++++++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 40 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index cceb159727b5..5e37acc2e80e 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1753,18 +1753,18 @@ struct _kvm_stats_desc { .size = _size, \ .bucket_size = _bucket_size -#define VM_GENERIC_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ - _bucket_size) \ +#define VM_GENERIC_STATS_DESC(_stat, _type, _name, _unit, _base, _exponent, \ + _size, _bucket_size) \ { \ { \ STATS_DESC_COMMON(_type, _unit, _base, _exponent, \ _size, _bucket_size), \ .offset = offsetof(struct kvm_vm_stat, generic._stat) \ }, \ - .name = #_stat, \ + .name = _name, \ } -#define VCPU_GENERIC_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ - _bucket_size) \ +#define VCPU_GENERIC_STATS_DESC(_stat, _type, _name, _unit, _base, _exponent, \ + _size, _bucket_size) \ { \ { \ STATS_DESC_COMMON(_type, _unit, _base, _exponent, \ @@ -1772,9 +1772,9 @@ struct _kvm_stats_desc { .offset = \ offsetof(struct kvm_vcpu_stat, generic._stat) \ }, \ - .name = #_stat, \ + .name = _name, \ } -#define VM_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ +#define VM_STATS_DESC(_stat, _type, _name, _unit, _base, _exponent, _size, \ _bucket_size) \ { \ { \ @@ -1782,9 +1782,9 @@ struct _kvm_stats_desc { _size, _bucket_size), \ .offset = offsetof(struct kvm_vm_stat, _stat) \ }, \ - .name = #_stat, \ + .name = _name, \ } -#define VCPU_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ +#define VCPU_STATS_DESC(_stat, _type, _name, _unit, _base, _exponent, _size, \ _bucket_size) \ { \ { \ @@ -1792,65 +1792,89 @@ struct _kvm_stats_desc { _size, _bucket_size), \ .offset = offsetof(struct kvm_vcpu_stat, _stat) \ }, \ - .name = #_stat, \ + .name = _name, \ } /* SCOPE: VM, VM_GENERIC, VCPU, VCPU_GENERIC */ -#define STATS_DESC(SCOPE, _stat, _type, _unit, _base, _exponent, _size, \ +#define STATS_DESC(SCOPE, _stat, _name, _type, _unit, _base, _exponent, _size, \ _bucket_size) \ - SCOPE##_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ - _bucket_size) + SCOPE##_STATS_DESC(_stat, _type, _name, _unit, _base, _exponent, \ + _size, _bucket_size) \ -#define STATS_DESC_CUMULATIVE(SCOPE, _stat, _unit, _base, exponent) \ - STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_CUMULATIVE, \ +#define STATS_DESC_CUMULATIVE(SCOPE, _stat, _name, _unit, _base, exponent) \ + STATS_DESC(SCOPE, _stat, _name, KVM_STATS_TYPE_CUMULATIVE, \ _unit, _base, exponent, 1, 0) -#define STATS_DESC_INSTANT(SCOPE, _stat, _unit, _base, exponent) \ - STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_INSTANT, \ +#define STATS_DESC_INSTANT(SCOPE, _stat, _name, _unit, _base, exponent) \ + STATS_DESC(SCOPE, _stat, _name, KVM_STATS_TYPE_INSTANT, \ _unit, _base, exponent, 1, 0) -#define STATS_DESC_PEAK(SCOPE, _stat, _unit, _base, exponent) \ - STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_PEAK, \ +#define STATS_DESC_PEAK(SCOPE, _stat, _name, _unit, _base, exponent) \ + STATS_DESC(SCOPE, _stat, _name, KVM_STATS_TYPE_PEAK, \ _unit, _base, exponent, 1, 0) -#define STATS_DESC_LINEAR_HIST(SCOPE, _stat, _unit, _base, exponent, _size, \ - _bucket_size) \ - STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_LINEAR_HIST, \ +#define STATS_DESC_LINEAR_HIST(SCOPE, _stat, _name, _unit, _base, exponent, \ + _size, _bucket_size) \ + STATS_DESC(SCOPE, _stat, _name, KVM_STATS_TYPE_LINEAR_HIST, \ _unit, _base, exponent, _size, _bucket_size) -#define STATS_DESC_LOG_HIST(SCOPE, _stat, _unit, _base, exponent, _size) \ - STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_LOG_HIST, \ +#define STATS_DESC_LOG_HIST(SCOPE, _stat, _name, _unit, _base, exponent, \ + _size) \ + STATS_DESC(SCOPE, _stat, _name, KVM_STATS_TYPE_LOG_HIST, \ _unit, _base, exponent, _size, 0) /* Cumulative counter, read/write */ -#define STATS_DESC_COUNTER(SCOPE, _stat) \ - STATS_DESC_CUMULATIVE(SCOPE, _stat, KVM_STATS_UNIT_NONE, \ +#define __STATS_DESC_COUNTER(SCOPE, _stat, _name) \ + STATS_DESC_CUMULATIVE(SCOPE, _stat, _name, KVM_STATS_UNIT_NONE, \ KVM_STATS_BASE_POW10, 0) +#define STATS_DESC_COUNTER(SCOPE, _stat) \ + __STATS_DESC_COUNTER(SCOPE, _stat, #_stat) + /* Instantaneous counter, read only */ -#define STATS_DESC_ICOUNTER(SCOPE, _stat) \ - STATS_DESC_INSTANT(SCOPE, _stat, KVM_STATS_UNIT_NONE, \ +#define __STATS_DESC_ICOUNTER(SCOPE, _stat, _name) \ + STATS_DESC_INSTANT(SCOPE, _stat, _name, KVM_STATS_UNIT_NONE, \ KVM_STATS_BASE_POW10, 0) +#define STATS_DESC_ICOUNTER(SCOPE, _stat) \ + __STATS_DESC_ICOUNTER(SCOPE, _stat, #_stat) + /* Peak counter, read/write */ -#define STATS_DESC_PCOUNTER(SCOPE, _stat) \ - STATS_DESC_PEAK(SCOPE, _stat, KVM_STATS_UNIT_NONE, \ +#define __STATS_DESC_PCOUNTER(SCOPE, _stat, _name) \ + STATS_DESC_PEAK(SCOPE, _stat, _name, KVM_STATS_UNIT_NONE, \ KVM_STATS_BASE_POW10, 0) +#define STATS_DESC_PCOUNTER(SCOPE, _stat) \ + __STATS_DESC_PCOUNTER(SCOPE, _stat, #_stat) /* Instantaneous boolean value, read only */ -#define STATS_DESC_IBOOLEAN(SCOPE, _stat) \ - STATS_DESC_INSTANT(SCOPE, _stat, KVM_STATS_UNIT_BOOLEAN, \ +#define __STATS_DESC_IBOOLEAN(SCOPE, _stat, _name) \ + STATS_DESC_INSTANT(SCOPE, _stat, _name, KVM_STATS_UNIT_BOOLEAN, \ KVM_STATS_BASE_POW10, 0) +#define STATS_DESC_IBOOLEAN(SCOPE, _stat) \ + __STATS_DESC_IBOOLEAN(SCOPE, _stat, #_stat) + /* Peak (sticky) boolean value, read/write */ -#define STATS_DESC_PBOOLEAN(SCOPE, _stat) \ - STATS_DESC_PEAK(SCOPE, _stat, KVM_STATS_UNIT_BOOLEAN, \ +#define __STATS_DESC_PBOOLEAN(SCOPE, _stat, _name) \ + STATS_DESC_PEAK(SCOPE, _stat, _name, KVM_STATS_UNIT_BOOLEAN, \ KVM_STATS_BASE_POW10, 0) +#define STATS_DESC_PBOOLEAN(SCOPE, _stat) \ + __STATS_DESC_PBOOLEAN(SOPE, _stat, #_stat) /* Cumulative time in nanosecond */ -#define STATS_DESC_TIME_NSEC(SCOPE, _stat) \ - STATS_DESC_CUMULATIVE(SCOPE, _stat, KVM_STATS_UNIT_SECONDS, \ +#define __STATS_DESC_TIME_NSEC(SCOPE, _stat, _name) \ + STATS_DESC_CUMULATIVE(SCOPE, _stat, _name, KVM_STATS_UNIT_SECONDS, \ KVM_STATS_BASE_POW10, -9) +#define STATS_DESC_TIME_NSEC(SCOPE, _stat) \ + __STATS_DESC_TIME_NSEC(SCOPE, _stat, #_stat) + /* Linear histogram for time in nanosecond */ -#define STATS_DESC_LINHIST_TIME_NSEC(SCOPE, _stat, _size, _bucket_size) \ - STATS_DESC_LINEAR_HIST(SCOPE, _stat, KVM_STATS_UNIT_SECONDS, \ +#define __STATS_DESC_LINHIST_TIME_NSEC(SCOPE, _stat, _name, _size, \ + _bucket_size) \ + STATS_DESC_LINEAR_HIST(SCOPE, _stat, _name, KVM_STATS_UNIT_SECONDS, \ KVM_STATS_BASE_POW10, -9, _size, _bucket_size) +#define STATS_DESC_LINHIST_TIME_NSEC(SCOPE, _stat, _size, _bucket_size) \ + __STATS_DESC_LINHIST_TIME_NSEC(SCOPE, _stat, #_stat, _size, \ + _bucket_size) + /* Logarithmic histogram for time in nanosecond */ -#define STATS_DESC_LOGHIST_TIME_NSEC(SCOPE, _stat, _size) \ - STATS_DESC_LOG_HIST(SCOPE, _stat, KVM_STATS_UNIT_SECONDS, \ +#define __STATS_DESC_LOGHIST_TIME_NSEC(SCOPE, _stat, _name, _size) \ + STATS_DESC_LOG_HIST(SCOPE, _stat, _name, KVM_STATS_UNIT_SECONDS, \ KVM_STATS_BASE_POW10, -9, _size) +#define STATS_DESC_LOGHIST_TIME_NSEC(SCOPE, _stat, _size) \ + __STATS_DESC_LOGHIST_TIME_NSEC(SCOPE, _stat, #_stat, _size) #define KVM_GENERIC_VM_STATS() \ STATS_DESC_COUNTER(VM_GENERIC, remote_tlb_flush), \ From patchwork Wed Jan 18 17:53:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13106765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EA0AC32793 for ; Wed, 18 Jan 2023 17:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229512AbjARRxb (ORCPT ); Wed, 18 Jan 2023 12:53:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbjARRxQ (ORCPT ); Wed, 18 Jan 2023 12:53:16 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D8354DE3D for ; Wed, 18 Jan 2023 09:53:13 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id k135-20020a25248d000000b007d689f92d6dso12408372ybk.22 for ; Wed, 18 Jan 2023 09:53:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=yUbgpWda+dccBvsvErJkX1PAtQUerfBikR5Rk5rhVEE=; b=bU5qpPAsWECyf8Tu1U1RR1RAql4O3IKPordj8Fa72lBuMimqzqCYrcl4rP42ZPh9E3 weFpA8IGGsRUZUr5pjxd/K6JfkGjVDYt3x3gmZ1bNvx7xDo67oFFTfYjLFlSoVbIVTB2 q7Ker8NiVidCQ6lJvI+cWYF0WgB3vgNW6VGma9goSvGedC+H31bpiHILPcVHzHX9mzDs f6UzTIgyGLiON7MwBnqZ2l4P5HNHhqlkQKCewvf1W64c3vHEIf9KkVbQSont6cB0L6Ip gcRMfjl5/N7TSBRe3tGiE1wcJwkloHd+dWTqUqBS2W+t05T+eVBZNpN77X8JUy/ZwU7X LV9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=yUbgpWda+dccBvsvErJkX1PAtQUerfBikR5Rk5rhVEE=; b=YF3eDVd1oKMjgMY6UJYIaZ0EaY9pqT0oRBtwG4elgQrAhpGQm7saKk1J3UuHx3Y2QM ySp/cubKgb1nX3mw0COr+cIgcLMau7acb1kGpQ3PAgRNXgweH4IUqaQH2i+oH1etxcEw l8og/k4YF+a4LsWeORJZs0lYOyXhtDlIt+Av+jgh51paZeDWTrwYAnud/PWX5R6lOhXp dOvbjYp4Gd2Buc6a0E2HyQRPG1rClp7saVCCaPqmp0QYRyndeiVdlYutkGnbJkpUuRz1 YuhK4KSaRPuD91s1aatfVzoWUaWbYuJbWI5pLfomR3T+BQvurEH9Jyl2wSVA9usJeNDB Eshg== X-Gm-Message-State: AFqh2kq5VoBaKoVRBOGHyofQLYqN1buOHKUBfw6aA2b9K9j8iDh8Xm3V uP1YgrbwQHFACl1ljORJOMQE4o0W5FxqTQ== X-Google-Smtp-Source: AMrXdXsSeUOvOwHjz9VyKlCk6Y4tbjdavwcxNKb5cV6TaKCYC6dKVkiarPFDPgfvAAx/jiGsFGnJeITKWCqn4g== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a25:e702:0:b0:6fa:5536:7e2 with SMTP id e2-20020a25e702000000b006fa553607e2mr1232248ybh.295.1674064392516; Wed, 18 Jan 2023 09:53:12 -0800 (PST) Date: Wed, 18 Jan 2023 09:53:00 -0800 In-Reply-To: <20230118175300.790835-1-dmatlack@google.com> Mime-Version: 1.0 References: <20230118175300.790835-1-dmatlack@google.com> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog Message-ID: <20230118175300.790835-6-dmatlack@google.com> Subject: [PATCH 5/5] KVM: x86: Drop union for pages_{4k,2m,1g} stats From: David Matlack To: Paolo Bonzini Cc: Sean Christopherson , kvm@vger.kernel.org, David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Drop the union for the pages_{4k,2m,1g} stats. The union is no longer necessary now that KVM supports choosing a custom name for stats. Eliminating the union also would allow future commits to more easily move pages[] into common code, e.g. if KVM ever gains support for a Common MMU (see Link below). An alternative would be to drop pages[] and have kvm_update_page_stats() update pages_{4k,2m,1g} directly. But that would make it harder to move the page stats logic into common code. No functional change intended. Link: https://lore.kernel.org/kvm/20221208193857.4090582-1-dmatlack@google.com/ Signed-off-by: David Matlack --- arch/x86/include/asm/kvm_host.h | 9 +-------- arch/x86/kvm/x86.c | 6 +++--- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 4d2bc08794e4..4423184070cd 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1457,14 +1457,7 @@ struct kvm_vm_stat { u64 mmu_recycled; u64 mmu_cache_miss; u64 mmu_unsync; - union { - struct { - atomic64_t pages_4k; - atomic64_t pages_2m; - atomic64_t pages_1g; - }; - atomic64_t pages[KVM_NR_PAGE_SIZES]; - }; + atomic64_t pages[KVM_NR_PAGE_SIZES]; u64 nx_lpage_splits; u64 max_mmu_page_hash_collisions; u64 max_mmu_rmap_size; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 508074e47bc0..66dcd4196ab0 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -240,9 +240,9 @@ const struct _kvm_stats_desc kvm_vm_stats_desc[] = { STATS_DESC_COUNTER(VM, mmu_recycled), STATS_DESC_COUNTER(VM, mmu_cache_miss), STATS_DESC_ICOUNTER(VM, mmu_unsync), - STATS_DESC_ICOUNTER(VM, pages_4k), - STATS_DESC_ICOUNTER(VM, pages_2m), - STATS_DESC_ICOUNTER(VM, pages_1g), + __STATS_DESC_ICOUNTER(VM, pages[PG_LEVEL_4K - 1], "pages_4k"), + __STATS_DESC_ICOUNTER(VM, pages[PG_LEVEL_2M - 1], "pages_2m"), + __STATS_DESC_ICOUNTER(VM, pages[PG_LEVEL_1G - 1], "pages_1g"), STATS_DESC_ICOUNTER(VM, nx_lpage_splits), STATS_DESC_PCOUNTER(VM, max_mmu_rmap_size), STATS_DESC_PCOUNTER(VM, max_mmu_page_hash_collisions)