diff mbox series

[2/5] KVM: Spell out parameter names in stats macros

Message ID 20230118175300.790835-3-dmatlack@google.com (mailing list archive)
State New, archived
Headers show
Series KVM: Refactor KVM stats macros to allow custom names | expand

Commit Message

David Matlack Jan. 18, 2023, 5:52 p.m. UTC
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 <dmatlack@google.com>
---
 include/linux/kvm_host.h | 134 +++++++++++++++++++++------------------
 1 file changed, 73 insertions(+), 61 deletions(-)
diff mbox series

Patch

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),		       \