[RFC PATCH 3/4] Test pidns translation cache
Dmitry V. Levin
ldv at altlinux.org
Sat Aug 15 21:00:00 UTC 2020
On Sat, Aug 15, 2020 at 10:54:46PM +0200, Ákos Uzonyi wrote:
> On Sat, 15 Aug 2020 at 22:35, Dmitry V. Levin <ldv at altlinux.org> wrote:
> > On Sat, Aug 15, 2020 at 10:21:49PM +0200, Ákos Uzonyi wrote:
> > > On Sat, 15 Aug 2020 at 14:37, Dmitry V. Levin <ldv at altlinux.org> wrote:
> > > > On Thu, Aug 13, 2020 at 05:32:41PM +0200, Ákos Uzonyi wrote:
> > > > [...]
> > > > > +/**
> > > > > + * There is a 1 sec timeout for this test. With pidns caching more than 1000
> > > > > + * syscalls can be executed, without caching only a few tens.
> > > > > + */
> > > > > +#define SYSCALL_COUNT 200
> > > > > +
> > > > > +int
> > > > > +main(void)
> > > > > +{
> > > > > + pidns_test_init();
> > > > > +
> > > > > + for (int i = 0; i < SYSCALL_COUNT; i++)
> > > > > + getpid();
> > > > > +
> > > > > + return 0;
> > > > > +}
> > > >
> > > > As getpid can be easily cached by libc, this has to be a syscall().
> > > >
> > > > With regards to the number of syscalls, some hosts could be very slow, so
> > > > I suggest to count the number of syscalls without any pid translation and
> > > > use it as a baseline.
> > >
> > > Good idea, thanks.
> >
> > We employ a similar technique in filter_seccomp-perf.test where the test
> > counts the number of chdir syscalls invoked in a loop for one second.
>
> Thanks for pointing that out. But I already started to implement a
> little bit different kind of test: the syscall count is constant, I
> measure the time with and without pidns translation, and the
> difference should be below some threshold.
Let's see which one results in less code then. ;)
--
ldv
More information about the Strace-devel
mailing list