Re: [kvm-unit-tests PATCH 08/17] arm: gic: Add simple SPI MP test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

What does MP stand for in the subject? Multi-processor? I think changing it to SMP
makes more sense, as that is also in the test name that you've added.

On 11/8/19 2:42 PM, Andre Przywara wrote:
> Shared Peripheral Interrupts (SPI) can target a specific CPU. Test this
> feature by routing the test SPI to each of the vCPUs, then triggering it
> and confirm its reception on that requested core.
>
> Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
> ---
>  arm/gic.c | 31 ++++++++++++++++++++++++++++++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/arm/gic.c b/arm/gic.c
> index 63aa9f4..304b7b9 100644
> --- a/arm/gic.c
> +++ b/arm/gic.c
> @@ -620,16 +620,45 @@ static void spi_test_single(void)
>  	check_acked("now enabled SPI fires", &cpumask);
>  }
>  
> +static void spi_test_smp(void)
> +{
> +	int cpu;
> +	int cores = 1;
> +
> +	wait_on_ready();
> +	for_each_present_cpu(cpu) {
> +		if (cpu == smp_processor_id())
> +			continue;
> +		spi_configure_irq(SPI_IRQ, cpu);
> +		if (trigger_and_check_spi(NULL, IRQ_STAT_IRQ, cpu))
> +			cores++;
> +		else
> +			report_info("SPI delivery failed on core %d", cpu);
> +	}
> +	report("SPI delievered on all cores", cores == nr_cpus);
> +}
> +
>  static void spi_send(void)
>  {
>  	irqs_enable();
>  
>  	spi_test_single();
>  
> +	if (nr_cpus > 1)
> +		spi_test_smp();
> +
>  	check_spurious();
>  	exit(report_summary());
>  }
>  
> +static void spi_test(void *data __unused)
> +{
> +	if (smp_processor_id() == 0)
> +		spi_send();
> +	else
> +		irq_recv();
> +}
> +
>  int main(int argc, char **argv)
>  {
>  	if (!gic_init()) {
> @@ -663,7 +692,7 @@ int main(int argc, char **argv)
>  		report_prefix_pop();
>  	} else if (strcmp(argv[1], "irq") == 0) {
>  		report_prefix_push(argv[1]);
> -		spi_send();
> +		on_cpus(spi_test, NULL);

This is a bit strange. You call on_cpus here, which means you assume that you have
more than one CPU, but then you check if you have more than one CPU in spi_send,
which gets executed on CPU 0.

How about this instead (compile tested only):

diff --git a/arm/gic.c b/arm/gic.c
index 63aa9f4a9fda..7d2443b06ffa 100644
--- a/arm/gic.c
+++ b/arm/gic.c
@@ -620,12 +620,42 @@ static void spi_test_single(void)
        check_acked("now enabled SPI fires", &cpumask);
 }
 
-static void spi_send(void)
+static void spi_test_smp(void)
 {
-       irqs_enable();
+       int cpu;
+       int cores = 1;
+
+       for_each_present_cpu(cpu) {
+               if (cpu == smp_processor_id())
+                       continue;
+               smp_boot_secondary(cpu, irq_recv);
+       }
+       wait_on_ready();
 
+       for_each_present_cpu(cpu) {
+               if (cpu == smp_processor_id())
+                       continue;
+               spi_configure_irq(SPI_IRQ, cpu);
+               if (trigger_and_check_spi(NULL, IRQ_STAT_IRQ, cpu))
+                       cores++;
+               else
+                       report_info("SPI delivery failed on core %d", cpu);
+       }
+       report("SPI delievered on all cores", cores == nr_cpus);
+}
+
+static void spi_test(void)
+{
+       irqs_enable();
        spi_test_single();
+       if (nr_cpus == 1) {
+               report_skip("At least 2 cpus required to run the SPI SMP test");
+               goto out;
+       }
+
+       spi_test_smp();
 
+out:
        check_spurious();
        exit(report_summary());
 }
@@ -663,7 +693,7 @@ int main(int argc, char **argv)
                report_prefix_pop();
        } else if (strcmp(argv[1], "irq") == 0) {
                report_prefix_push(argv[1]);
-               spi_send();
+               spi_test();
                report_prefix_pop();
        } else {
                report_abort("Unknown subtest '%s'", argv[1]);

What do you think?

Thanks,
Alex
>  		report_prefix_pop();
>  	} else {
>  		report_abort("Unknown subtest '%s'", argv[1]);
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm




[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux