summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-02-06 11:30:27 -0600
committerLouis Burda <quent.burda@gmail.com>2023-02-06 11:30:27 -0600
commit8d018c17170a3b623f48de5282955b817a6284f3 (patch)
tree70c44cfe471771ef2a42933118846c6ab869df11 /test
parent4dd9fe04e1399e8629ab2a98b54db6a7dcdb0076 (diff)
downloadcachepc-8d018c17170a3b623f48de5282955b817a6284f3.tar.gz
cachepc-8d018c17170a3b623f48de5282955b817a6284f3.zip
qemu-targetstep: Attempt to track guest process gfn when running in userspace
Seems like single-stepping the guest with LAPIC influences the guest scheduler behaviour, since just a single step inside the target gfn (to determine if its running in userspace), is enough to for us to never reach the GUEST_STOP_TRACK event. FWICT the single-stepping is not frequent and does not take long enough to justify never reaching the stop event.
Diffstat (limited to 'test')
-rwxr-xr-xtest/.gitignore4
-rw-r--r--test/qemu-targetstep.c (renamed from test/qemu-eviction.c)28
-rw-r--r--test/qemu-targetstep_guest.c (renamed from test/qemu-eviction_guest.c)7
3 files changed, 30 insertions, 9 deletions
diff --git a/test/.gitignore b/test/.gitignore
index cea8b5a..9c69377 100755
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -7,10 +7,10 @@ kvm-step
kvm-step_guest
kvm-pagestep
kvm-pagestep_guest
-qemu-eviction
-qemu-eviction_guest
qemu-pagestep
qemu-aes
qemu-aes_guest
qemu-poc
qemu-poc_guest
+qemu-targetstep
+qemu-targetstep_guest
diff --git a/test/qemu-eviction.c b/test/qemu-targetstep.c
index 2392472..a7345a3 100644
--- a/test/qemu-eviction.c
+++ b/test/qemu-targetstep.c
@@ -17,6 +17,7 @@
static struct cpc_event event;
static struct cpc_event_batch batch;
+static uint64_t last_user_inst_gfn;
int
monitor(bool baseline)
@@ -30,7 +31,7 @@ monitor(bool baseline)
switch (event.type) {
case CPC_EVENT_GUEST:
- printf("Guest event: %i\n", event.guest.type);
+ printf("Guest %s\n", !event.guest.type ? "start" : "stop");
if (event.guest.type == CPC_GUEST_STOP_TRACK)
return 2;
break;
@@ -71,7 +72,14 @@ read_batch(void)
if (batch.buf[i].type != CPC_EVENT_TRACK_PAGE)
continue;
- printf("GFN %08llx\n", batch.buf[i].page.inst_gfn);
+ if (batch.buf[i].page.retinst_user > 0) {
+ printf("GFN %08llx %04x %4llu %4llu\n",
+ batch.buf[i].page.inst_gfn,
+ batch.buf[i].page.fault_err,
+ batch.buf[i].page.retinst,
+ batch.buf[i].page.retinst_user);
+ last_user_inst_gfn = batch.buf[i].page.inst_gfn;
+ }
}
}
@@ -185,8 +193,12 @@ main(int argc, const char **argv)
ret = ioctl(kvm_dev, KVM_CPC_POLL_EVENT, &event);
if (ret && errno == EAGAIN) continue;
if (ret) err(1, "KVM_CPC_POLL_EVENT");
-
- printf("EVENT %i\n", event.type);
+
+ if (event.type == CPC_EVENT_GUEST) {
+ read_batch();
+ printf("Guest %s\n",
+ !event.guest.type ? "start" : "stop");
+ }
if (event.type == CPC_EVENT_GUEST
&& event.guest.type == CPC_GUEST_START_TRACK) {
@@ -207,17 +219,21 @@ main(int argc, const char **argv)
if (!batch.cnt) errx(1, "empty batch buffer");
memset(&cfg, 0, sizeof(cfg));
cfg.mode = CPC_TRACK_STEPS;
- cfg.steps.target_gfn = batch.buf[batch.cnt - 3].page.inst_gfn;
+ cfg.steps.target_gfn = last_user_inst_gfn;
+ cfg.steps.target_user = true;
cfg.steps.use_target = true;
cfg.steps.use_filter = true;
- cfg.steps.with_data = true;
+ //cfg.steps.with_data = true;
ret = ioctl(kvm_dev, KVM_CPC_TRACK_MODE, &cfg);
if (ret) err(1, "KVM_CPC_TRACK_MODE");
ret = ioctl(kvm_dev, KVM_CPC_ACK_EVENT, &event.id);
if (ret) err(1, "KVM_CPC_ACK_EVENT");
+ printf("Target GFN: %08llx\n", cfg.steps.target_gfn);
+
while (monitor(false) != 2);
+ read_batch();
signal(SIGINT, NULL);
diff --git a/test/qemu-eviction_guest.c b/test/qemu-targetstep_guest.c
index 086fee5..9ef36e1 100644
--- a/test/qemu-eviction_guest.c
+++ b/test/qemu-targetstep_guest.c
@@ -2,6 +2,7 @@
#include <sys/time.h>
#include <sys/resource.h>
+#include <errno.h>
#include <err.h>
#include <unistd.h>
#include <stdint.h>
@@ -13,13 +14,17 @@ int
main(int argc, const char **argv)
{
void *buf;
+ int ret;
buf = NULL;
if (posix_memalign(&buf, L1_LINESIZE * L1_SETS, L1_LINESIZE * L1_SETS))
err(1, "memalign");
memset(buf, 0, L1_LINESIZE * L1_SETS);
- setpriority(PRIO_PROCESS, 0, -20);
+ errno = 0;
+ ret = setpriority(PRIO_PROCESS, 0, -20);
+ if (errno) err(1, "setpriority");
+ printf("NICE %i\n", ret);
while (1) {
printf("LOOP\n");