All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH igt] igt/prime_mmap_coherency: Only assert correct usage of sync API
Date: Tue, 17 Oct 2017 15:05:29 +0300	[thread overview]
Message-ID: <20171017120529.GQ10981@intel.com> (raw)
In-Reply-To: <150823703227.6894.17870258747245341139@mail.alporthouse.com>

On Tue, Oct 17, 2017 at 11:43:52AM +0100, Chris Wilson wrote:
> Quoting Chris Wilson (2017-10-11 10:56:29)
> > Ignore the unexpected success when the CPU cache is randomly flushed
> > that makes !llc appear to work without sync. It happens, the cpu cache
> > is a fickle beast that we do not have sole control over. Instead limit
> > the test to detect failures when the API is being adhered to.
> > 
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103168
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> Ping?

Rationale makes sense.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> 
> > ---
> >  tests/prime_mmap_coherency.c | 71 ++++++++++++++------------------------------
> >  1 file changed, 22 insertions(+), 49 deletions(-)
> > 
> > diff --git a/tests/prime_mmap_coherency.c b/tests/prime_mmap_coherency.c
> > index 9831d775..a213ac0f 100644
> > --- a/tests/prime_mmap_coherency.c
> > +++ b/tests/prime_mmap_coherency.c
> > @@ -34,10 +34,7 @@
> >  IGT_TEST_DESCRIPTION("Test dma-buf mmap on !llc platforms mostly and provoke"
> >                 " coherency bugs so we know for sure where we need the sync ioctls.");
> >  
> > -#define ROUNDS 20
> > -
> >  int fd;
> > -int stale = 0;
> >  static drm_intel_bufmgr *bufmgr;
> >  struct intel_batchbuffer *batch;
> >  static int width = 1024, height = 1024;
> > @@ -49,13 +46,14 @@ static int width = 1024, height = 1024;
> >   *   3. write '1's, in GTT domain.
> >   *   4. read again through the mapped dma-buf.
> >   */
> > -static void test_read_flush(bool expect_stale_cache)
> > +static int test_read_flush(void)
> >  {
> >         drm_intel_bo *bo_1;
> >         drm_intel_bo *bo_2;
> >         uint32_t *ptr_cpu;
> >         uint32_t *ptr_gtt;
> >         int dma_buf_fd, i;
> > +       int stale = 0;
> >  
> >         bo_1 = drm_intel_bo_alloc(bufmgr, "BO 1", width * height * 4, 4096);
> >  
> > @@ -94,18 +92,16 @@ static void test_read_flush(bool expect_stale_cache)
> >          * stale cachelines from step #2 survive (mostly, a few will be evicted)
> >          * until we try to read them again in step #4. This behavior could be fixed
> >          * by flush CPU read right before accessing the CPU pointer */
> > -       if (!expect_stale_cache)
> > -               prime_sync_start(dma_buf_fd, false);
> > +       prime_sync_start(dma_buf_fd, false);
> >  
> >         for (i = 0; i < (width * height) / 4; i++)
> > -               if (ptr_cpu[i] != 0xc5c5c5c5) {
> > -                       igt_warn_on_f(!expect_stale_cache,
> > -                                   "Found 0x%08x at offset 0x%08x\n", ptr_cpu[i], i);
> > +               if (ptr_cpu[i] != 0xc5c5c5c5)
> >                         stale++;
> > -               }
> >  
> >         drm_intel_bo_unreference(bo_1);
> >         munmap(ptr_cpu, width * height);
> > +
> > +       return stale;
> >  }
> >  
> >  /*
> > @@ -115,13 +111,14 @@ static void test_read_flush(bool expect_stale_cache)
> >   *   3. copy BO 1 to new BO 2, in GTT domain.
> >   *   4. read via dma-buf mmap BO 2.
> >   */
> > -static void test_write_flush(bool expect_stale_cache)
> > +static int test_write_flush(void)
> >  {
> >         drm_intel_bo *bo_1;
> >         drm_intel_bo *bo_2;
> >         uint32_t *ptr_cpu;
> >         uint32_t *ptr2_cpu;
> >         int dma_buf_fd, dma_buf2_fd, i;
> > +       int stale = 0;
> >  
> >         bo_1 = drm_intel_bo_alloc(bufmgr, "BO 1", width * height * 4, 4096);
> >  
> > @@ -143,8 +140,7 @@ static void test_write_flush(bool expect_stale_cache)
> >  
> >         /* This is the main point of this test: !llc hw requires a cache write
> >          * flush right here (explained in step #4). */
> > -       if (!expect_stale_cache)
> > -               prime_sync_start(dma_buf_fd, true);
> > +       prime_sync_start(dma_buf_fd, true);
> >  
> >         memset(ptr_cpu, 0x11, width * height);
> >  
> > @@ -164,15 +160,14 @@ static void test_write_flush(bool expect_stale_cache)
> >         igt_assert(ptr2_cpu != MAP_FAILED);
> >  
> >         for (i = 0; i < (width * height) / 4; i++)
> > -               if (ptr2_cpu[i] != 0x11111111) {
> > -                       igt_warn_on_f(!expect_stale_cache,
> > -                                     "Found 0x%08x at offset 0x%08x\n", ptr2_cpu[i], i);
> > +               if (ptr2_cpu[i] != 0x11111111)
> >                         stale++;
> > -               }
> >  
> >         drm_intel_bo_unreference(bo_1);
> >         drm_intel_bo_unreference(bo_2);
> >         munmap(ptr_cpu, width * height);
> > +
> > +       return stale;
> >  }
> >  
> >  static void blit_and_cmp(void)
> > @@ -279,7 +274,6 @@ static void test_ioctl_errors(void)
> >  
> >  int main(int argc, char **argv)
> >  {
> > -       int i;
> >         igt_subtest_init(argc, argv);
> >  
> >         igt_fixture {
> > @@ -293,41 +287,20 @@ int main(int argc, char **argv)
> >         /* Cache coherency and the eviction are pretty much unpredictable, so
> >          * reproducing boils down to trial and error to hit different scenarios.
> >          * TODO: We may want to improve tests a bit by picking random subranges. */
> > -       igt_info("%d rounds for each test\n", ROUNDS);
> >         igt_subtest("read") {
> > -               stale = 0;
> > -               igt_info("exercising read flush\n");
> > -               for (i = 0; i < ROUNDS; i++)
> > -                       test_read_flush(false);
> > -               igt_fail_on_f(stale, "num of stale cache lines %d\n", stale);
> > -       }
> > -
> > -       /* Only for !llc platforms */
> > -       igt_subtest("read-and-fail") {
> > -               igt_require(!gem_has_llc(fd));
> > -               stale = 0;
> > -               igt_info("exercising read flush and expect to fail on !llc\n");
> > -               for (i = 0; i < ROUNDS; i++)
> > -                       test_read_flush(true);
> > -               igt_fail_on_f(!stale, "couldn't find any stale cache lines\n");
> > +               igt_until_timeout(5) {
> > +                       int stale = test_read_flush();
> > +                       igt_fail_on_f(stale,
> > +                                     "num of stale cache lines %d\n", stale);
> > +               }
> >         }
> >  
> >         igt_subtest("write") {
> > -               stale = 0;
> > -               igt_info("exercising write flush\n");
> > -               for (i = 0; i < ROUNDS; i++)
> > -                       test_write_flush(false);
> > -               igt_fail_on_f(stale, "num of stale cache lines %d\n", stale);
> > -       }
> > -
> > -       /* Only for !llc platforms */
> > -       igt_subtest("write-and-fail") {
> > -               igt_require(!gem_has_llc(fd));
> > -               stale = 0;
> > -               igt_info("exercising write flush and expect to fail on !llc\n");
> > -               for (i = 0; i < ROUNDS; i++)
> > -                       test_write_flush(true);
> > -               igt_fail_on_f(!stale, "couldn't find any stale cache lines\n");
> > +               igt_until_timeout(5) {
> > +                       int stale = test_write_flush();
> > +                       igt_fail_on_f(stale,
> > +                                     "num of stale cache lines %d\n", stale);
> > +               }
> >         }
> >  
> >         igt_subtest("ioctl-errors") {
> > -- 
> > 2.15.0.rc0
> > 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2017-10-17 12:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11  9:56 [PATCH igt] igt/prime_mmap_coherency: Only assert correct usage of sync API Chris Wilson
2017-10-11 13:46 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-10-11 20:14 ` ✓ Fi.CI.IGT: " Patchwork
2017-10-17 10:43 ` [PATCH igt] " Chris Wilson
2017-10-17 12:05   ` Ville Syrjälä [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=20171017120529.GQ10981@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.