kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Eric Auger <eric.auger@redhat.com>
Cc: eric.auger.pro@gmail.com, maz@kernel.org,
	kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org,
	peter.maydell@linaro.org, andre.przywara@arm.com,
	thuth@redhat.com, yuzenghui@huawei.com, alexandru.elisei@arm.com
Subject: Re: [kvm-unit-tests PATCH v3 14/14] arm/arm64: ITS: pending table migration test
Date: Fri, 7 Feb 2020 15:06:27 +0100	[thread overview]
Message-ID: <20200207140627.rikkw5coe7naxssb@kamzik.brq.redhat.com> (raw)
In-Reply-To: <20200128103459.19413-15-eric.auger@redhat.com>

On Tue, Jan 28, 2020 at 11:34:59AM +0100, Eric Auger wrote:
> Add two new migration tests. One testing the migration of
> a topology where collection were unmapped. The second test
> checks the migration of the pending table.
> 
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> 
> ---
> 
> v2 -> v3:
> - tests belong to both its and migration groups
> ---
>  arm/gic.c         | 150 ++++++++++++++++++++++++++++++++++++++++++++++
>  arm/unittests.cfg |  16 +++++
>  2 files changed, 166 insertions(+)
> 
> diff --git a/arm/gic.c b/arm/gic.c
> index fa8626a..ec3dd3a 100644
> --- a/arm/gic.c
> +++ b/arm/gic.c
> @@ -195,6 +195,7 @@ static void lpi_handler(struct pt_regs *regs __unused)
>  	smp_rmb(); /* pairs with wmb in lpi_stats_expect */
>  	lpi_stats.observed.cpu_id = smp_processor_id();
>  	lpi_stats.observed.lpi_id = irqnr;
> +	acked[lpi_stats.observed.cpu_id]++;
>  	smp_wmb(); /* pairs with rmb in check_lpi_stats */
>  }
>  
> @@ -239,6 +240,18 @@ static void secondary_lpi_test(void)
>  	while (1)
>  		wfi();
>  }
> +
> +static void check_lpi_hits(int *expected)
> +{
> +	int i;
> +
> +	for (i = 0; i < nr_cpus; i++) {
> +		if (acked[i] != expected[i])
> +			report(false, "expected %d LPIs on PE #%d, %d observed",
> +			       expected[i], i, acked[i]);

report_info
pass = false

> +		}
> +	report(true, "check LPI on all vcpus");

report(pass, ...);

> +}
>  #endif
>  
>  static void gicv2_ipi_send_self(void)
> @@ -594,6 +607,8 @@ static void gic_test_mmio(void)
>  static void test_its_introspection(void) {}
>  static void test_its_trigger(void) {}
>  static void test_its_migration(void) {}
> +static void test_migrate_unmapped_collection(void) {}
> +static void test_its_pending_migration(void) {}

I'm not sure what's worse. This pile of stubs or one #ifdef in main()
wrapping all the calls.

>  
>  #else /* __arch64__ */
>  
> @@ -666,6 +681,18 @@ static bool its_prerequisites(int nb_cpus)
>  	return false;
>  }
>  
> +static void set_lpi(struct its_device *dev, u32 eventid, u32 physid,
> +		    struct its_collection *col)
> +{
> +	if (!dev || !col)

I don't think col can be null, and this doesn't look like the right place
to check if dev is null.  If we're bothiner to call set_lpi, then I
think we should already expect dev to be good to go.

> +		report_abort("wrong device or collection");
> +
> +	its_send_mapti(dev, physid, eventid, col);
> +
> +	gicv3_lpi_set_config(physid, LPI_PROP_DEFAULT);
> +	its_send_invall(col);
> +}
> +
>  /*
>   * Setup the configuration for those mappings:
>   * dev_id=2 event=20 -> vcpu 3, intid=8195
> @@ -806,6 +833,121 @@ static void test_its_migration(void)
>  	its_send_int(dev7, 255);
>  	check_lpi_stats();
>  }
> +
> +static void test_migrate_unmapped_collection(void)
> +{
> +	struct its_collection *col;
> +	struct its_device *dev2, *dev7;
> +	u8 config;
> +
> +	if (its_setup1())
> +		return;
> +
> +	col = its_create_collection(nr_cpus - 1, nr_cpus - 1);
> +	dev2 = its_get_device(2);
> +	dev7 = its_get_device(7);
> +
> +	/* MAPTI with the collection unmapped */
> +	set_lpi(dev2, 0, 8192, col);
> +
> +	puts("Now migrate the VM, then press a key to continue...\n");
> +	(void)getchar();
> +	report(true, "Migration complete");

report_info

> +
> +	/* on the destination, map the collection */
> +	its_send_mapc(col, true);
> +
> +	lpi_stats_expect(2, 8196);
> +	its_send_int(dev7, 255);
> +	check_lpi_stats();
> +
> +	config = gicv3_lpi_get_config(8192);
> +	report(config == LPI_PROP_DEFAULT,
> +	       "Config of LPI 8192 was properly migrated");
> +
> +	lpi_stats_expect(nr_cpus - 1, 8192);
> +	its_send_int(dev2, 0);
> +	check_lpi_stats();
> +
> +	/* unmap the collection */
> +	its_send_mapc(col, false);
> +
> +	lpi_stats_expect(-1, -1);
> +	its_send_int(dev2, 0);
> +	check_lpi_stats();
> +
> +	/* remap event 0 onto lpiid 8193 */
> +	set_lpi(dev2, 0, 8193, col);
> +	lpi_stats_expect(-1, -1);
> +	its_send_int(dev2, 0);
> +	check_lpi_stats();
> +
> +	/* remap the collection */
> +	its_send_mapc(col, true);
> +	lpi_stats_expect(nr_cpus - 1, 8193);
> +}
> +
> +static void test_its_pending_migration(void)
> +{
> +	struct its_device *dev;
> +	struct its_collection *collection[2];
> +	int expected[NR_CPUS];

expected = malloc(nr_cpus * sizeof(int));

I know there are other places using NR_CPUS right now that don't have to,
but we shouldn't add more. Eventually I'll change the other places too.

> +	u64 pendbaser;
> +	void *ptr;
> +	int i;
> +
> +	if (its_prerequisites(4))
> +		return;
> +
> +	dev = its_create_device(2 /* dev id */, 8 /* nb_ites */);
> +	its_send_mapd(dev, true);
> +
> +	collection[0] = its_create_collection(nr_cpus - 1, nr_cpus - 1);
> +	collection[1] = its_create_collection(nr_cpus - 2, nr_cpus - 2);
> +	its_send_mapc(collection[0], true);
> +	its_send_mapc(collection[1], true);
> +
> +	/* disable lpi at redist level */
> +	gicv3_lpi_rdist_ctrl(nr_cpus - 1, false);
> +	gicv3_lpi_rdist_ctrl(nr_cpus - 2, false);
> +
> +	/* even lpis are assigned to even cpu */
> +	for (i = 0; i < 256; i++) {
> +		struct its_collection *col = i % 2 ? collection[0] :
> +						     collection[1];
> +		int vcpu = col->target_address >> 16;

I'm lost with the even/odd (nr_cpus - 1)/(nr_cpus - 2) stuff, and won't
it swap if nr_cpus is odd vs. even?

Shouldn't we just have something like

  pe1 = nr_cpus - 1;
  pe2 = nr_cpus - 2;
  col1 = its_create_collection(pe1, pe1);
  col2 = its_create_collection(pe2, pe2);

without mentioning even and odd?

> +
> +		its_send_mapti(dev, 8192 + i, i, col);
> +		gicv3_lpi_set_config(8192 + i, LPI_PROP_DEFAULT);
> +		gicv3_lpi_set_pending_table_bit(vcpu, 8192 + i, true);
> +	}
> +	its_send_invall(collection[0]);
> +	its_send_invall(collection[1]);
> +
> +	/* Set the PTZ bit on each pendbaser */
> +
> +	expected[nr_cpus - 1] = 128;
> +	expected[nr_cpus - 2] = 128;
> +
> +	ptr = gicv3_data.redist_base[nr_cpus - 1] + GICR_PENDBASER;
> +	pendbaser = readq(ptr);
> +	writeq(pendbaser & ~GICR_PENDBASER_PTZ, ptr);
> +
> +	ptr = gicv3_data.redist_base[nr_cpus - 2] + GICR_PENDBASER;
> +	pendbaser = readq(ptr);
> +	writeq(pendbaser & ~GICR_PENDBASER_PTZ, ptr);
> +
> +	gicv3_lpi_rdist_ctrl(nr_cpus - 1, true);
> +	gicv3_lpi_rdist_ctrl(nr_cpus - 2, true);
> +
> +	puts("Now migrate the VM, then press a key to continue...\n");
> +	(void)getchar();
> +	report(true, "Migration complete");

report_info

> +
> +	mdelay(1000);

This delay needs a comment explaining why it's here.

> +
> +	check_lpi_hits(expected);
> +}
>  #endif
>  
>  int main(int argc, char **argv)
> @@ -847,6 +989,14 @@ int main(int argc, char **argv)
>  		report_prefix_push(argv[1]);
>  		test_its_migration();
>  		report_prefix_pop();
> +	} else if (!strcmp(argv[1], "its-pending-migration")) {
> +		report_prefix_push(argv[1]);
> +		test_its_pending_migration();
> +		report_prefix_pop();
> +	} else if (!strcmp(argv[1], "its-migrate-unmapped-collection")) {
> +		report_prefix_push(argv[1]);
> +		test_migrate_unmapped_collection();
> +		report_prefix_pop();
>  	} else if (strcmp(argv[1], "its-introspection") == 0) {
>  		report_prefix_push(argv[1]);
>  		test_its_introspection();
> diff --git a/arm/unittests.cfg b/arm/unittests.cfg
> index 8b8ec79..d917157 100644
> --- a/arm/unittests.cfg
> +++ b/arm/unittests.cfg
> @@ -144,6 +144,22 @@ extra_params = -machine gic-version=3 -append 'its-migration'
>  groups = its migration
>  arch = arm64
>  
> +[its-pending-migration]
> +file = gic.flat
> +smp = $MAX_SMP
> +accel = kvm
> +extra_params = -machine gic-version=3 -append 'its-pending-migration'
> +groups = its migration
> +arch = arm64
> +
> +[its-migrate-unmapped-collection]
> +file = gic.flat
> +smp = $MAX_SMP
> +accel = kvm
> +extra_params = -machine gic-version=3 -append 'its-migrate-unmapped-collection'
> +groups = its migration
> +arch = arm64
> +
>  # Test PSCI emulation
>  [psci]
>  file = psci.flat
> -- 
> 2.20.1
> 
>

Thanks,
drew 


  reply	other threads:[~2020-02-07 14:06 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-28 10:34 [kvm-unit-tests PATCH v3 00/14] arm/arm64: Add ITS tests Eric Auger
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 01/14] libcflat: Add other size defines Eric Auger
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 02/14] arm: gic: Provide per-IRQ helper functions Eric Auger
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 03/14] arm/arm64: gic: Introduce setup_irq() helper Eric Auger
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 04/14] arm/arm64: gicv3: Add some re-distributor defines Eric Auger
2020-02-06 14:35   ` Zenghui Yu
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 05/14] arm/arm64: ITS: Introspection tests Eric Auger
2020-02-06 15:12   ` Zenghui Yu
2020-02-07 10:19   ` Andrew Jones
2020-03-04 14:20     ` Auger Eric
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 06/14] arm/arm64: gicv3: Set the LPI config and pending tables Eric Auger
2020-02-07  2:12   ` Zenghui Yu
2020-03-05 19:40     ` Auger Eric
2020-02-07 12:11   ` Andrew Jones
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 07/14] arm/arm64: gicv3: Enable/Disable LPIs at re-distributor level Eric Auger
2020-02-07 12:14   ` Andrew Jones
2020-02-07 12:19     ` Andrew Jones
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 08/14] arm/arm64: ITS: its_enable_defaults Eric Auger
2020-02-07  3:20   ` Zenghui Yu
2020-03-04 14:26     ` Auger Eric
2020-03-05  6:30       ` Zenghui Yu
2020-02-07 12:41   ` Andrew Jones
2020-03-05 17:59     ` Auger Eric
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 09/14] arm/arm64: ITS: Device and collection Initialization Eric Auger
2020-02-07  5:41   ` Zenghui Yu
2020-03-05 19:42     ` Auger Eric
2020-02-07 12:51   ` Andrew Jones
2020-03-06  8:47     ` Auger Eric
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 10/14] arm/arm64: ITS: commands Eric Auger
2020-02-07 13:37   ` Andrew Jones
2020-03-06  9:13     ` Auger Eric
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 11/14] arm/arm64: ITS: INT functional tests Eric Auger
2020-02-07 13:15   ` Andrew Jones
2020-03-06 12:55     ` Auger Eric
2020-03-06 13:29       ` Andrew Jones
2020-03-06 13:40         ` Auger Eric
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 12/14] arm/run: Allow Migration tests Eric Auger
2020-01-29  8:07   ` Thomas Huth
2020-01-29  9:29     ` Auger Eric
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 13/14] arm/arm64: ITS: migration tests Eric Auger
2020-02-07 13:49   ` Andrew Jones
2020-03-06 13:06     ` Auger Eric
2020-01-28 10:34 ` [kvm-unit-tests PATCH v3 14/14] arm/arm64: ITS: pending table migration test Eric Auger
2020-02-07 14:06   ` Andrew Jones [this message]
2020-03-06 13:21     ` Auger Eric
2020-03-06 13:36       ` Andrew Jones
2020-03-06 13:41         ` Auger Eric

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200207140627.rikkw5coe7naxssb@kamzik.brq.redhat.com \
    --to=drjones@redhat.com \
    --cc=alexandru.elisei@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=eric.auger@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=maz@kernel.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).