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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux