intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH i-g-t] syncobj_timeline: Tell the compiler to read from the thread
@ 2020-08-06 15:19 Chris Wilson
  2020-08-06 15:25 ` Lionel Landwerlin
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Wilson @ 2020-08-06 15:19 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, Chris Wilson

32bits-limit waits for the thread to indicate it has started by busy
spinning on a common variable. The compiler is clever and knows that the
variable cannot change within the thread, and turns it into an infinite
loop!

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 tests/syncobj_timeline.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/syncobj_timeline.c b/tests/syncobj_timeline.c
index be7dd2d1c..20375cdd3 100644
--- a/tests/syncobj_timeline.c
+++ b/tests/syncobj_timeline.c
@@ -1245,9 +1245,11 @@ test_32bits_limit(int fd)
 	uint64_t value, last_value;
 	int i;
 
-	igt_assert_eq(pthread_create(&thread, NULL, checker_thread_func, &thread_data), 0);
+	igt_assert_eq(pthread_create(&thread, NULL,
+				     checker_thread_func, &thread_data), 0);
 
-	while (!thread_data.started);
+	while (!READ_ONCE(thread_data.started))
+		;
 
 	for (i = 0; i < ARRAY_SIZE(points); i++) {
 		int fence = sw_sync_timeline_create_fence(timeline, i + 1);
-- 
2.28.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [Intel-gfx] [PATCH i-g-t] syncobj_timeline: Tell the compiler to read from the thread
  2020-08-06 15:19 [Intel-gfx] [PATCH i-g-t] syncobj_timeline: Tell the compiler to read from the thread Chris Wilson
@ 2020-08-06 15:25 ` Lionel Landwerlin
  0 siblings, 0 replies; 2+ messages in thread
From: Lionel Landwerlin @ 2020-08-06 15:25 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx; +Cc: igt-dev

On 06/08/2020 18:19, Chris Wilson wrote:
> 32bits-limit waits for the thread to indicate it has started by busy
> spinning on a common variable. The compiler is clever and knows that the
> variable cannot change within the thread, and turns it into an infinite
> loop!
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>


Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>

> ---
>   tests/syncobj_timeline.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tests/syncobj_timeline.c b/tests/syncobj_timeline.c
> index be7dd2d1c..20375cdd3 100644
> --- a/tests/syncobj_timeline.c
> +++ b/tests/syncobj_timeline.c
> @@ -1245,9 +1245,11 @@ test_32bits_limit(int fd)
>   	uint64_t value, last_value;
>   	int i;
>   
> -	igt_assert_eq(pthread_create(&thread, NULL, checker_thread_func, &thread_data), 0);
> +	igt_assert_eq(pthread_create(&thread, NULL,
> +				     checker_thread_func, &thread_data), 0);
>   
> -	while (!thread_data.started);
> +	while (!READ_ONCE(thread_data.started))
> +		;
>   
>   	for (i = 0; i < ARRAY_SIZE(points); i++) {
>   		int fence = sw_sync_timeline_create_fence(timeline, i + 1);


_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2020-08-06 15:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-06 15:19 [Intel-gfx] [PATCH i-g-t] syncobj_timeline: Tell the compiler to read from the thread Chris Wilson
2020-08-06 15:25 ` Lionel Landwerlin

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).