All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] igt/drm_read: Exercise waking up the next waiter
@ 2019-02-27 10:20 Chris Wilson
  2019-02-27 10:45 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Chris Wilson @ 2019-02-27 10:20 UTC (permalink / raw)
  To: igt-dev

Try to hit a bug in the kernel whereby a short reader does not wakeup
the next waiter (on the same fd) leading to forever blocking.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 tests/drm_read.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/tests/drm_read.c b/tests/drm_read.c
index 309f389f6..923a9f750 100644
--- a/tests/drm_read.c
+++ b/tests/drm_read.c
@@ -43,6 +43,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <sys/poll.h>
+#include <pthread.h>
 #include "drm.h"
 
 IGT_TEST_DESCRIPTION("Call read(drm) and see if it behaves.");
@@ -166,6 +167,90 @@ static void test_short_buffer(int in, int nonblock, enum pipe pipe)
 	teardown(fd);
 }
 
+struct short_buffer_wakeup {
+	pthread_mutex_t mutex;
+	pthread_cond_t send, recv;
+	int counter;
+	int done;
+	int fd;
+};
+
+static void *thread_short_buffer_wakeup(void *arg)
+{
+	struct short_buffer_wakeup *w = arg;
+	char buffer[1024]; /* events are typically 32 bytes */
+
+	while (!w->done) {
+		/* Short read, does not consume the event. */
+		igt_assert_eq(read(w->fd, buffer, 4), 0);
+
+		pthread_mutex_lock(&w->mutex);
+		if (!--w->counter)
+			pthread_cond_signal(&w->send);
+		pthread_cond_wait(&w->recv, &w->mutex);
+		pthread_mutex_unlock(&w->mutex);
+	}
+
+	return NULL;
+}
+
+static void test_short_buffer_wakeup(int in, enum pipe pipe)
+{
+	const int nt = sysconf(_SC_NPROCESSORS_ONLN) + 1;
+	struct short_buffer_wakeup w = {
+		.fd = setup(in, 0),
+	};
+	pthread_t t[nt];
+	char buffer[1024]; /* events are typically 32 bytes */
+
+	pthread_mutex_init(&w.mutex, NULL);
+	pthread_cond_init(&w.send, NULL);
+	pthread_cond_init(&w.recv, NULL);
+
+	for (int n = 0; n < nt; n++)
+		pthread_create(&t[n], NULL, thread_short_buffer_wakeup, &w);
+
+	igt_until_timeout(30) {
+		struct timespec tv;
+		int err = 0;
+
+		pthread_mutex_lock(&w.mutex);
+		w.counter = nt;
+		pthread_cond_broadcast(&w.recv);
+		pthread_mutex_unlock(&w.mutex);
+
+		/* Give each thread a chance to sleep in drm_read() */
+		pthread_yield();
+
+		/* One event should wake all threads as none consume */
+		generate_event(w.fd, pipe);
+
+		clock_gettime(CLOCK_REALTIME, &tv);
+		tv.tv_sec += 5; /* Let's be very generous to the scheduler */
+
+		pthread_mutex_lock(&w.mutex);
+		while (w.counter && !err)
+			err = pthread_cond_timedwait(&w.send, &w.mutex, &tv);
+		pthread_mutex_unlock(&w.mutex);
+
+		igt_assert_f(err == 0,
+			     "Timed out waiting for drm_read() to wakeup on an event\n");
+
+
+		/* No thread should consume the event */
+		igt_assert(read(w.fd, buffer, 40) > 0);
+	}
+	pthread_mutex_lock(&w.mutex);
+	w.done = true;
+	pthread_cond_broadcast(&w.recv);
+	pthread_mutex_unlock(&w.mutex);
+
+	for (int n = 0; n < nt; n++)
+		pthread_join(t[n], NULL);
+
+	close(w.fd);
+}
+
 igt_main
 {
 	int fd;
@@ -218,4 +303,7 @@ igt_main
 
 	igt_subtest("short-buffer-nonblock")
 		test_short_buffer(fd, 1, pipe);
+
+	igt_subtest("short-buffer-wakeup")
+		test_short_buffer_wakeup(fd, pipe);
 }
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for igt/drm_read: Exercise waking up the next waiter
  2019-02-27 10:20 [igt-dev] [PATCH i-g-t] igt/drm_read: Exercise waking up the next waiter Chris Wilson
@ 2019-02-27 10:45 ` Patchwork
  2019-02-27 11:48 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  2019-02-27 20:46 ` [igt-dev] [PATCH i-g-t] " Ville Syrjälä
  2 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2019-02-27 10:45 UTC (permalink / raw)
  To: igt-dev

== Series Details ==

Series: igt/drm_read: Exercise waking up the next waiter
URL   : https://patchwork.freedesktop.org/series/57285/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5664 -> IGTPW_2531
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/57285/revisions/1/

Known issues
------------

  Here are the changes found in IGTPW_2531 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_suspend@basic-s4-devices:
    - fi-blb-e6850:       PASS -> INCOMPLETE [fdo#107718]

  * igt@i915_selftest@live_hangcheck:
    - fi-icl-u2:          PASS -> INCOMPLETE [fdo#108569]

  * igt@kms_busy@basic-flip-a:
    - fi-gdg-551:         PASS -> FAIL [fdo#103182]

  
#### Possible fixes ####

  * igt@i915_pm_rpm@basic-pci-d3-state:
    - fi-byt-n2820:       SKIP [fdo#109271] -> PASS
    - fi-bsw-kefka:       SKIP [fdo#109271] -> PASS

  * igt@i915_pm_rpm@basic-rte:
    - fi-byt-n2820:       FAIL [fdo#108800] -> PASS
    - fi-bsw-kefka:       FAIL [fdo#108800] -> PASS

  * igt@i915_selftest@live_execlists:
    - fi-icl-u3:          INCOMPLETE [fdo#109567] -> PASS
    - fi-apl-guc:         INCOMPLETE [fdo#103927] / [fdo#109720] -> PASS

  * igt@kms_busy@basic-flip-a:
    - fi-kbl-7567u:       SKIP [fdo#109271] / [fdo#109278] -> PASS +2

  * igt@kms_busy@basic-flip-b:
    - fi-gdg-551:         FAIL [fdo#103182] -> PASS

  
  [fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
  [fdo#108800]: https://bugs.freedesktop.org/show_bug.cgi?id=108800
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
  [fdo#109567]: https://bugs.freedesktop.org/show_bug.cgi?id=109567
  [fdo#109720]: https://bugs.freedesktop.org/show_bug.cgi?id=109720


Participating hosts (42 -> 39)
------------------------------

  Missing    (3): fi-ilk-m540 fi-byt-squawks fi-bsw-cyan 


Build changes
-------------

    * IGT: IGT_4859 -> IGTPW_2531

  CI_DRM_5664: cf7f9ddffea038209e80a3068eb4d7af73db0560 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_2531: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2531/
  IGT_4859: 1d8f3320cbc06fa73ad1487453a63993f17b9d57 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@drm_read@short-buffer-wakeup

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2531/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [igt-dev] ✓ Fi.CI.IGT: success for igt/drm_read: Exercise waking up the next waiter
  2019-02-27 10:20 [igt-dev] [PATCH i-g-t] igt/drm_read: Exercise waking up the next waiter Chris Wilson
  2019-02-27 10:45 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
@ 2019-02-27 11:48 ` Patchwork
  2019-02-27 11:50   ` Chris Wilson
  2019-02-27 21:18   ` Antonio Argenziano
  2019-02-27 20:46 ` [igt-dev] [PATCH i-g-t] " Ville Syrjälä
  2 siblings, 2 replies; 9+ messages in thread
From: Patchwork @ 2019-02-27 11:48 UTC (permalink / raw)
  To: igt-dev

== Series Details ==

Series: igt/drm_read: Exercise waking up the next waiter
URL   : https://patchwork.freedesktop.org/series/57285/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5664_full -> IGTPW_2531_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/57285/revisions/1/

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in IGTPW_2531_full:

### IGT changes ###

#### Possible regressions ####

  * {igt@drm_read@short-buffer-wakeup} (NEW):
    - shard-apl:          NOTRUN -> FAIL
    - shard-snb:          NOTRUN -> FAIL
    - shard-kbl:          NOTRUN -> FAIL
    - shard-hsw:          NOTRUN -> FAIL
    - shard-glk:          NOTRUN -> FAIL

  
New tests
---------

  New tests have been introduced between CI_DRM_5664_full and IGTPW_2531_full:

### New IGT tests (1) ###

  * igt@drm_read@short-buffer-wakeup:
    - Statuses : 5 fail(s)
    - Exec time: [5.05, 5.54] s

  

Known issues
------------

  Here are the changes found in IGTPW_2531_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_basic@basic-bsd1:
    - shard-glk:          NOTRUN -> SKIP [fdo#109271] +3

  * igt@gem_stolen@stolen-no-mmap:
    - shard-snb:          NOTRUN -> SKIP [fdo#109271] +19

  * igt@i915_pm_rc6_residency@rc6-accuracy:
    - shard-snb:          PASS -> SKIP [fdo#109271]

  * igt@i915_pm_rpm@system-suspend-modeset:
    - shard-kbl:          PASS -> INCOMPLETE [fdo#103665] / [fdo#107807]

  * igt@kms_atomic_transition@1x-modeset-transitions-nonblocking-fencing:
    - shard-apl:          PASS -> FAIL [fdo#109660]
    - shard-kbl:          PASS -> FAIL [fdo#109660]

  * igt@kms_busy@basic-modeset-f:
    - shard-snb:          NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +2

  * igt@kms_busy@extended-modeset-hang-newfb-render-b:
    - shard-snb:          PASS -> DMESG-WARN [fdo#107956]

  * igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
    - shard-kbl:          PASS -> DMESG-WARN [fdo#107956] +1
    - shard-hsw:          PASS -> DMESG-WARN [fdo#107956]

  * igt@kms_cursor_crc@cursor-128x128-random:
    - shard-apl:          PASS -> FAIL [fdo#103232] +2

  * igt@kms_cursor_crc@cursor-128x42-sliding:
    - shard-kbl:          PASS -> FAIL [fdo#103232]

  * igt@kms_cursor_legacy@2x-long-flip-vs-cursor-atomic:
    - shard-glk:          PASS -> FAIL [fdo#104873]

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-pwrite:
    - shard-apl:          PASS -> FAIL [fdo#103167] +3
    - shard-kbl:          PASS -> FAIL [fdo#103167] +1

  * igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-cpu:
    - shard-glk:          PASS -> FAIL [fdo#103167] +1

  * igt@kms_frontbuffer_tracking@fbcpsr-rgb565-draw-mmap-cpu:
    - shard-apl:          NOTRUN -> SKIP [fdo#109271] +1

  * igt@kms_plane_multiple@atomic-pipe-b-tiling-y:
    - shard-glk:          PASS -> FAIL [fdo#103166] +2
    - shard-apl:          PASS -> FAIL [fdo#103166] +3
    - shard-kbl:          PASS -> FAIL [fdo#103166]

  * igt@kms_rotation_crc@multiplane-rotation-cropping-bottom:
    - shard-kbl:          PASS -> DMESG-FAIL [fdo#105763]

  * igt@kms_vblank@pipe-a-ts-continuation-dpms-suspend:
    - shard-apl:          PASS -> FAIL [fdo#104894] +3

  * igt@kms_vblank@pipe-b-ts-continuation-modeset:
    - shard-kbl:          PASS -> FAIL [fdo#104894]

  * igt@testdisplay:
    - shard-kbl:          PASS -> INCOMPLETE [fdo#103665]
    - shard-apl:          PASS -> INCOMPLETE [fdo#103927]

  
#### Possible fixes ####

  * igt@drm_read@short-buffer-nonblock:
    - shard-snb:          INCOMPLETE [fdo#105411] -> PASS

  * igt@i915_pm_rc6_residency@rc6-accuracy:
    - shard-kbl:          SKIP [fdo#109271] -> PASS +1

  * igt@kms_busy@extended-modeset-hang-newfb-render-a:
    - shard-hsw:          DMESG-WARN [fdo#107956] -> PASS +1
    - shard-kbl:          DMESG-WARN [fdo#107956] -> PASS +1

  * igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-a:
    - shard-apl:          DMESG-WARN [fdo#107956] -> PASS

  * igt@kms_cursor_crc@cursor-256x85-sliding:
    - shard-kbl:          FAIL [fdo#103232] -> PASS +1

  * igt@kms_cursor_crc@cursor-64x21-sliding:
    - shard-apl:          FAIL [fdo#103232] -> PASS +4

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-cpu:
    - shard-apl:          FAIL [fdo#103167] -> PASS +2
    - shard-kbl:          FAIL [fdo#103167] -> PASS

  * igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-onoff:
    - shard-glk:          FAIL [fdo#103167] -> PASS +3

  * igt@kms_plane_multiple@atomic-pipe-a-tiling-x:
    - shard-apl:          FAIL [fdo#103166] -> PASS +1

  * igt@kms_plane_multiple@atomic-pipe-c-tiling-x:
    - shard-glk:          FAIL [fdo#103166] -> PASS +2
    - shard-kbl:          FAIL [fdo#103166] -> PASS +1

  * igt@kms_setmode@basic:
    - shard-apl:          FAIL [fdo#99912] -> PASS
    - shard-kbl:          FAIL [fdo#99912] -> PASS

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
  [fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#104873]: https://bugs.freedesktop.org/show_bug.cgi?id=104873
  [fdo#104894]: https://bugs.freedesktop.org/show_bug.cgi?id=104894
  [fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
  [fdo#105763]: https://bugs.freedesktop.org/show_bug.cgi?id=105763
  [fdo#107807]: https://bugs.freedesktop.org/show_bug.cgi?id=107807
  [fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
  [fdo#109660]: https://bugs.freedesktop.org/show_bug.cgi?id=109660
  [fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912


Participating hosts (6 -> 5)
------------------------------

  Missing    (1): shard-skl 


Build changes
-------------

    * IGT: IGT_4859 -> IGTPW_2531
    * Piglit: piglit_4509 -> None

  CI_DRM_5664: cf7f9ddffea038209e80a3068eb4d7af73db0560 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_2531: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2531/
  IGT_4859: 1d8f3320cbc06fa73ad1487453a63993f17b9d57 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2531/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [igt-dev] ✓ Fi.CI.IGT: success for igt/drm_read: Exercise waking up the next waiter
  2019-02-27 11:48 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
@ 2019-02-27 11:50   ` Chris Wilson
  2019-02-27 21:18   ` Antonio Argenziano
  1 sibling, 0 replies; 9+ messages in thread
From: Chris Wilson @ 2019-02-27 11:50 UTC (permalink / raw)
  To: Patchwork, igt-dev

Quoting Patchwork (2019-02-27 11:48:25)
>   * {igt@drm_read@short-buffer-wakeup} (NEW):
>     - shard-apl:          NOTRUN -> FAIL
>     - shard-snb:          NOTRUN -> FAIL
>     - shard-kbl:          NOTRUN -> FAIL
>     - shard-hsw:          NOTRUN -> FAIL
>     - shard-glk:          NOTRUN -> FAIL

\o/
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] igt/drm_read: Exercise waking up the next waiter
  2019-02-27 10:20 [igt-dev] [PATCH i-g-t] igt/drm_read: Exercise waking up the next waiter Chris Wilson
  2019-02-27 10:45 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
  2019-02-27 11:48 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
@ 2019-02-27 20:46 ` Ville Syrjälä
  2019-02-27 21:13   ` Chris Wilson
  2 siblings, 1 reply; 9+ messages in thread
From: Ville Syrjälä @ 2019-02-27 20:46 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

On Wed, Feb 27, 2019 at 10:20:19AM +0000, Chris Wilson wrote:
> Try to hit a bug in the kernel whereby a short reader does not wakeup
> the next waiter (on the same fd) leading to forever blocking.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  tests/drm_read.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 88 insertions(+)
> 
> diff --git a/tests/drm_read.c b/tests/drm_read.c
> index 309f389f6..923a9f750 100644
> --- a/tests/drm_read.c
> +++ b/tests/drm_read.c
> @@ -43,6 +43,7 @@
>  #include <sys/ioctl.h>
>  #include <sys/time.h>
>  #include <sys/poll.h>
> +#include <pthread.h>
>  #include "drm.h"
>  
>  IGT_TEST_DESCRIPTION("Call read(drm) and see if it behaves.");
> @@ -166,6 +167,90 @@ static void test_short_buffer(int in, int nonblock, enum pipe pipe)
>  	teardown(fd);
>  }
>  
> +struct short_buffer_wakeup {
> +	pthread_mutex_t mutex;
> +	pthread_cond_t send, recv;
> +	int counter;
> +	int done;
> +	int fd;
> +};
> +
> +static void *thread_short_buffer_wakeup(void *arg)
> +{
> +	struct short_buffer_wakeup *w = arg;
> +	char buffer[1024]; /* events are typically 32 bytes */
> +
> +	while (!w->done) {
> +		/* Short read, does not consume the event. */
> +		igt_assert_eq(read(w->fd, buffer, 4), 0);
> +
> +		pthread_mutex_lock(&w->mutex);
> +		if (!--w->counter)
> +			pthread_cond_signal(&w->send);
> +		pthread_cond_wait(&w->recv, &w->mutex);
> +		pthread_mutex_unlock(&w->mutex);
> +	}
> +
> +	return NULL;
> +}
> +
> +static void test_short_buffer_wakeup(int in, enum pipe pipe)
> +{
> +	const int nt = sysconf(_SC_NPROCESSORS_ONLN) + 1;

Hmm. I guess with less threads there's a better chance
they'd all escape the wait_for_event() before the list
becomes empty and just all pile up on the mutex. So I
was wondering if even more would be better. But since
CI already found the problem with this I guess it's
sufficient.

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

> +	struct short_buffer_wakeup w = {
> +		.fd = setup(in, 0),
> +	};
> +	pthread_t t[nt];
> +	char buffer[1024]; /* events are typically 32 bytes */
> +
> +	pthread_mutex_init(&w.mutex, NULL);
> +	pthread_cond_init(&w.send, NULL);
> +	pthread_cond_init(&w.recv, NULL);
> +
> +	for (int n = 0; n < nt; n++)
> +		pthread_create(&t[n], NULL, thread_short_buffer_wakeup, &w);
> +
> +	igt_until_timeout(30) {
> +		struct timespec tv;
> +		int err = 0;
> +
> +		pthread_mutex_lock(&w.mutex);
> +		w.counter = nt;
> +		pthread_cond_broadcast(&w.recv);
> +		pthread_mutex_unlock(&w.mutex);
> +
> +		/* Give each thread a chance to sleep in drm_read() */
> +		pthread_yield();
> +
> +		/* One event should wake all threads as none consume */
> +		generate_event(w.fd, pipe);
> +
> +		clock_gettime(CLOCK_REALTIME, &tv);
> +		tv.tv_sec += 5; /* Let's be very generous to the scheduler */
> +
> +		pthread_mutex_lock(&w.mutex);
> +		while (w.counter && !err)
> +			err = pthread_cond_timedwait(&w.send, &w.mutex, &tv);
> +		pthread_mutex_unlock(&w.mutex);
> +
> +		igt_assert_f(err == 0,
> +			     "Timed out waiting for drm_read() to wakeup on an event\n");
> +
> +
> +		/* No thread should consume the event */
> +		igt_assert(read(w.fd, buffer, 40) > 0);
> +	}
> +	pthread_mutex_lock(&w.mutex);
> +	w.done = true;
> +	pthread_cond_broadcast(&w.recv);
> +	pthread_mutex_unlock(&w.mutex);
> +
> +	for (int n = 0; n < nt; n++)
> +		pthread_join(t[n], NULL);
> +
> +	close(w.fd);
> +}
> +
>  igt_main
>  {
>  	int fd;
> @@ -218,4 +303,7 @@ igt_main
>  
>  	igt_subtest("short-buffer-nonblock")
>  		test_short_buffer(fd, 1, pipe);
> +
> +	igt_subtest("short-buffer-wakeup")
> +		test_short_buffer_wakeup(fd, pipe);
>  }
> -- 
> 2.20.1
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev

-- 
Ville Syrjälä
Intel
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] igt/drm_read: Exercise waking up the next waiter
  2019-02-27 20:46 ` [igt-dev] [PATCH i-g-t] " Ville Syrjälä
@ 2019-02-27 21:13   ` Chris Wilson
  0 siblings, 0 replies; 9+ messages in thread
From: Chris Wilson @ 2019-02-27 21:13 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: igt-dev

Quoting Ville Syrjälä (2019-02-27 20:46:12)
> On Wed, Feb 27, 2019 at 10:20:19AM +0000, Chris Wilson wrote:
> > Try to hit a bug in the kernel whereby a short reader does not wakeup
> > the next waiter (on the same fd) leading to forever blocking.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > ---
> >  tests/drm_read.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 88 insertions(+)
> > 
> > diff --git a/tests/drm_read.c b/tests/drm_read.c
> > index 309f389f6..923a9f750 100644
> > --- a/tests/drm_read.c
> > +++ b/tests/drm_read.c
> > @@ -43,6 +43,7 @@
> >  #include <sys/ioctl.h>
> >  #include <sys/time.h>
> >  #include <sys/poll.h>
> > +#include <pthread.h>
> >  #include "drm.h"
> >  
> >  IGT_TEST_DESCRIPTION("Call read(drm) and see if it behaves.");
> > @@ -166,6 +167,90 @@ static void test_short_buffer(int in, int nonblock, enum pipe pipe)
> >       teardown(fd);
> >  }
> >  
> > +struct short_buffer_wakeup {
> > +     pthread_mutex_t mutex;
> > +     pthread_cond_t send, recv;
> > +     int counter;
> > +     int done;
> > +     int fd;
> > +};
> > +
> > +static void *thread_short_buffer_wakeup(void *arg)
> > +{
> > +     struct short_buffer_wakeup *w = arg;
> > +     char buffer[1024]; /* events are typically 32 bytes */
> > +
> > +     while (!w->done) {
> > +             /* Short read, does not consume the event. */
> > +             igt_assert_eq(read(w->fd, buffer, 4), 0);
> > +
> > +             pthread_mutex_lock(&w->mutex);
> > +             if (!--w->counter)
> > +                     pthread_cond_signal(&w->send);
> > +             pthread_cond_wait(&w->recv, &w->mutex);
> > +             pthread_mutex_unlock(&w->mutex);
> > +     }
> > +
> > +     return NULL;
> > +}
> > +
> > +static void test_short_buffer_wakeup(int in, enum pipe pipe)
> > +{
> > +     const int nt = sysconf(_SC_NPROCESSORS_ONLN) + 1;
> 
> Hmm. I guess with less threads there's a better chance
> they'd all escape the wait_for_event() before the list
> becomes empty and just all pile up on the mutex. So I
> was wondering if even more would be better. But since
> CI already found the problem with this I guess it's
> sufficient.

I think the biggest challenge is actually making sure that at least 2
threads enter the read and hit the wait condition, before the parent
generates the event. If we bound everyone to a single CPU, made the
children RT and the parent low priority, we probably could do it with
just 2 child threads successfully.

But since it only takes about 3 passes (less than 0.1s) for this to
trigger across the machines, I think that's, as you say, good enough.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [igt-dev] ✓ Fi.CI.IGT: success for igt/drm_read: Exercise waking up the next waiter
  2019-02-27 11:48 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  2019-02-27 11:50   ` Chris Wilson
@ 2019-02-27 21:18   ` Antonio Argenziano
  2019-02-27 21:22     ` Chris Wilson
  1 sibling, 1 reply; 9+ messages in thread
From: Antonio Argenziano @ 2019-02-27 21:18 UTC (permalink / raw)
  To: igt-dev, Patchwork



On 27/02/19 03:48, Patchwork wrote:
> == Series Details ==
> 
> Series: igt/drm_read: Exercise waking up the next waiter
> URL   : https://patchwork.freedesktop.org/series/57285/
> State : success
> 
> == Summary ==
> 
> CI Bug Log - changes from CI_DRM_5664_full -> IGTPW_2531_full
> ====================================================
> 
> Summary
> -------
> 
>    **SUCCESS**
> 
>    No regressions found.
> 
>    External URL: https://patchwork.freedesktop.org/api/1.0/series/57285/revisions/1/
> 
> Possible new issues
> -------------------
> 
>    Here are the unknown changes that may have been introduced in IGTPW_2531_full:
> 
> ### IGT changes ###
> 
> #### Possible regressions ####
> 
>    * {igt@drm_read@short-buffer-wakeup} (NEW):
>      - shard-apl:          NOTRUN -> FAIL
>      - shard-snb:          NOTRUN -> FAIL
>      - shard-kbl:          NOTRUN -> FAIL
>      - shard-hsw:          NOTRUN -> FAIL
>      - shard-glk:          NOTRUN -> FAIL

Is it normal to have the run claim success if a new test is added and fails?

Antonio

> 
>    
> New tests
> ---------
> 
>    New tests have been introduced between CI_DRM_5664_full and IGTPW_2531_full:
> 
> ### New IGT tests (1) ###
> 
>    * igt@drm_read@short-buffer-wakeup:
>      - Statuses : 5 fail(s)
>      - Exec time: [5.05, 5.54] s
> 
>    
> 
> Known issues
> ------------
> 
>    Here are the changes found in IGTPW_2531_full that come from known issues:
> 
> ### IGT changes ###
> 
> #### Issues hit ####
> 
>    * igt@gem_exec_basic@basic-bsd1:
>      - shard-glk:          NOTRUN -> SKIP [fdo#109271] +3
> 
>    * igt@gem_stolen@stolen-no-mmap:
>      - shard-snb:          NOTRUN -> SKIP [fdo#109271] +19
> 
>    * igt@i915_pm_rc6_residency@rc6-accuracy:
>      - shard-snb:          PASS -> SKIP [fdo#109271]
> 
>    * igt@i915_pm_rpm@system-suspend-modeset:
>      - shard-kbl:          PASS -> INCOMPLETE [fdo#103665] / [fdo#107807]
> 
>    * igt@kms_atomic_transition@1x-modeset-transitions-nonblocking-fencing:
>      - shard-apl:          PASS -> FAIL [fdo#109660]
>      - shard-kbl:          PASS -> FAIL [fdo#109660]
> 
>    * igt@kms_busy@basic-modeset-f:
>      - shard-snb:          NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +2
> 
>    * igt@kms_busy@extended-modeset-hang-newfb-render-b:
>      - shard-snb:          PASS -> DMESG-WARN [fdo#107956]
> 
>    * igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
>      - shard-kbl:          PASS -> DMESG-WARN [fdo#107956] +1
>      - shard-hsw:          PASS -> DMESG-WARN [fdo#107956]
> 
>    * igt@kms_cursor_crc@cursor-128x128-random:
>      - shard-apl:          PASS -> FAIL [fdo#103232] +2
> 
>    * igt@kms_cursor_crc@cursor-128x42-sliding:
>      - shard-kbl:          PASS -> FAIL [fdo#103232]
> 
>    * igt@kms_cursor_legacy@2x-long-flip-vs-cursor-atomic:
>      - shard-glk:          PASS -> FAIL [fdo#104873]
> 
>    * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-pwrite:
>      - shard-apl:          PASS -> FAIL [fdo#103167] +3
>      - shard-kbl:          PASS -> FAIL [fdo#103167] +1
> 
>    * igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-cpu:
>      - shard-glk:          PASS -> FAIL [fdo#103167] +1
> 
>    * igt@kms_frontbuffer_tracking@fbcpsr-rgb565-draw-mmap-cpu:
>      - shard-apl:          NOTRUN -> SKIP [fdo#109271] +1
> 
>    * igt@kms_plane_multiple@atomic-pipe-b-tiling-y:
>      - shard-glk:          PASS -> FAIL [fdo#103166] +2
>      - shard-apl:          PASS -> FAIL [fdo#103166] +3
>      - shard-kbl:          PASS -> FAIL [fdo#103166]
> 
>    * igt@kms_rotation_crc@multiplane-rotation-cropping-bottom:
>      - shard-kbl:          PASS -> DMESG-FAIL [fdo#105763]
> 
>    * igt@kms_vblank@pipe-a-ts-continuation-dpms-suspend:
>      - shard-apl:          PASS -> FAIL [fdo#104894] +3
> 
>    * igt@kms_vblank@pipe-b-ts-continuation-modeset:
>      - shard-kbl:          PASS -> FAIL [fdo#104894]
> 
>    * igt@testdisplay:
>      - shard-kbl:          PASS -> INCOMPLETE [fdo#103665]
>      - shard-apl:          PASS -> INCOMPLETE [fdo#103927]
> 
>    
> #### Possible fixes ####
> 
>    * igt@drm_read@short-buffer-nonblock:
>      - shard-snb:          INCOMPLETE [fdo#105411] -> PASS
> 
>    * igt@i915_pm_rc6_residency@rc6-accuracy:
>      - shard-kbl:          SKIP [fdo#109271] -> PASS +1
> 
>    * igt@kms_busy@extended-modeset-hang-newfb-render-a:
>      - shard-hsw:          DMESG-WARN [fdo#107956] -> PASS +1
>      - shard-kbl:          DMESG-WARN [fdo#107956] -> PASS +1
> 
>    * igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-a:
>      - shard-apl:          DMESG-WARN [fdo#107956] -> PASS
> 
>    * igt@kms_cursor_crc@cursor-256x85-sliding:
>      - shard-kbl:          FAIL [fdo#103232] -> PASS +1
> 
>    * igt@kms_cursor_crc@cursor-64x21-sliding:
>      - shard-apl:          FAIL [fdo#103232] -> PASS +4
> 
>    * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-cpu:
>      - shard-apl:          FAIL [fdo#103167] -> PASS +2
>      - shard-kbl:          FAIL [fdo#103167] -> PASS
> 
>    * igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-onoff:
>      - shard-glk:          FAIL [fdo#103167] -> PASS +3
> 
>    * igt@kms_plane_multiple@atomic-pipe-a-tiling-x:
>      - shard-apl:          FAIL [fdo#103166] -> PASS +1
> 
>    * igt@kms_plane_multiple@atomic-pipe-c-tiling-x:
>      - shard-glk:          FAIL [fdo#103166] -> PASS +2
>      - shard-kbl:          FAIL [fdo#103166] -> PASS +1
> 
>    * igt@kms_setmode@basic:
>      - shard-apl:          FAIL [fdo#99912] -> PASS
>      - shard-kbl:          FAIL [fdo#99912] -> PASS
> 
>    
>    {name}: This element is suppressed. This means it is ignored when computing
>            the status of the difference (SUCCESS, WARNING, or FAILURE).
> 
>    [fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
>    [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
>    [fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
>    [fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
>    [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
>    [fdo#104873]: https://bugs.freedesktop.org/show_bug.cgi?id=104873
>    [fdo#104894]: https://bugs.freedesktop.org/show_bug.cgi?id=104894
>    [fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
>    [fdo#105763]: https://bugs.freedesktop.org/show_bug.cgi?id=105763
>    [fdo#107807]: https://bugs.freedesktop.org/show_bug.cgi?id=107807
>    [fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
>    [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
>    [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
>    [fdo#109660]: https://bugs.freedesktop.org/show_bug.cgi?id=109660
>    [fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
> 
> 
> Participating hosts (6 -> 5)
> ------------------------------
> 
>    Missing    (1): shard-skl
> 
> 
> Build changes
> -------------
> 
>      * IGT: IGT_4859 -> IGTPW_2531
>      * Piglit: piglit_4509 -> None
> 
>    CI_DRM_5664: cf7f9ddffea038209e80a3068eb4d7af73db0560 @ git://anongit.freedesktop.org/gfx-ci/linux
>    IGTPW_2531: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2531/
>    IGT_4859: 1d8f3320cbc06fa73ad1487453a63993f17b9d57 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
>    piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
> 
> == Logs ==
> 
> For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2531/
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [igt-dev] ✓ Fi.CI.IGT: success for igt/drm_read: Exercise waking up the next waiter
  2019-02-27 21:18   ` Antonio Argenziano
@ 2019-02-27 21:22     ` Chris Wilson
  2019-02-27 21:47       ` Antonio Argenziano
  0 siblings, 1 reply; 9+ messages in thread
From: Chris Wilson @ 2019-02-27 21:22 UTC (permalink / raw)
  To: Antonio Argenziano, Patchwork, igt-dev

Quoting Antonio Argenziano (2019-02-27 21:18:10)
> 
> 
> On 27/02/19 03:48, Patchwork wrote:
> > == Series Details ==
> > 
> > Series: igt/drm_read: Exercise waking up the next waiter
> > URL   : https://patchwork.freedesktop.org/series/57285/
> > State : success
> > 
> > == Summary ==
> > 
> > CI Bug Log - changes from CI_DRM_5664_full -> IGTPW_2531_full
> > ====================================================
> > 
> > Summary
> > -------
> > 
> >    **SUCCESS**
> > 
> >    No regressions found.
> > 
> >    External URL: https://patchwork.freedesktop.org/api/1.0/series/57285/revisions/1/
> > 
> > Possible new issues
> > -------------------
> > 
> >    Here are the unknown changes that may have been introduced in IGTPW_2531_full:
> > 
> > ### IGT changes ###
> > 
> > #### Possible regressions ####
> > 
> >    * {igt@drm_read@short-buffer-wakeup} (NEW):
> >      - shard-apl:          NOTRUN -> FAIL
> >      - shard-snb:          NOTRUN -> FAIL
> >      - shard-kbl:          NOTRUN -> FAIL
> >      - shard-hsw:          NOTRUN -> FAIL
> >      - shard-glk:          NOTRUN -> FAIL
> 
> Is it normal to have the run claim success if a new test is added and fails?

It's expected, let's call it a feature. New tests start as automatically
suppressed, so it falls out of that logic.

Now that Martin has the "its a brand spanking new test" bit worked out,
the next feature would be indeed to identify that an IGT run with a new
test is probably interested in that test result; and indeed such a
series should ideally not be committed until the failure has been
resolved.

It would also be useful if the NOTRUN -> {FAIL, PASS} be reported in the
issues.html so that we didn't have to go searching the full view for
them.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [igt-dev] ✓ Fi.CI.IGT: success for igt/drm_read: Exercise waking up the next waiter
  2019-02-27 21:22     ` Chris Wilson
@ 2019-02-27 21:47       ` Antonio Argenziano
  0 siblings, 0 replies; 9+ messages in thread
From: Antonio Argenziano @ 2019-02-27 21:47 UTC (permalink / raw)
  To: Chris Wilson, Patchwork, igt-dev



On 27/02/19 13:22, Chris Wilson wrote:
> Quoting Antonio Argenziano (2019-02-27 21:18:10)
>>
>>
>> On 27/02/19 03:48, Patchwork wrote:
>>> == Series Details ==
>>>
>>> Series: igt/drm_read: Exercise waking up the next waiter
>>> URL   : https://patchwork.freedesktop.org/series/57285/
>>> State : success
>>>
>>> == Summary ==
>>>
>>> CI Bug Log - changes from CI_DRM_5664_full -> IGTPW_2531_full
>>> ====================================================
>>>
>>> Summary
>>> -------
>>>
>>>     **SUCCESS**
>>>
>>>     No regressions found.
>>>
>>>     External URL: https://patchwork.freedesktop.org/api/1.0/series/57285/revisions/1/
>>>
>>> Possible new issues
>>> -------------------
>>>
>>>     Here are the unknown changes that may have been introduced in IGTPW_2531_full:
>>>
>>> ### IGT changes ###
>>>
>>> #### Possible regressions ####
>>>
>>>     * {igt@drm_read@short-buffer-wakeup} (NEW):
>>>       - shard-apl:          NOTRUN -> FAIL
>>>       - shard-snb:          NOTRUN -> FAIL
>>>       - shard-kbl:          NOTRUN -> FAIL
>>>       - shard-hsw:          NOTRUN -> FAIL
>>>       - shard-glk:          NOTRUN -> FAIL
>>
>> Is it normal to have the run claim success if a new test is added and fails?
> 
> It's expected, let's call it a feature. New tests start as automatically
> suppressed, so it falls out of that logic.
> 
> Now that Martin has the "its a brand spanking new test" bit worked out,
> the next feature would be indeed to identify that an IGT run with a new
> test is probably interested in that test result; and indeed such a
> series should ideally not be committed until the failure has been
> resolved.


OK, that makes sense.

Thanks,
Antonio

> 
> It would also be useful if the NOTRUN -> {FAIL, PASS} be reported in the
> issues.html so that we didn't have to go searching the full view for
> them.
> -Chris
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-02-27 21:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27 10:20 [igt-dev] [PATCH i-g-t] igt/drm_read: Exercise waking up the next waiter Chris Wilson
2019-02-27 10:45 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-02-27 11:48 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-02-27 11:50   ` Chris Wilson
2019-02-27 21:18   ` Antonio Argenziano
2019-02-27 21:22     ` Chris Wilson
2019-02-27 21:47       ` Antonio Argenziano
2019-02-27 20:46 ` [igt-dev] [PATCH i-g-t] " Ville Syrjälä
2019-02-27 21:13   ` Chris Wilson

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.