Re: [PATCH bpf-next] Improve BPF test stability (related to perf events and scheduling)

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

 



On Fri, Feb 18, 2022 at 4:30 PM Mykola Lysenko <mykolal@xxxxxx> wrote:
>
> In send_signal, replace sleep with dummy cpu intensive computation
> to increase probability of child process being scheduled. Add few
> more asserts.

How often do we see the test fail because the child process is not
scheduled?

[...]

>  static void sigusr1_handler(int signum)
>  {
> -       sigusr1_received++;
> +       sigusr1_received = 1;
>  }
>
>  static void test_send_signal_common(struct perf_event_attr *attr,
> @@ -42,7 +43,9 @@ static void test_send_signal_common(struct perf_event_attr *attr,
>                 int old_prio;
>
>                 /* install signal handler and notify parent */
> +               errno = 0;
>                 signal(SIGUSR1, sigusr1_handler);
> +               ASSERT_OK(errno, "signal");
>
>                 close(pipe_c2p[0]); /* close read */
>                 close(pipe_p2c[1]); /* close write */
> @@ -63,9 +66,12 @@ static void test_send_signal_common(struct perf_event_attr *attr,
>                 ASSERT_EQ(read(pipe_p2c[0], buf, 1), 1, "pipe_read");
>
>                 /* wait a little for signal handler */
> -               sleep(1);
> +               for (int i = 0; i < 1000000000; i++)
> +                       volatile_variable++;
>
>                 buf[0] = sigusr1_received ? '2' : '0';

^^^^ this "? :" seems useless as we assert sigusr1_received == 1. Let's fix it.

> +               ASSERT_EQ(sigusr1_received, 1, "sigusr1_received");
> +
>                 ASSERT_EQ(write(pipe_c2p[1], buf, 1), 1, "pipe_write");
>
>                 /* wait for parent notification and exit */
> @@ -110,9 +116,9 @@ static void test_send_signal_common(struct perf_event_attr *attr,
>         ASSERT_EQ(read(pipe_c2p[0], buf, 1), 1, "pipe_read");
>
>         /* trigger the bpf send_signal */
> +       skel->bss->signal_thread = signal_thread;
>         skel->bss->pid = pid;
>         skel->bss->sig = SIGUSR1;
> -       skel->bss->signal_thread = signal_thread;

Does the order matter here?



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux