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: 13162214 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54C5CC64EC4 for ; Mon, 6 Mar 2023 19:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=FvZ7EYgSiBYOLJrUl6qSeAPhHT7lmwwDgSBmIdohX8M=; b=zEA NisktU+/m56KORKcdYLpBHel3GR8/XKNkCf7NFGUkDW1/ivRedVThwxgueb9akKk1uVdzvt1kdhZy bFGHSPKCbzdMF9jvQqKLAS6Jff5RKNXbzfahZ9NoHBYv/1twlw+ZmfXnXPPkGdU0nujIvyW08Z1XH qgJJL6cUYIERpaS9t8tpGtk0Xk0JR/lSJMxnD7muQNHEr4513sKGMdBwwZpLfjM/UpT+tceOOZmNV RcdYREkvseJ370HjG6TbJsKCR6+qk0Bm/SrnFwFR2U4gmKHjmIy6MTl96mRD/Z1fdmdvjXmGyuZVF 23MYBJr8wmb0Mk5xLEKZdX01NlQv+gw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG65-00ERYU-PK; Mon, 06 Mar 2023 19:02:10 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG60-00ERTe-4J for linux-arm-kernel@lists.infradead.org; Mon, 06 Mar 2023 19:02:06 +0000 Received: by mail-yb1-xb49.google.com with SMTP id x64-20020a25ce43000000b00ae6d5855d78so11536137ybe.12 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=XXAJ9FTFUE8hkJYiHx7Nng2u75Azs+CCvBp3IJ/18Prv28qJNfavm1RrArwVeE7JkY EuAc/FQYMHJ64HsNxlwwIby3NT42p+WhsohwMRKMwo1grZ1mcf9bqDMnztWmYUrZaqle hKAzsG5Nyf5VEtGyhjlsJ3BTTr7qqpBr08ZPlBzEJ+BKpCBbK4DjbZ5iRx8oglzqvrXA AxxlKKEr+UxjvNYcpOOO8DKQq7Bi6rBHHTdC4zTjIW8ODASQSS82yiLPLspyNwVLQ8MP hLUoWHNmMsNtTYhtU/29hR9GBI/pOqCAJ8M4Cw1wtGiR1mmG/Up36nBBIDKG82Z1JEtU SuYw== X-Gm-Message-State: AO0yUKVBhWmuWa0KFgMoBZwNlZHwzRqkksI6ZqtzZQvEfBvCDqkEE+fZ y1vQv8BH8GI6ud9j2B8zcRJ1UNP6ZS7kqw== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230306_110204_308922_0265E545 X-CRM114-Status: GOOD ( 11.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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