[kvm-unit-tests PATCH v1 3/3] x86/asyncpf: Add CPUID feature bits check to ensure feature is available

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

 



Asyncpf test only works for #PF-based 'page-ready' notification. This case
becomes invalid for KVM that starts to enumerate interrupt-based 'page-ready'
notification.

Add CPUID feature check at the beginning, and skip the test when KVM_FEATURE_ASYNC_PF
is not available or it enumerates KVM_FEATURE_ASYNC_PF_INT.

To run this test, add the QEMU option "-cpu host" to check CPUID, since
KVM_FEATURE_ASYNC_PF_INT can't be detected without "-cpu host".

Update the usage of how to setup cgroup for different cgroup versions.

Signed-off-by: Dan Wu <dan1.wu@xxxxxxxxx>
Reviewed-by: Xiaoyao Li <xiaoyao.li@xxxxxxxxx>
---
Unlike patch #2, this patch retains the original test without reducing the memory
access round from 2 to 1. If anyone thinks it worthes a go, please call out.
---
 x86/asyncpf.c     | 22 ++++++++++++++++++++--
 x86/unittests.cfg |  2 +-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/x86/asyncpf.c b/x86/asyncpf.c
index a0bdefcf..e2cf9934 100644
--- a/x86/asyncpf.c
+++ b/x86/asyncpf.c
@@ -1,18 +1,26 @@
 /*
  * Async PF test. For the test to actually do anything it needs to be started
- * in memory cgroup with 512M of memory and with more then 1G memory provided
+ * in memory cgroup with 512M of memory and with more than 1G memory provided
  * to the guest.
  *
+ * To identify the cgroup version on Linux:
+ * stat -fc %T /sys/fs/cgroup/
+ *
+ * If the output is tmpfs, your system is using cgroup v1:
  * To create cgroup do as root:
  * mkdir /dev/cgroup
  * mount -t cgroup none -omemory /dev/cgroup
  * chmod a+rxw /dev/cgroup/
- *
  * From a shell you will start qemu from:
  * mkdir /dev/cgroup/1
  * echo $$ >  /dev/cgroup/1/tasks
  * echo 512M > /dev/cgroup/1/memory.limit_in_bytes
  *
+ * If the output is cgroup2fs, your system is using cgroup v2:
+ * mkdir /sys/fs/cgroup/cg1
+ * echo $$ >  /sys/fs/cgroup/cg1/cgroup.procs
+ * echo 512M > /sys/fs/cgroup/cg1/memory.max
+ *
  */
 #include "x86/msr.h"
 #include "x86/processor.h"
@@ -79,6 +87,16 @@ static void pf_isr(struct ex_regs *r)
 
 int main(int ac, char **av)
 {
+	if (!this_cpu_has(KVM_FEATURE_ASYNC_PF)) {
+		report_skip("KVM_FEATURE_ASYNC_PF is not supported\n");
+		return report_summary();
+	}
+
+	if (this_cpu_has(KVM_FEATURE_ASYNC_PF_INT)) {
+		report_skip("interrupt-based page-ready event is enumerated, use asyncpf-int instead.\n");
+		return report_summary();
+	}
+
 	int loop = 2;
 
 	setup_vm();
diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index 8735ba34..94a5c7c7 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -172,7 +172,7 @@ extra_params = -cpu max
 
 [asyncpf]
 file = asyncpf.flat
-extra_params = -m 2048
+extra_params = -cpu host -m 2048
 
 [asyncpf_int]
 file = asyncpf_int.flat
-- 
2.39.3





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux