From patchwork Mon Mar 6 19:01:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13162215 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 5F524C64EC4 for ; Mon, 6 Mar 2023 19:03:34 +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=xkKvf3j5B/bWTnVO5WFUoVpfSwwc7WXETq4+zgvU4Z4=; b=ehk87AMutixSBBN3ADpvYV9fGB H0F4qdbsfWTNeZfEXH2Ddqz3ORl+SYcpmGQPFE4lHRznolT8Y+i4SJUBYB98TIJSixmg9jomJkOlc vddWce5Ul9JlivxjWOrc8Y6xhjTiOuBb/rexvvZtXBcE9yw2YdVNvMZ9+qpdTGjbbl1DYVfwJwl0G oCzknUktXsDmqE8OjJ0pwmAJWZmVyZxs/jHioImblftNJwVznztR3pQD3mtNOXqr3grY0ylRAg571 dlyTAK8RmnL4z1JjOmwEyAnSPi2AB9Su6f8J5usLkIwSMzc1Z5mrdIJ3CCQ0BQxntugBX5np7HcT1 ih9XWvVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG6K-00ERdp-2X; Mon, 06 Mar 2023 19:02:24 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG60-00ERUh-D7 for linux-arm-kernel@lists.infradead.org; Mon, 06 Mar 2023 19:02:08 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id o3-20020a257303000000b00a131264017aso11591723ybc.20 for ; Mon, 06 Mar 2023 11:02:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678129323; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=YtNaR+Rua5pfZ3i1GgJ4+hfSm+WXWk7IiLK4Wtb8+uM=; b=A42BX/LP2I7Yrldf83rjJjVVWP9EY7MIToR2w3fKfHNuwlJilnDlJG9Ga110/MBKfg bANY0GGZpHkSiBa5gtT3zYMm3kqQ6eoCd9XQbU1Nw97OaGmCCVTg5gCJq6SSBEjZs5D2 WXuRcS2VBsFJxrimrp+JQlNpq+OFmS1Ohh71sBzmcc1MXrTW549F5OJ3aZCaRVfQfJrL Xl5df+WIcc/z0GU55ilZ3Am2ARcrEJpAjke5BrZTBJ9d+m4fByyPMgXYOtOtNovF1gQu M0K+F9OgIzJN5j3FpXghI6sTRl0hwMpb0KkZDbWtWBZRE7ORKqG1rS1sA7NOJROAsX6B zrWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678129323; 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=YtNaR+Rua5pfZ3i1GgJ4+hfSm+WXWk7IiLK4Wtb8+uM=; b=3yTsHa3UEYf0PKHgyRnWI/FgPI77z2u+wyC/Lf7UFr2FqmEoWs4LAwLywolhBj+oqE ZZBWYIi/ayNIZ0J3BiEVbwOVLeNvVswHTIh3jm4D1IIrqwyQyi7ilQ/pqfN4QuFL8/fZ Yl1z57rQh20LJFM3eef3WR3vcgljWfKI/b/0pcT5RstSlIQACCGq4GWqNzfKZSx0nWGQ YwXPCU9YWpyaPEG4Sl6FYV4L42s0Op0DZvqFE7krLOb9+MQJ6Yt+fqh4HZN8XpmfFFWf 12I52oo7+gtSgM+OAof7GlsJ5+1hudxHGuIaPqebHwwVcGhZZDOGt2x85JB3l02oWK7O ORww== X-Gm-Message-State: AO0yUKVgPgeqzLPryirlnlh4U2FHntN9oU8Ia+hY8dnbI+rqjd5FpmWo qZhRcnuh0AcKmw8PupJsxEZTGQVqw2A6zw== X-Google-Smtp-Source: AK7set90Igml/rc2W0Ya1hk1eHjjJqlvHrIGVSaZmJTzp6vbZseA2XP1DWQDVsfl/YAYC2c0ne8CFj1tJ7LMiQ== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a81:ad0d:0:b0:52e:b635:5496 with SMTP id l13-20020a81ad0d000000b0052eb6355496mr7126400ywh.2.1678129323101; Mon, 06 Mar 2023 11:02:03 -0800 (PST) Date: Mon, 6 Mar 2023 11:01:54 -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-3-dmatlack@google.com> Subject: [PATCH v2 2/4] KVM: Refactor designated initializer macros for struct _kvm_stats_desc 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_584775_54F780B3 X-CRM114-Status: GOOD ( 11.50 ) 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 Refactor the macros that generate struct _kvm_stats_desc designated initializers to cut down on duplication. No functional change intended. Signed-off-by: David Matlack --- include/linux/kvm_host.h | 75 +++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 02b1151c2753..6673ae757c4e 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1744,47 +1744,42 @@ 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) \ +/* Generates a designated initializer list for a struct _kvm_stats_desc. */ +#define _KVM_STATS_DESC(_struct, _field, _name, _type, _unit, _base, \ + _exponent, _size, _bucket_size) \ +{ \ { \ - { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vm_stat, generic.stat) \ - }, \ - .name = #stat, \ - } -#define VCPU_GENERIC_STATS_DESC(stat, type, unit, base, exp, sz, bsz) \ - { \ - { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vcpu_stat, generic.stat) \ - }, \ - .name = #stat, \ - } -#define VM_STATS_DESC(stat, type, unit, base, exp, sz, bsz) \ - { \ - { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vm_stat, stat) \ - }, \ - .name = #stat, \ - } -#define VCPU_STATS_DESC(stat, type, unit, base, exp, sz, bsz) \ - { \ - { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vcpu_stat, stat) \ - }, \ - .name = #stat, \ - } + .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, \ + .offset = offsetof(_struct, _field), \ + }, \ + .name = _name, \ +} + +#define VM_GENERIC_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ + _KVM_STATS_DESC(struct kvm_vm_stat, generic._stat, #_stat, _type, \ + _unit, _base, _exponent, _size, _bucket_size) + +#define VCPU_GENERIC_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ + _KVM_STATS_DESC(struct kvm_vcpu_stat, generic._stat, #_stat, _type, \ + _unit, _base, _exponent, _size, _bucket_size) + +#define VM_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ + _KVM_STATS_DESC(struct kvm_vm_stat, _stat, #_stat, _type, _unit, \ + _base, _exponent, _size, _bucket_size) + +#define VCPU_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ + _KVM_STATS_DESC(struct kvm_vcpu_stat, _stat, #_stat, _type, _unit, \ + _base, _exponent, _size, _bucket_size) /* SCOPE: VM, VM_GENERIC, VCPU, VCPU_GENERIC */ #define STATS_DESC(SCOPE, stat, type, unit, base, exp, sz, bsz) \