Re: [kvm-unit-tests PATCH v3 1/1] s390x: add parallel skey migration test

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

 



On Wed, 2022-12-14 at 13:38 +0100, Nico Boehr wrote:
> Right now, we have a test which sets storage keys, then migrates the VM
> and - after migration finished - verifies the skeys are still there.
> 
> Add a new version of the test which changes storage keys while the
> migration is in progress. This is achieved by adding a command line
> argument to the existing migration-skey test.
> 
> Signed-off-by: Nico Boehr <nrb@xxxxxxxxxxxxx>

Reviewed-by: Nina Schoetterl-Glausch <nsg@xxxxxxxxxxxxx>

Indentation should be fixed IMO, feel free to ignore the rest.

> ---
>  s390x/migration-skey.c | 218 +++++++++++++++++++++++++++++++++++++----
>  s390x/unittests.cfg    |  15 ++-
>  2 files changed, 210 insertions(+), 23 deletions(-)
> 
> diff --git a/s390x/migration-skey.c b/s390x/migration-skey.c
> index a91eb6b5a63e..0f862cc9d821 100644
> --- a/s390x/migration-skey.c
> +++ b/s390x/migration-skey.c
> 
[...]

> +/*
> + * Verify storage keys on pagebuf.
> + * Storage keys must have been set by set_test_pattern on pagebuf before.
> + * set_test_pattern must have been called with the same seed value.
> + *
> + * If storage keys match the expected result, will return a verify_result
> + * with verify_failed false. All other fields are then invalid.
> + * If there is a mismatch, returned struct will have verify_failed true and will
> + * be filled with the details on the first mismatch encountered.
> + */
> +static struct verify_result verify_test_pattern(unsigned char seed)
> +{
> +	union skey expected_key, actual_key;
> +	struct verify_result result = {
> +		.verify_failed = true
> +	};
> +	uint8_t *cur_page;
> +	unsigned long i;
>  
>  	for (i = 0; i < NUM_PAGES; i++) {
> -		actual_key.val = get_storage_key(pagebuf[i]);
> -		expected_key.val = i * 2;
> +		cur_page = pagebuf + i * PAGE_SIZE;
> +		actual_key.val = get_storage_key(cur_page);
> +		expected_key.val = (i ^ seed) * 2;
>  
>  		/*
>  		 * The PoP neither gives a guarantee that the reference bit is
> @@ -51,27 +105,153 @@ static void test_migration(void)
>  		actual_key.str.rf = 0;
>  		expected_key.str.rf = 0;
>  
> -		/* don't log anything when key matches to avoid spamming the log */
>  		if (actual_key.val != expected_key.val) {
> -			key_mismatches++;
> -			report_fail("page %d expected_key=0x%x actual_key=0x%x", i, expected_key.val, actual_key.val);

I feel like setting verify_failed here also would be nicer. Could also do
	return (struct verify_result) {
	...
	}
Just a suggestion.
> +			result.expected_key.val = expected_key.val;
> +			result.actual_key.val = actual_key.val;
> +			result.page_mismatch_idx = i;
> +			result.page_mismatch_addr = (unsigned long)cur_page;
> +			return result;
>  		}
>  	}
>  
> -	report(!key_mismatches, "skeys after migration match");
> +	result.verify_failed = false;
> +	return result;
> +}
> +
> +static void report_verify_result(struct verify_result * const result)

Why const? Why not also pointer to const?
> +{
> +	if (result->verify_failed)
> +		report_fail("page skey mismatch: first page idx = %lu, addr = 0x%lx, "
> +			"expected_key = 0x%x, actual_key = 0x%x",

Indent is off here.
I have a slight preference for %02x for the keys. Just a suggestion.

> +			result->page_mismatch_idx, result->page_mismatch_addr,
> +			result->expected_key.val, result->actual_key.val);
> +	else
> +		report_pass("skeys match");
> +}
> +
> 
[...]

> -int main(void)
> +int main(int argc, char **argv)
>  {
>  	report_prefix_push("migration-skey");
>  
> -	if (test_facility(169))
> +	if (test_facility(169)) {
>  		report_skip("storage key removal facility is active");
> -	else
> -		test_migration();
> +		goto error;
> +	}
>  
> -	migrate_once();
> +	parse_args(argc, argv);
> +
> +	switch (arg_test_to_run) {

break statements should be indented.

> +	case TEST_SEQUENTIAL:
> +		test_skey_migration_sequential();
> +	break;
> +	case TEST_PARALLEL:
> +		test_skey_migration_parallel();
> +	break;
> +	default:
> +		print_usage();
> +	break;
> +	}
>  
> +error:
> +	migrate_once();
>  	report_prefix_pop();
>  	return report_summary();
>  }
[...]




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux