* [PATCH kvm-unit-test] tscdeadline_latency: add option to exit on max latency
@ 2015-02-12 11:30 Marcelo Tosatti
2015-02-12 11:41 ` [PATCH kvm-unit-test v2] " Marcelo Tosatti
0 siblings, 1 reply; 2+ messages in thread
From: Marcelo Tosatti @ 2015-02-12 11:30 UTC (permalink / raw)
To: kvm-devel; +Cc: Luiz Capitulino, Paolo Bonzini
Add option to exit in case latency exceeds a given maximum.
Its useful to test host latency without the complexity of a
guest.
Example command line:
echo 1 > /sys/kernel/debug/tracing/tracing_on; taskset -c 3 qemu-kvm
-enable-kvm -device testdev,chardev=testlog -chardev
file,id=testlog,path=msr.out -display none -serial stdio -kernel
x86/tscdeadline_latency.flat -cpu host -append "200000 10000 120050" >
/tmp/a; echo 0 > /sys/kernel/debug/tracing/tracing_on
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
diff --git a/x86/tscdeadline_latency.c b/x86/tscdeadline_latency.c
index 9f255c0..14ab8c8 100644
--- a/x86/tscdeadline_latency.c
+++ b/x86/tscdeadline_latency.c
@@ -9,6 +9,17 @@
* hist(latency, 50)
*/
+/*
+ * for host tracing of breakmax option:
+ *
+ * # cd /sys/kernel/debug/tracing/
+ * # echo x86-tsc > trace_clock
+ * # echo "kvm_exit kvm_entry kvm_msr" > set_event
+ * # echo "sched_switch $extratracepoints" >> set_event
+ * # echo apic_timer_fn > set_ftrace_filter
+ * # echo "function" > current_tracer
+ */
+
#include "libcflat.h"
#include "apic.h"
#include "vm.h"
@@ -37,6 +48,8 @@ int delta;
#define TABLE_SIZE 10000
u64 table[TABLE_SIZE];
volatile int table_idx;
+volatile int hitmax = 0;
+int breakmax = 0;
static void tsc_deadline_timer_isr(isr_regs_t *regs)
{
@@ -46,6 +59,12 @@ static void tsc_deadline_timer_isr(isr_regs_t *regs)
if (table_idx < TABLE_SIZE && tdt_count > 1)
table[table_idx++] = now - exptime;
+ if (breakmax && tdt_count > 1 && (now - exptime) > breakmax) {
+ hitmax = 1;
+ apic_write(APIC_EOI, 0);
+ return;
+ }
+
exptime = now+delta;
wrmsr(MSR_IA32_TSCDEADLINE, now+delta);
apic_write(APIC_EOI, 0);
@@ -97,16 +116,21 @@ int main(int argc, char **argv)
mask_pic_interrupts();
delta = argc <= 1 ? 200000 : atol(argv[1]);
- size = argc <= 2 ? TABLE_SIZE : atol(argv[1]);
+ size = argc <= 2 ? TABLE_SIZE : atol(argv[2]);
+ breakmax = argc <= 3 ? 0 : atol(argv[3]);
printf("breakmax=%d\n", breakmax);
test_tsc_deadline_timer();
irq_enable();
do {
asm volatile("hlt");
- } while (table_idx < size);
+ } while (!hitmax && table_idx < size);
- for (i = 0; i < size; i++)
+ for (i = 0; i < table_idx; i++) {
+ if (hitmax && i == table_idx-1)
+ printf("hit max: %d < ", breakmax);
printf("latency: %d\n", table[i]);
+ }
return report_summary();
}
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH kvm-unit-test v2] tscdeadline_latency: add option to exit on max latency
2015-02-12 11:30 [PATCH kvm-unit-test] tscdeadline_latency: add option to exit on max latency Marcelo Tosatti
@ 2015-02-12 11:41 ` Marcelo Tosatti
0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2015-02-12 11:41 UTC (permalink / raw)
To: kvm-devel; +Cc: Luiz Capitulino, Paolo Bonzini
v2: fix typo
---
Add option to exit in case latency exceeds a given maximum.
Its useful to test host latency without the complexity of a
guest.
Example command line:
echo 1 > /sys/kernel/debug/tracing/tracing_on; taskset -c 3 qemu-kvm
-enable-kvm -device testdev,chardev=testlog -chardev
file,id=testlog,path=msr.out -display none -serial stdio -kernel
x86/tscdeadline_latency.flat -cpu host -append "200000 10000 120050" >
/tmp/a; echo 0 > /sys/kernel/debug/tracing/tracing_on
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
diff --git a/x86/tscdeadline_latency.c b/x86/tscdeadline_latency.c
index 9f255c0..14ab8c8 100644
--- a/x86/tscdeadline_latency.c
+++ b/x86/tscdeadline_latency.c
@@ -9,6 +9,17 @@
* hist(latency, 50)
*/
+/*
+ * for host tracing of breakmax option:
+ *
+ * # cd /sys/kernel/debug/tracing/
+ * # echo x86-tsc > trace_clock
+ * # echo "kvm_exit kvm_entry kvm_msr" > set_event
+ * # echo "sched_switch $extratracepoints" >> set_event
+ * # echo apic_timer_fn > set_ftrace_filter
+ * # echo "function" > current_tracer
+ */
+
#include "libcflat.h"
#include "apic.h"
#include "vm.h"
@@ -37,6 +48,8 @@ int delta;
#define TABLE_SIZE 10000
u64 table[TABLE_SIZE];
volatile int table_idx;
+volatile int hitmax = 0;
+int breakmax = 0;
static void tsc_deadline_timer_isr(isr_regs_t *regs)
{
@@ -46,6 +59,12 @@ static void tsc_deadline_timer_isr(isr_regs_t *regs)
if (table_idx < TABLE_SIZE && tdt_count > 1)
table[table_idx++] = now - exptime;
+ if (breakmax && tdt_count > 1 && (now - exptime) > breakmax) {
+ hitmax = 1;
+ apic_write(APIC_EOI, 0);
+ return;
+ }
+
exptime = now+delta;
wrmsr(MSR_IA32_TSCDEADLINE, now+delta);
apic_write(APIC_EOI, 0);
@@ -97,16 +116,21 @@ int main(int argc, char **argv)
mask_pic_interrupts();
delta = argc <= 1 ? 200000 : atol(argv[1]);
- size = argc <= 2 ? TABLE_SIZE : atol(argv[1]);
+ size = argc <= 2 ? TABLE_SIZE : atol(argv[2]);
+ breakmax = argc <= 3 ? 0 : atol(argv[3]);
+ printf("breakmax=%d\n", breakmax);
test_tsc_deadline_timer();
irq_enable();
do {
asm volatile("hlt");
- } while (table_idx < size);
+ } while (!hitmax && table_idx < size);
- for (i = 0; i < size; i++)
+ for (i = 0; i < table_idx; i++) {
+ if (hitmax && i == table_idx-1)
+ printf("hit max: %d < ", breakmax);
printf("latency: %d\n", table[i]);
+ }
return report_summary();
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-12 11:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-12 11:30 [PATCH kvm-unit-test] tscdeadline_latency: add option to exit on max latency Marcelo Tosatti
2015-02-12 11:41 ` [PATCH kvm-unit-test v2] " Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox