Re: [PATCH v4 4/4] selftest/bpf: Test a perf bpf program that suppresses side effects.

From: Song Liu
Date: Fri Jan 19 2024 - 12:20:05 EST


On Thu, Jan 18, 2024 at 4:14 PM Kyle Huey <me@xxxxxxxxxxxx> wrote:
>

Acked-by: Song Liu <song@xxxxxxxxxx>

with a couple nitpicks below.

[...]
> +int sigio_count, sigtrap_count;
> +
> +static void handle_sigio(int sig __always_unused)
> +{
> + ++sigio_count;
> +}
> +
> +static void handle_sigtrap(int signum __always_unused,
> + siginfo_t *info,
> + void *ucontext __always_unused)
> +{
> + ASSERT_EQ(info->si_code, TRAP_PERF, "wrong si_code");

nit: I would just call it "si_code", not "wrong si_code".

> + ++sigtrap_count;
> +}
[...]
> + if (!ASSERT_OK(sigaction(SIGTRAP, &action, &previous_sigtrap), "sigaction"))
> + return;
> +
> + previous_sigio = signal(SIGIO, handle_sigio);
> + if (!ASSERT_NEQ(previous_sigio, SIG_ERR, "signal"))
> + goto cleanup;

nit: If we goto cleanup here, we will do

signal(SIGIO, SIG_ERR);

This is a no-op, so it is not a real issue. But it is not very clean.

[...]