Re: [PATCH v9 1/5] selftests/mm: move pkey selftest helpers to pkey_util.c

From: David Hildenbrand (Arm)

Date: Mon Jul 06 2026 - 05:41:56 EST


On 7/2/26 08:23, Hongfu Li wrote:
> Move pkey selftest debugging helpers into shared code so both pkey
> selftests can use the same tracing and abort-hook logic. Also fix
> cat_into_file() to print file, not str, in the open() failure message.
>
> Signed-off-by: Hongfu Li <lihongfu@xxxxxxxxxx>
> Acked-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> Acked-by: Liam R. Howlett (Oracle) <liam@xxxxxxxxxxxxx>
> Reviewed-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>
> Tested-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>
> ---
> tools/testing/selftests/mm/pkey-helpers.h | 4 +-
> tools/testing/selftests/mm/pkey_util.c | 90 ++++++++++++++++++++
> tools/testing/selftests/mm/protection_keys.c | 87 -------------------
> 3 files changed, 93 insertions(+), 88 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h
> index 2c377f4e9df1..46a8a1878dc1 100644
> --- a/tools/testing/selftests/mm/pkey-helpers.h
> +++ b/tools/testing/selftests/mm/pkey-helpers.h
> @@ -68,7 +68,9 @@ static inline void sigsafe_printf(const char *format, ...)
> #define dprintf3(args...) dprintf_level(3, args)
> #define dprintf4(args...) dprintf_level(4, args)
>
> -extern void abort_hooks(void);
> +void tracing_on(void);
> +void tracing_off(void);
> +void abort_hooks(void);
> #define pkey_assert(condition) do { \
> if (!(condition)) { \
> dprintf0("# assert() at %s::%d test_nr: %d iteration: %d\n", \
> diff --git a/tools/testing/selftests/mm/pkey_util.c b/tools/testing/selftests/mm/pkey_util.c
> index 255b332f7a08..fbef3cd45447 100644
> --- a/tools/testing/selftests/mm/pkey_util.c
> +++ b/tools/testing/selftests/mm/pkey_util.c
> @@ -2,9 +2,99 @@
> #define __SANE_USERSPACE_TYPES__
> #include <sys/syscall.h>
> #include <unistd.h>
> +#include <fcntl.h>
> +#include <stdio.h>
> +#include <string.h>
>
> #include "pkey-helpers.h"
>
> +int iteration_nr = 1;
> +int test_nr;
> +int dprint_in_signal;
> +
> +#if CONTROL_TRACING > 0

Who sets that CONTROL_TRACING? And if it's nobody, why are we dragging this along?

--
Cheers,

David