This patch add a test to measure the latency of IPI injection. Signed-off-by: Jingyi Wang <wangjingyi11@xxxxxxxxxx> --- arm/gic.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/arm/gic.c b/arm/gic.c index fcf4c1f..f5e830e 100644 --- a/arm/gic.c +++ b/arm/gic.c @@ -27,6 +27,9 @@ struct gic { struct { void (*send_self)(void); void (*send_broadcast)(void); + u64 ipi_inject_time; + u64 ipi_receive_time[NR_CPUS]; + int nr_records; } ipi; }; @@ -142,6 +145,7 @@ static void check_irqnr(u32 irqnr) static void ipi_handler(struct pt_regs *regs __unused) { + gic->ipi.ipi_receive_time[gic->ipi.nr_records++] = get_cntvct(); u32 irqstat = gic_read_iar(); u32 irqnr = gic_iar_irqnr(irqstat); @@ -187,9 +191,16 @@ static void ipi_test_self(void) stats_reset(); cpumask_clear(&mask); cpumask_set_cpu(smp_processor_id(), &mask); + + gic->ipi.nr_records = 0; + gic->ipi.ipi_inject_time = get_cntvct(); gic->ipi.send_self(); + check_acked("IPI: self", &mask); report_prefix_pop(); + + report_info("The latency of ipi_test_self: %ld cycles", + gic->ipi.ipi_receive_time[0] - gic->ipi.ipi_inject_time); } static void ipi_test_smp(void) @@ -202,17 +213,33 @@ static void ipi_test_smp(void) cpumask_copy(&mask, &cpu_present_mask); for (i = smp_processor_id() & 1; i < nr_cpus; i += 2) cpumask_clear_cpu(i, &mask); + + gic->ipi.nr_records = 0; + gic->ipi.ipi_inject_time = get_cntvct(); gic_ipi_send_mask(IPI_IRQ, &mask); + check_acked("IPI: directed", &mask); report_prefix_pop(); + for (i = 0; i < gic->ipi.nr_records; i++) + report_info("The latency of ipi_test_smp(directed): %ld cycles", + gic->ipi.ipi_receive_time[i] - gic->ipi.ipi_inject_time); + report_prefix_push("broadcast"); stats_reset(); cpumask_copy(&mask, &cpu_present_mask); cpumask_clear_cpu(smp_processor_id(), &mask); + + gic->ipi.nr_records = 0; + gic->ipi.ipi_inject_time = get_cntvct(); gic->ipi.send_broadcast(); + check_acked("IPI: broadcast", &mask); report_prefix_pop(); + + for (i = 0; i < gic->ipi.nr_records; i++) + report_info("The latency of ipi_test_smp(broadcast): %ld cycles", + gic->ipi.ipi_receive_time[i] - gic->ipi.ipi_inject_time); } static void ipi_enable(void) -- 2.19.1 _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm