From patchwork Mon Mar 6 19:01: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: 13162218 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 C7268C61DA4 for ; Mon, 6 Mar 2023 19:04:38 +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: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6NCqNHYq/h8HEP5MJcgiRVyovjdWZgXwKkAUEjRmbNA=; b=C5jbBz6lU5KK+04LhDjuVeXKiZ qzRS5PUp6bAMsD9LSJvk2lmxYKqS0/sldvTfNdfzKrM4O//rrlYYmFvi00ykhllzMZavh+nmMkMyn +VBC5nL9N+duZHspomUT5jWgn4f9piDZcOqyatd3aZOz6CiK+OD2nWHHo3fh0iHa4/AdWZlZ+IWk3 9JkjrY8oQ5p2EdFR6tgiozInJ1+X9luhBieZT5/C6E2KoRXNWhKdaYvB1iUcMcMcro71kZwn+uqIK XT8YOtS+t+YsD+GVXstOx4laQeX1jasJwVxCZZ8CwxXNW5kHkdxjJQTeSORo2GwBv1TmbEIy9X6ik 4aLtL4kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG76-00ES66-81; Mon, 06 Mar 2023 19:03:12 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG6C-00ERbK-0P for linux-arm-kernel@bombadil.infradead.org; Mon, 06 Mar 2023 19:02:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Hy1Buh0DyhAQ1dsWc1I6Y0GrKiZLM4ytS70wq/2qiU0=; b=hK58AzGQBxAbfsw6G4kanEQDA1 0sqztLvxyUScj8jQ9sYAv1vP3QZZ8sPyivpu7o0IkZ2O6e5B185w35QNtZ9S9SwV6BtRWZiAEyal/ MkCRfCgnLYGfOw9m7Qbma3vba0pUSaI+iEnYCp4ZmBJARTPLlVCiBLEUHYWBgjRhaO56NNmf0BHk7 +grTpCKEu8pADEh2zO5QLOPvRfDQmSLxYvWYp+HuMkfuUNo1N+de0kaKwCXmSQhrQ3sxQV9ov/rVa o6r4kIwMVQSr9WRLZh2lQUf41ZQ7BBjRdguElI3qR/B35gDFDPSEzXHFLmzrr0r87wNlo7ZZb4QPP 3zNEDgcg==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pZG66-00Glqv-1y for linux-arm-kernel@lists.infradead.org; Mon, 06 Mar 2023 19:02:14 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-536cb268ab8so112433727b3.17 for ; Mon, 06 Mar 2023 11:02:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678129326; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Hy1Buh0DyhAQ1dsWc1I6Y0GrKiZLM4ytS70wq/2qiU0=; b=Letr5LRp7bS0YmkVINmE83RF8//+0ihwPomgSJZC4+dkD9sFUFEL35AQoxcfPpIbXW Y1mVJA34aQ9Fn9+jBPkAovdeUPbAGsum3MVzw575zB3u4rfwK4ZVePdw3VSiVo2j9C9v 3XnoKl7fEhlmtkQ5DdG9/UhFj+tyVjNmSih/iYAuSQ6xwOtYmbjOYgHRAkzFRXa92dze ZQvrRjBbIKvFglVzBDH4EAw30eROHuzuIjsYKsJXNnWsAQHIog+eYwButoAe0B9OxSD2 pOTz7b2aOyFjFOUOaTEw5+7DJRfnksutj0fbq9nxtjgFb7SGFFpwHZTOmxj6KpssL5px NozA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678129326; 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=Hy1Buh0DyhAQ1dsWc1I6Y0GrKiZLM4ytS70wq/2qiU0=; b=REQ0H8mLiP1tEVJJAJ0iEq1uQexTLdiPe8f8QSfYUVf2BVpgGV7EX66EfuTPWH9qpH WUu0JsuT6IOLxWhw4Cne7+/NKfSmZEH6xVxMfGQcVqfcb4d+BpS8dKkvg7MiHwfvr66G s9xojrkMG83kQ1YyV8Mcy3SzbQtR04UypUqUobHfqtRdDkBvpqjlYDeftzYYUJS3DOEQ LAi4VdqX1ynk4exvMyX5CKdiaME3cwVlu4L6+jSJc+eshEsvcQpMVYvJTuCL0V/grRA4 JAzbCTRmfDvLh15Lg8jMdaZArMdC/4ayG/9O6T+jRs1vwqhJG1t/BPLc1TYT1iB07MyC yjuw== X-Gm-Message-State: AO0yUKWs8X5qri4GOZFjUJ7UqSjT0taFhOLb/NO8SAGttRrlHo4mcDGr J6+DLw0E1M2CL7B050DFad4f/uhFzQBVtw== X-Google-Smtp-Source: AK7set9e2oV5ajrE5TnGPzkyECRcuaio2KGOJRsM0L6WhO9k90cawVld9W/AAFXa4Ih5X3b9O+P88E69HqyVhg== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a81:b667:0:b0:534:d71f:14e6 with SMTP id h39-20020a81b667000000b00534d71f14e6mr7365447ywk.9.1678129326079; Mon, 06 Mar 2023 11:02:06 -0800 (PST) Date: Mon, 6 Mar 2023 11:01:56 -0800 In-Reply-To: <20230306190156.434452-1-dmatlack@google.com> Mime-Version: 1.0 References: <20230306190156.434452-1-dmatlack@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230306190156.434452-5-dmatlack@google.com> Subject: [PATCH v2 4/4] KVM: x86: Drop union for pages_{4k,2m,1g} stats 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_190210_782232_5FC52922 X-CRM114-Status: GOOD ( 12.51 ) 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 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 page table code. An alternative would be to drop pages[] and have kvm_update_page_stats() update pages_{4k,2m,1g} directly. But that's not a good direction to go in since other architectures use other page sizes. 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 808c292ad3f4..a59e41355ef4 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1473,14 +1473,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 072f5ba83170..101ad6b7e7b6 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[] = { KVM_STAT(VM, CUMULATIVE, NONE, mmu_recycled), KVM_STAT(VM, CUMULATIVE, NONE, mmu_cache_miss), KVM_STAT(VM, INSTANT, NONE, mmu_unsync), - KVM_STAT(VM, INSTANT, NONE, pages_4k), - KVM_STAT(VM, INSTANT, NONE, pages_2m), - KVM_STAT(VM, INSTANT, NONE, pages_1g), + __KVM_STAT(VM, INSTANT, NONE, pages[PG_LEVEL_4K - 1], "pages_4k"), + __KVM_STAT(VM, INSTANT, NONE, pages[PG_LEVEL_2M - 1], "pages_2m"), + __KVM_STAT(VM, INSTANT, NONE, pages[PG_LEVEL_1G - 1], "pages_1g"), KVM_STAT(VM, INSTANT, NONE, nx_lpage_splits), KVM_STAT(VM, PEAK, NONE, max_mmu_rmap_size), KVM_STAT(VM, PEAK, NONE, max_mmu_page_hash_collisions)