Thread (32 messages) 32 messages, 5 authors, 2021-06-14

Re: [PATCH v7 2/4] KVM: stats: Add fd-based API to read binary stats data

From: Paolo Bonzini <pbonzini@redhat.com>
Date: 2021-06-10 16:42:18
Also in: kvm, kvmarm, linux-kselftest, linux-s390

On 03/06/21 23:14, Jing Zhang wrote:
+struct _kvm_stats_header {
+	__u32 name_size;
+	__u32 count;
+	__u32 desc_offset;
+	__u32 data_offset;
+};
+
Keeping this struct in sync with kvm_stats_header is a bit messy.  If 
you move the id at the end of the header, however, you can use the same 
trick with the zero-sized array that you used for _kvm_stats_desc.
+struct kvm_vm_stats_data {
+	unsigned long value[0];
+};
+
I posted the patch to switch the VM statistics to 64-bit; you can rebase 
on top of it.
+#define KVM_GET_STATS_FD  _IOR(KVMIO,  0xcc, struct kvm_stats_header)
This should be _IO(KVMIO, 0xcc) since it does not have an argument.
+#define STATS_DESC(stat, type, unit, scale, exp)			       \
+	{								       \
+		{							       \
+			.flags = type | unit | scale,			       \
+			.exponent = exp,				       \
+			.size = 1					       \
+		},							       \
+		.name = stat,						       \
Here you can use

	type | BUILD_BUG_ON_ZERO(type & ~KVM_STATS_TYPE_MASK) |
	unit | BUILD_BUG_ON_ZERO(unit & ~KVM_STATS_UNIT_MASK) |
	scale | BUILD_BUG_ON_ZERO(scale & ~KVM_STATS_SCALE_MASK) |

to get a little bit of type checking.

Paolo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help