Re: [Intel-gfx] [PATCH i-g-t] lib/gt: Make use of dummyload library to create recursive batch

2018-07-13 Thread Chris Wilson
Quoting Antonio Argenziano (2018-07-13 19:22:41)
> 
> 
> On 13/07/18 03:06, Chris Wilson wrote:
> > From: Antonio Argenziano 
> > 
> > An hanging batch is nothing more than a spinning batch that never gets
> > stopped, so re-use the routines implemented in dummyload.c.
> > 
> > v2: Let caller decide spin loop size
> > v3: Only use loose loops for hangs (Chris)
> > v4: No requires
> > v5: Free the spinner
> > v6: Chamelium exists.
> > 
> > Signed-off-by: Antonio Argenziano 
> > Signed-off-by: Chris Wilson 
> > ---
> 
> >   /**
> > @@ -377,11 +329,11 @@ igt_hang_t igt_hang_ring(int fd, int ring)
> >*/
> >   void igt_post_hang_ring(int fd, igt_hang_t arg)
> >   {
> > - if (arg.handle == 0)
> > + if (!arg.spin)
> >   return;
> >   
> > - gem_sync(fd, arg.handle);
> > - gem_close(fd, arg.handle);
> > + gem_sync(fd, arg.spin->handle); /* Wait until it hangs */
> 
> I was expecting a poll spinner + manual reset here.

That would break some tests that are using this for hangcheck.
(Not break as such, just make them not work as intended.) More refinement
required, there's room for plenty here!

> 
> > + igt_spin_batch_free(fd, arg.spin);
> >   
> >   context_set_ban(fd, arg.ctx, arg.ban);
> >   
> > diff --git a/lib/igt_gt.h b/lib/igt_gt.h
> 
> > +
> > +#define igt_list_for_each_safe(pos, tmp, head, member) 
> >   \
> 
> (nitpick) extra tab.

So much for just moving it to a new header :)

> > + for (pos = igt_list_first_entry(head, pos, member), \
> > +  tmp = igt_list_next_entry(pos, member);\
> 
> I trust you and the compiler got all the places that needed changing.
> 
> Reviewed-by: Antonio Argenziano 
> 
> Thanks for picking-up this. At my speed it would have taken years :).

The task is only just begun.
-Sisyphus
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH i-g-t] lib/gt: Make use of dummyload library to create recursive batch

2018-07-13 Thread Antonio Argenziano



On 13/07/18 03:06, Chris Wilson wrote:

From: Antonio Argenziano 

An hanging batch is nothing more than a spinning batch that never gets
stopped, so re-use the routines implemented in dummyload.c.

v2: Let caller decide spin loop size
v3: Only use loose loops for hangs (Chris)
v4: No requires
v5: Free the spinner
v6: Chamelium exists.

Signed-off-by: Antonio Argenziano 
Signed-off-by: Chris Wilson 
---



  /**
@@ -377,11 +329,11 @@ igt_hang_t igt_hang_ring(int fd, int ring)
   */
  void igt_post_hang_ring(int fd, igt_hang_t arg)
  {
-   if (arg.handle == 0)
+   if (!arg.spin)
return;
  
-	gem_sync(fd, arg.handle);

-   gem_close(fd, arg.handle);
+   gem_sync(fd, arg.spin->handle); /* Wait until it hangs */


I was expecting a poll spinner + manual reset here.


+   igt_spin_batch_free(fd, arg.spin);
  
  	context_set_ban(fd, arg.ctx, arg.ban);
  
diff --git a/lib/igt_gt.h b/lib/igt_gt.h



+
+#define igt_list_for_each_safe(pos, tmp, head, member) \


(nitpick) extra tab.


+   for (pos = igt_list_first_entry(head, pos, member), \
+tmp = igt_list_next_entry(pos, member);\


I trust you and the compiler got all the places that needed changing.

Reviewed-by: Antonio Argenziano 

Thanks for picking-up this. At my speed it would have taken years :).
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] lib/gt: Make use of dummyload library to create recursive batch

2018-07-13 Thread Chris Wilson
From: Antonio Argenziano 

An hanging batch is nothing more than a spinning batch that never gets
stopped, so re-use the routines implemented in dummyload.c.

v2: Let caller decide spin loop size
v3: Only use loose loops for hangs (Chris)
v4: No requires
v5: Free the spinner
v6: Chamelium exists.

Signed-off-by: Antonio Argenziano 
Signed-off-by: Chris Wilson 
---
 lib/i915/gem_ring.c|   1 +
 lib/igt_aux.h  | 105 --
 lib/igt_chamelium.c|   3 +-
 lib/igt_core.h |   4 ++
 lib/igt_dummyload.h|   3 +-
 lib/igt_gt.c   |  72 -
 lib/igt_gt.h   |   9 +--
 lib/igt_kmod.c |   3 +-
 lib/igt_kmod.h |   2 +-
 lib/igt_list.h | 128 +
 tests/drv_hangman.c|   9 ++-
 tests/gem_concurrent_all.c |  23 ++-
 tests/gem_exec_schedule.c  |   4 +-
 tests/gem_mmap_gtt.c   |   2 +-
 tests/gem_reset_stats.c|   4 +-
 tests/gem_shrink.c |   2 +-
 tests/gem_softpin.c|   7 +-
 17 files changed, 177 insertions(+), 204 deletions(-)
 create mode 100644 lib/igt_list.h

diff --git a/lib/i915/gem_ring.c b/lib/i915/gem_ring.c
index 0708c8a2e..fdb9fc1b1 100644
--- a/lib/i915/gem_ring.c
+++ b/lib/i915/gem_ring.c
@@ -25,6 +25,7 @@
 
 #include 
 #include 
+#include 
 
 #include "intel_reg.h"
 #include "drmtest.h"
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 9a962881b..639a90778 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -31,7 +31,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -39,12 +38,6 @@
 extern drm_intel_bo **trash_bos;
 extern int num_trash_bos;
 
-/* signal interrupt helpers */
-
-#define MSEC_PER_SEC (1000)
-#define USEC_PER_SEC (1000*MSEC_PER_SEC)
-#define NSEC_PER_SEC (1000*USEC_PER_SEC)
-
 /* signal interrupt helpers */
 #define gettid() syscall(__NR_gettid)
 #define sigev_notify_thread_id _sigev_un._tid
@@ -295,104 +288,6 @@ void igt_set_module_param_int(const char *name, int val);
 int igt_terminate_process(int sig, const char *comm);
 void igt_lsof(const char *dpath);
 
-/*
- * This list data structure is a verbatim copy from wayland-util.h from the
- * Wayland project; except that wl_ prefix has been removed.
- */
-
-struct igt_list {
-   struct igt_list *prev;
-   struct igt_list *next;
-};
-
-#define __IGT_INIT_LIST(name) { &(name), &(name) }
-#define IGT_LIST(name) struct igt_list name = __IGT_INIT_LIST(name)
-
-static inline void igt_list_init(struct igt_list *list)
-{
-   list->prev = list;
-   list->next = list;
-}
-
-static inline void __igt_list_add(struct igt_list *list,
- struct igt_list *prev,
- struct igt_list *next)
-{
-   next->prev = list;
-   list->next = next;
-   list->prev = prev;
-   prev->next = list;
-}
-
-static inline void igt_list_add(struct igt_list *elm, struct igt_list *list)
-{
-   __igt_list_add(elm, list, list->next);
-}
-
-static inline void igt_list_add_tail(struct igt_list *elm,
-struct igt_list *list)
-{
-   __igt_list_add(elm, list->prev, list);
-}
-
-static inline void __igt_list_del(struct igt_list *prev, struct igt_list *next)
-{
-   next->prev = prev;
-   prev->next = next;
-}
-
-static inline void igt_list_del(struct igt_list *elm)
-{
-   __igt_list_del(elm->prev, elm->next);
-}
-
-static inline void igt_list_move(struct igt_list *elm, struct igt_list *list)
-{
-   igt_list_del(elm);
-   igt_list_add(elm, list);
-}
-
-static inline void igt_list_move_tail(struct igt_list *elm,
- struct igt_list *list)
-{
-   igt_list_del(elm);
-   igt_list_add_tail(elm, list);
-}
-
-static inline bool igt_list_empty(const struct igt_list *list)
-{
-   return list->next == list;
-}
-
-#define container_of(ptr, sample, member)  \
-   (typeof(sample))((char *)(ptr) - offsetof(typeof(*sample), member))
-
-#define igt_list_first_entry(head, pos, member) \
-   container_of((head)->next, (pos), member)
-#define igt_list_last_entry(head, pos, member) \
-   container_of((head)->prev, (pos), member)
-
-#define igt_list_next_entry(pos, member) \
-   container_of((pos)->member.next, (pos), member)
-#define igt_list_prev_entry(pos, member) \
-   container_of((pos)->member.prev, (pos), member)
-
-#define igt_list_for_each(pos, head, member)   \
-   for (pos = igt_list_first_entry(head, pos, member); \
-&pos->member != (head);\
-pos = igt_list_next_entry(pos, member))
-
-#define igt_list_for_each_reverse(pos, head, member)   \
-   for (pos = igt_list_last_entry(head, pos, member);  \
-&pos->member != (head);\
-pos = igt_lis

[Intel-gfx] [PATCH i-g-t] lib/gt: Make use of dummyload library to create recursive batch

2018-07-13 Thread Chris Wilson
From: Antonio Argenziano 

An hanging batch is nothing more than a spinning batch that never gets
stopped, so re-use the routines implemented in dummyload.c.

v2:
- Let caller decide spin loop size
- Now builds with meson.
v3:
- Only use loose loops for hangs (Chris)
v4:
- No requires
v5:
- Free the spinner

Signed-off-by: Antonio Argenziano 
Signed-off-by: Chris Wilson 
---
 lib/i915/gem_ring.c|   1 +
 lib/igt_aux.h  | 105 --
 lib/igt_core.h |   4 ++
 lib/igt_dummyload.h|   3 +-
 lib/igt_gt.c   |  72 -
 lib/igt_gt.h   |   9 +--
 lib/igt_kmod.c |   3 +-
 lib/igt_kmod.h |   2 +-
 lib/igt_list.h | 128 +
 tests/drv_hangman.c|   9 ++-
 tests/gem_concurrent_all.c |  23 ++-
 tests/gem_exec_schedule.c  |   4 +-
 tests/gem_mmap_gtt.c   |   2 +-
 tests/gem_reset_stats.c|   4 +-
 tests/gem_shrink.c |   2 +-
 tests/gem_softpin.c|   7 +-
 16 files changed, 175 insertions(+), 203 deletions(-)
 create mode 100644 lib/igt_list.h

diff --git a/lib/i915/gem_ring.c b/lib/i915/gem_ring.c
index 0708c8a2e..fdb9fc1b1 100644
--- a/lib/i915/gem_ring.c
+++ b/lib/i915/gem_ring.c
@@ -25,6 +25,7 @@
 
 #include 
 #include 
+#include 
 
 #include "intel_reg.h"
 #include "drmtest.h"
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 9a962881b..639a90778 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -31,7 +31,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -39,12 +38,6 @@
 extern drm_intel_bo **trash_bos;
 extern int num_trash_bos;
 
-/* signal interrupt helpers */
-
-#define MSEC_PER_SEC (1000)
-#define USEC_PER_SEC (1000*MSEC_PER_SEC)
-#define NSEC_PER_SEC (1000*USEC_PER_SEC)
-
 /* signal interrupt helpers */
 #define gettid() syscall(__NR_gettid)
 #define sigev_notify_thread_id _sigev_un._tid
@@ -295,104 +288,6 @@ void igt_set_module_param_int(const char *name, int val);
 int igt_terminate_process(int sig, const char *comm);
 void igt_lsof(const char *dpath);
 
-/*
- * This list data structure is a verbatim copy from wayland-util.h from the
- * Wayland project; except that wl_ prefix has been removed.
- */
-
-struct igt_list {
-   struct igt_list *prev;
-   struct igt_list *next;
-};
-
-#define __IGT_INIT_LIST(name) { &(name), &(name) }
-#define IGT_LIST(name) struct igt_list name = __IGT_INIT_LIST(name)
-
-static inline void igt_list_init(struct igt_list *list)
-{
-   list->prev = list;
-   list->next = list;
-}
-
-static inline void __igt_list_add(struct igt_list *list,
- struct igt_list *prev,
- struct igt_list *next)
-{
-   next->prev = list;
-   list->next = next;
-   list->prev = prev;
-   prev->next = list;
-}
-
-static inline void igt_list_add(struct igt_list *elm, struct igt_list *list)
-{
-   __igt_list_add(elm, list, list->next);
-}
-
-static inline void igt_list_add_tail(struct igt_list *elm,
-struct igt_list *list)
-{
-   __igt_list_add(elm, list->prev, list);
-}
-
-static inline void __igt_list_del(struct igt_list *prev, struct igt_list *next)
-{
-   next->prev = prev;
-   prev->next = next;
-}
-
-static inline void igt_list_del(struct igt_list *elm)
-{
-   __igt_list_del(elm->prev, elm->next);
-}
-
-static inline void igt_list_move(struct igt_list *elm, struct igt_list *list)
-{
-   igt_list_del(elm);
-   igt_list_add(elm, list);
-}
-
-static inline void igt_list_move_tail(struct igt_list *elm,
- struct igt_list *list)
-{
-   igt_list_del(elm);
-   igt_list_add_tail(elm, list);
-}
-
-static inline bool igt_list_empty(const struct igt_list *list)
-{
-   return list->next == list;
-}
-
-#define container_of(ptr, sample, member)  \
-   (typeof(sample))((char *)(ptr) - offsetof(typeof(*sample), member))
-
-#define igt_list_first_entry(head, pos, member) \
-   container_of((head)->next, (pos), member)
-#define igt_list_last_entry(head, pos, member) \
-   container_of((head)->prev, (pos), member)
-
-#define igt_list_next_entry(pos, member) \
-   container_of((pos)->member.next, (pos), member)
-#define igt_list_prev_entry(pos, member) \
-   container_of((pos)->member.prev, (pos), member)
-
-#define igt_list_for_each(pos, head, member)   \
-   for (pos = igt_list_first_entry(head, pos, member); \
-&pos->member != (head);\
-pos = igt_list_next_entry(pos, member))
-
-#define igt_list_for_each_reverse(pos, head, member)   \
-   for (pos = igt_list_last_entry(head, pos, member);  \
-&pos->member != (head);\
-