[RFC PATCH 5/5] RISC-V: selftests: Apply which-cpus flag to CBO hwprobe test

Palmer Dabbelt palmer at dabbelt.com
Mon Sep 25 04:23:38 PDT 2023


On Thu, 21 Sep 2023 05:55:24 PDT (-0700), ajones at ventanamicro.com wrote:
> Now that we can efficiently clear cpus from a cpu set that do
> not meet a key-value criteria, apply it to the cpus used in
> the CBO hwprobe selftest, instead of looping over hwprobe.
>
> Signed-off-by: Andrew Jones <ajones at ventanamicro.com>
> ---
>  tools/testing/selftests/riscv/hwprobe/cbo.c | 26 +++++++--------------
>  1 file changed, 9 insertions(+), 17 deletions(-)
>
> diff --git a/tools/testing/selftests/riscv/hwprobe/cbo.c b/tools/testing/selftests/riscv/hwprobe/cbo.c
> index 50a2cc8aef38..375a343bc2c6 100644
> --- a/tools/testing/selftests/riscv/hwprobe/cbo.c
> +++ b/tools/testing/selftests/riscv/hwprobe/cbo.c
> @@ -135,27 +135,19 @@ static void check_no_zicboz_cpus(cpu_set_t *cpus)
>  {
>  	struct riscv_hwprobe pair = {
>  		.key = RISCV_HWPROBE_KEY_IMA_EXT_0,
> +		.value = RISCV_HWPROBE_EXT_ZICBOZ,
>  	};
> -	cpu_set_t one_cpu;
> -	int i = 0, c = 0;
> +	cpu_set_t tmp;
>  	long rc;
>
> -	while (i++ < CPU_COUNT(cpus)) {
> -		while (!CPU_ISSET(c, cpus))
> -			++c;
> -
> -		CPU_ZERO(&one_cpu);
> -		CPU_SET(c, &one_cpu);
> -
> -		rc = riscv_hwprobe(&pair, 1, sizeof(cpu_set_t), (unsigned long *)&one_cpu, 0);
> -		assert(rc == 0 && pair.key == RISCV_HWPROBE_KEY_IMA_EXT_0);
> +	memcpy(&tmp, cpus, sizeof(cpu_set_t));
> +	rc = riscv_hwprobe(&pair, 1, sizeof(cpu_set_t), (unsigned long *)&tmp, RISCV_HWPROBE_WHICH_CPUS);
> +	assert(rc == 0 && pair.key == RISCV_HWPROBE_KEY_IMA_EXT_0);
>
> -		if (pair.value & RISCV_HWPROBE_EXT_ZICBOZ)
> -			ksft_exit_fail_msg("Zicboz is only present on a subset of harts.\n"
> -					   "Use taskset to select a set of harts where Zicboz\n"
> -					   "presence (present or not) is consistent for each hart\n");
> -		++c;
> -	}
> +	if (CPU_COUNT(&tmp))
> +		ksft_exit_fail_msg("Zicboz is only present on a subset of harts.\n"
> +				   "Use taskset to select a set of harts where Zicboz\n"
> +				   "presence (present or not) is consistent for each hart\n");
>  }
>
>  enum {

Reviewed-by: Palmer Dabbelt <palmer at rivosinc.com>



More information about the linux-riscv mailing list