From patchwork Mon Mar 6 19:01:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13162199 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 D76A1C61DA4 for ; Mon, 6 Mar 2023 19:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229876AbjCFTCW (ORCPT ); Mon, 6 Mar 2023 14:02:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbjCFTCU (ORCPT ); Mon, 6 Mar 2023 14:02:20 -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 748CE30290 for ; Mon, 6 Mar 2023 11:02:00 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id o3-20020a257303000000b00a131264017aso11591507ybc.20 for ; Mon, 06 Mar 2023 11:02:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678129319; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=C+DxnQV3hp0RGd+ug96FCObNfG/ILFIXHP4OvcDjXtA=; b=VWgYmSrmEfZIk/6E1VMbGjDaim/LrqhaEaWbHuc+fH+V6S1DKdJkRtZ34FezlMlvhM U6mcoknL3sAYb7G1m+RD4Ig6gMHZ3RTQuTmwizQCiRBj2rGy41IyS90Qy6jvQXVsrewL 9SFoAxeMBzW5t2TD3YILUvsMiBUCUbLVi57NBysGJg1yYn7YuGGMcpOxrx1eRRLBIO55 6Jbb9BwFCYffUcjzVZAFu0HkR94u7+bMfdsXfZ8y0VaWIgzYSxnsXzYIhqkR9LOZ5C0I 6G5p1/Kff9hdoITAYU26Wdj64V3gzTqUAgddrH7mg7Qk+8AvTWLN0NmGqN/B0ffPRXLb 3ITQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678129319; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=C+DxnQV3hp0RGd+ug96FCObNfG/ILFIXHP4OvcDjXtA=; b=jcp/rTLXkPGQiYLxK7ail1U0MvPtadUere1ElIbe4zricuqh93CCliiaP5bUWw+oze apSx9BK3xS49hw0Pd52fIlTXjveTEo4YyNGCB9L1rZTZ0YCu8UXElxflHI4EvWsBy0TO yGwj6mBpE6R+wnMJ5TQHMeq1aHMUK6odYz8kpw9dtwUCb66kVb17fZHMHheX/C9Sce9w KekdaUgu9laFmVU9tdtctmkYW9sz7VT3DfJMgiyAQIVAro/CSqBUpFcY1AcglUVrfmMG SLqe8oFrYkGBKsDpnHSuBo6f6Ix0DElSqfmghEWvYsKiCjJRGfIPRhQTK4pb8cT9ku+p dpCQ== X-Gm-Message-State: AO0yUKW0kybd73YVUZski7/UquweYZ8f6qBji7G8KhT1Y5zafDsIBRkq XV7KM8JBCsEZW5fVIXm7awLeyzqg9WN9Rg== X-Google-Smtp-Source: AK7set/pVosUQpXpF+342Y6QcFu+4eURtJP2+OiNzV4zJi7D/yZ3hybJi6gL3lLKDOrFj5EE1HIssi/eN+VpiA== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a81:b723:0:b0:536:38b4:f51 with SMTP id v35-20020a81b723000000b0053638b40f51mr7493840ywh.5.1678129319569; Mon, 06 Mar 2023 11:01:59 -0800 (PST) Date: Mon, 6 Mar 2023 11:01:52 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230306190156.434452-1-dmatlack@google.com> Subject: [PATCH v2 0/4] KVM: Refactor KVM stats macros and enable custom stat names From: David Matlack To: Paolo Bonzini Cc: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Huacai Chen , Aleksandar Markovic , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Sean Christopherson , Michael Ellerman , Eric Farman , " =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= " , David Matlack , Sathvika Vasireddy , Nicholas Piggin , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org This series refactors the KVM stats macros to reduce duplication and adds the support for choosing custom names for stats. Custom name makes it possible to decouple 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. Case in point, the last patch in this series removes the pages_{4k,2m,1g} union, which is a useful cleanup to prepare for sharing paging code across architectures [1]. And for full transparency, another motivation for this series it that at Google we have several out-of-tree stats that use arrays. Custom name support is something we added internally and it reduces our technical debt to get the support merged upstream. Tested on x86. Compile tested on ARM. Not yet tested on any other architectures. Link: https://lore.kernel.org/kvm/20221208193857.4090582-1-dmatlack@google.com/ v2: - Refactor stat macros (patch 1) to reduce duplication and make it simpler to add custom name support [Sean] v1: https://lore.kernel.org/kvm/20230118175300.790835-1-dmatlack@google.com/ David Matlack (4): KVM: Refactor stats descriptor generation macros KVM: Refactor designated initializer macros for struct _kvm_stats_desc KVM: Allow custom names for KVM_STAT() KVM: x86: Drop union for pages_{4k,2m,1g} stats arch/arm64/kvm/guest.c | 14 +-- arch/mips/kvm/mips.c | 54 ++++----- arch/powerpc/kvm/book3s.c | 62 +++++----- arch/powerpc/kvm/booke.c | 48 ++++---- arch/riscv/kvm/vcpu.c | 16 +-- arch/s390/kvm/kvm-s390.c | 198 ++++++++++++++++---------------- arch/x86/include/asm/kvm_host.h | 9 +- arch/x86/kvm/x86.c | 94 +++++++-------- include/linux/kvm_host.h | 179 +++++++++++------------------ 9 files changed, 314 insertions(+), 360 deletions(-) base-commit: 45dd9bc75d9adc9483f0c7d662ba6e73ed698a0b Reviewed-by: Sean Christopherson Reviewed-by: Oliver Upton