This fixes another possible hang of this test when delay is configured too small (e.g., 2000) so that the IRQ handler will trigger forever. Let's stop the timer if we've collected enough data so that the program can quit always. Signed-off-by: Peter Xu <peterx@xxxxxxxxxx> --- x86/tscdeadline_latency.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/x86/tscdeadline_latency.c b/x86/tscdeadline_latency.c index 0a3532d..a63f98b 100644 --- a/x86/tscdeadline_latency.c +++ b/x86/tscdeadline_latency.c @@ -50,18 +50,24 @@ int breakmax = 0; static void tsc_deadline_timer_isr(isr_regs_t *regs) { - u64 now = rdtsc(); + u64 now = rdtsc(), delay; ++tdt_count; - if (table_idx < TABLE_SIZE && tdt_count > 1) - table[table_idx++] = now - exptime; + if (tdt_count == 1) + /* Skip the 1st IRQ */ + goto setup_next; - if (breakmax && tdt_count > 1 && (now - exptime) > breakmax) { - hitmax = 1; + table[table_idx++] = delay = now - exptime; + + /* Stop if either we finished collection or hit max */ + if ((breakmax && delay > breakmax) || table_idx >= TABLE_SIZE) { + if (breakmax) + hitmax = 1; apic_write(APIC_EOI, 0); return; } +setup_next: exptime = now+delta; wrmsr(MSR_IA32_TSCDEADLINE, now+delta); apic_write(APIC_EOI, 0); -- 2.21.0