[Intel-gfx] [PATCH igt 2/3] benchmarks/gem_syslatency: Apply vmpressure, measure page allocation

Chris Wilson chris at chris-wilson.co.uk
Wed Sep 27 09:36:03 UTC 2017


Quoting Joonas Lahtinen (2017-09-27 09:52:42)
> On Mon, 2017-09-25 at 21:26 +0100, Chris Wilson wrote:
> > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> > ---
> >  benchmarks/gem_syslatency.c | 86 +++++++++++++++++++++++++++++++++++++++++++--
> >  1 file changed, 83 insertions(+), 3 deletions(-)
> > 
> > diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
> > index 4ed23638..b8788497 100644
> > --- a/benchmarks/gem_syslatency.c
> > +++ b/benchmarks/gem_syslatency.c
> > @@ -29,6 +29,7 @@
> >  #include <stdio.h>
> >  #include <string.h>
> >  #include <fcntl.h>
> > +#include <ftw.h>
> >  #include <inttypes.h>
> >  #include <pthread.h>
> >  #include <sched.h>
> > @@ -51,6 +52,7 @@ static volatile int done;
> >  struct gem_busyspin {
> >       pthread_t thread;
> >       unsigned long count;
> > +     bool leak;
> >  };
> 
> I know we all binary arithmetic, but can I still ask
> 
> 
> #define M()
> #define K()
> 
> Or something.
> 
> >  
> >  struct sys_wait {
> > @@ -93,6 +95,7 @@ static void *gem_busyspin(void *arg)
> >       struct gem_busyspin *bs = arg;
> >       struct drm_i915_gem_execbuffer2 execbuf;
> >       struct drm_i915_gem_exec_object2 obj;
> > +     const unsigned sz = bs->leak ? 16 << 20 : 4 << 10;
> 
> Beause, this is quite OK still.
> 
> > @@ -180,6 +188,33 @@ static void *sys_wait(void *arg)
> >       return NULL;
> >  }
> >  
> > +static void *sys_thp_alloc(void *arg)
> > +{
> > +     struct sys_wait *w = arg;
> > +     struct timespec now;
> > +
> > +     clock_gettime(CLOCK_MONOTONIC, &now);
> > +     while (!done) {
> > +             const size_t sz = 2 << 20;
> > +             const struct timespec start = now;
> > +             void *ptr;
> > +
> > +             ptr = mmap(NULL, sz,
> > +                        PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
> > +                        -1, 0);
> > +             assert(ptr != MAP_FAILED);
> > +             madvise(ptr, sz, MADV_HUGEPAGE);
> > +             for (int page = 0; page < 2 << 20 >> 12; page++)
> > +                     *((volatile uint32_t *)ptr + (page << 12 >> 2)) = 0;
> 
> But what's the point in this iteration, we iterate from 0 to 512 page
> index (sz/PAGE_SIZE would be so much easier) and then write to to not
> each page but interleave four page writes per page and 3/4 of pages
> never get written? If this is intentional, please drop a comment.

:) As you later realised, there's an implicit <<2 from the pointer
arithmetic.
-Chris


More information about the Intel-gfx mailing list