bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Andrii Nakryiko <andriin@fb.com>, bpf <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next] selftests/bpf: fix usleep() implementation
Date: Thu, 12 Mar 2020 23:52:08 -0700	[thread overview]
Message-ID: <CAEf4BzZDRQ7J5_1RN+wK1aD-LxdWD7FTbZpo+qPm8_yuGQ766Q@mail.gmail.com> (raw)
In-Reply-To: <20200313064521.se2sqpgkpd5ekmfo@ast-mbp>

On Thu, Mar 12, 2020 at 11:45 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Thu, Mar 12, 2020 at 11:18:37PM -0700, Andrii Nakryiko wrote:
> > nanosleep syscall expects pointer to struct timespec, not nanoseconds
> > directly. Current implementation fulfills its purpose of invoking nanosleep
> > syscall, but doesn't really provide sleeping capabilities, which can cause
> > flakiness for tests relying on usleep() to wait for something.
> >
> > Fixes: ec12a57b822c ("selftests/bpf: Guarantee that useep() calls nanosleep() syscall")
> > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> > ---
> >  tools/testing/selftests/bpf/test_progs.c | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> > index 2b0bc1171c9c..b6201dd82edf 100644
> > --- a/tools/testing/selftests/bpf/test_progs.c
> > +++ b/tools/testing/selftests/bpf/test_progs.c
> > @@ -35,7 +35,16 @@ struct prog_test_def {
> >   */
> >  int usleep(useconds_t usec)
> >  {
> > -     return syscall(__NR_nanosleep, usec * 1000UL);
> > +     struct timespec ts;
> > +
> > +     if (usec > 999999) {
> > +             ts.tv_sec = usec / 1000000;
> > +             ts.tv_nsec = usec % 1000000;
> > +     } else {
> > +             ts.tv_sec = 0;
> > +             ts.tv_nsec = usec;
> > +     }
> > +     return nanosleep(&ts, NULL);
> >  }
>
> Is this a copy-paste from somewhere?

nope, my very own prematurely optimized implementation :)

> Above 'if' looks like premature optimization.
> I applied it anyway, since it fixes flakiness in test_progs -n 24.
> Now pin*tp* tests are stable.
>

Great, I hoped as much.

> But the other one is still flaky:
> server_thread:FAIL:237
> Failed to accept client: Resource temporarily unavailable
> #64 tcp_rtt:FAIL
> Note that if I run the test alone (test_progs -n 64) it is stable.
> It fails only when run as part of bigger test_progs.
> test_progs -n 30-64 sporadically fails (most of the time)
> test_progs -n 40-64 consistently passes
> Haven't bisected further.

Okey, I'll get to it once I'm done fixing a bunch of other problems.
Seems like tcp_rtt needs some more love, sigh... :(

      reply	other threads:[~2020-03-13  6:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-13  6:18 [PATCH bpf-next] selftests/bpf: fix usleep() implementation Andrii Nakryiko
2020-03-13  6:45 ` Alexei Starovoitov
2020-03-13  6:52   ` Andrii Nakryiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEf4BzZDRQ7J5_1RN+wK1aD-LxdWD7FTbZpo+qPm8_yuGQ766Q@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).