From: Dan Wu <dan1.wu@intel.com>
To: seanjc@google.com, pbonzini@redhat.com, kvm@vger.kernel.org
Cc: xiaoyao.li@intel.com, dan1.wu@intel.com
Subject: [kvm-unit-tests PATCH v1 3/3] x86/asyncpf: Add CPUID feature bits check to ensure feature is available
Date: Tue, 12 Dec 2023 14:27:08 +0800 [thread overview]
Message-ID: <20231212062708.16509-4-dan1.wu@intel.com> (raw)
In-Reply-To: <20231212062708.16509-1-dan1.wu@intel.com>
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@intel.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
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
next prev parent reply other threads:[~2023-12-12 6:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 6:27 [kvm-unit-tests PATCH v1 0/3] x86: fix async page fault issues Dan Wu
2023-12-12 6:27 ` [kvm-unit-tests PATCH v1 1/3] x86: Add a common header asyncpf.h Dan Wu
2023-12-12 6:27 ` [kvm-unit-tests PATCH v1 2/3] x86: Add async page fault int test Dan Wu
2023-12-12 6:27 ` Dan Wu [this message]
2023-12-12 15:17 ` [kvm-unit-tests PATCH v1 0/3] x86: fix async page fault issues Sean Christopherson
2023-12-13 1:36 ` Wu, Dan1
2023-12-13 18:20 ` Sean Christopherson
2023-12-14 2:32 ` Wu, Dan1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231212062708.16509-4-dan1.wu@intel.com \
--to=dan1.wu@intel.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=xiaoyao.li@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox