Skip to contentSkip to conversation

lib: Silence Valgrind warning in synce_fence_status

PATCH In review Tvrtko Ursulin 4 participants 9 messages Jun 27, 2019 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: Silence Valgrind warning in synce_fence_status

From: Tvrtko Ursulin <[email protected]>

Let Valgrind know the ioctl initializes the passed in info block to reduce the noise while debugging.

---
 lib/sw_sync.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/sw_sync.c +11 -0
index f208603312c2..73f3f7015d9d 100644
@@ -41,6 +41,15 @@
 #include "drmtest.h"
 #include "ioctl_wrappers.h"
 
+#ifdef HAVE_VALGRIND
+#include <valgrind/valgrind.h>
+#include <valgrind/memcheck.h>
+
+#define VG(x) x
+#else
+#define VG(x) do {} while (0)
+#endif
+
 /**
  * SECTION:sw_sync
  * @short_description: Software sync (fencing) support library
@@ -218,6 +227,8 @@ int sync_fence_status(int fence)
 	if (file_info.num_fences != 1)
 		return -EINVAL;
 
+	VG(VALGRIND_MAKE_MEM_DEFINED(&fence_info, sizeof(fence_info)));
+
 	return fence_info.status;
 }
 
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

Quoting Tvrtko Ursulin (2019-06-27 13:55:21)

Quoted 31 lines

From: Tvrtko Ursulin <[email protected]>

Let Valgrind know the ioctl initializes the passed in info block to reduce the noise while debugging.

---
 lib/sw_sync.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/sw_sync.c +9 -0
index f208603312c2..73f3f7015d9d 100644
@@ -41,6 +41,15 @@
 #include "drmtest.h"
 #include "ioctl_wrappers.h"
 
+#ifdef HAVE_VALGRIND
+#include <valgrind/valgrind.h>
+#include <valgrind/memcheck.h>
+
+#define VG(x) x
+#else
+#define VG(x) do {} while (0)
+#endif
+
 /**
  * SECTION:sw_sync
  * @short_description: Software sync (fencing) support library

lib/sw_sync.c int sync_fence_status(int fence) · line 228

Quoted 2 lines
lib/sw_sync.c +0 -0
@@ -218,6 +227,8 @@ int sync_fence_status(int fence)
        if (file_info.num_fences != 1)
                return -EINVAL;

^ Otherwise known as lets pretend we never saw that kernel bug.
https://patchwork.freedesktop.org/patch/311883/?series=62278&rev=1

An example of why igt should not be filtering the kernel.

Just complaining because Petri found a bug in one of tests that is being blocked by no one reviewing the kernel fix that is blocking fixing the library to allow the bug fix in the test.

lib/sw_sync.c int sync_fence_status(int fence) · line 230

Quoted 1 line
lib/sw_sync.c +1 -0
+       VG(VALGRIND_MAKE_MEM_DEFINED(&fence_info, sizeof(fence_info)));

More fun would be to

struct sync_fence_info fence_info = { .status = -ENOSYS };

So that valgrind knows it is initialised and we reliably report an error if the kernel fails to fill in the struct.
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#2 lore raw
Quoted 38 lines · Chris Wilson

Quoting Tvrtko Ursulin (2019-06-27 13:55:21)

Quoted 31 lines

From: Tvrtko Ursulin <[email protected]>

Let Valgrind know the ioctl initializes the passed in info block to reduce the noise while debugging.

---
  lib/sw_sync.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
lib/sw_sync.c +9 -0
index f208603312c2..73f3f7015d9d 100644
@@ -41,6 +41,15 @@
  #include "drmtest.h"
  #include "ioctl_wrappers.h"
 
+#ifdef HAVE_VALGRIND
+#include <valgrind/valgrind.h>
+#include <valgrind/memcheck.h>
+
+#define VG(x) x
+#else
+#define VG(x) do {} while (0)
+#endif
+
  /**
   * SECTION:sw_sync
   * @short_description: Software sync (fencing) support library

lib/sw_sync.c int sync_fence_status(int fence) · line 228

Quoted 2 lines
lib/sw_sync.c +0 -0
@@ -218,6 +227,8 @@ int sync_fence_status(int fence)
         if (file_info.num_fences != 1)
                 return -EINVAL;

^ Otherwise known as lets pretend we never saw that kernel bug.
https://patchwork.freedesktop.org/patch/311883/?series=62278&rev=1

Quoted 1 line

An example of why igt should not be filtering the kernel.

You think the library helper shouldn't be testing for num_fences == 1, eg the same as passed in? It is questionable that it should return -EINVAL in this case I agree with that. If that's what you meant with filtering.

Quoted 3 lines

Just complaining because Petri found a bug in one of tests that is being blocked by no one reviewing the kernel fix that is blocking fixing the library to allow the bug fix in the test.

It's only related because it's the same ioctl. :) But...

Quoted 8 lines

lib/sw_sync.c int sync_fence_status(int fence) · line 230

Quoted 1 line
lib/sw_sync.c +1 -0
+       VG(VALGRIND_MAKE_MEM_DEFINED(&fence_info, sizeof(fence_info)));

More fun would be to

struct sync_fence_info fence_info = { .status = -ENOSYS };

So that valgrind knows it is initialised and we reliably report an error if the kernel fails to fill in the struct.

... sure, this is also okay. For me -ENOSYS is not strictly needed at this level. It would be more of a unit test for the ioctl, not belonging to the library helper, but it is also fine to inject some more explicit trash so it can be caught even if there are no specific unit tests.

I don't also see a problem with Valgrind annotation. It doesn't hide anything, nor does it sanitises. But yes, it is not needed if we go for -ENOSYS trick.

Regards,

Tvrtko
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

Quoting Tvrtko Ursulin (2019-06-27 14:59:10)

Quoted 11 lines · Chris Wilson
Quoted 8 lines
Quoted 1 line

+ VG(VALGRIND_MAKE_MEM_DEFINED(&fence_info, sizeof(fence_info)));

More fun would be to

struct sync_fence_info fence_info = { .status = -ENOSYS };

So that valgrind knows it is initialised and we reliably report an error if the kernel fails to fill in the struct.

Quoted 8 lines

... sure, this is also okay. For me -ENOSYS is not strictly needed at this level. It would be more of a unit test for the ioctl, not belonging to the library helper, but it is also fine to inject some more explicit trash so it can be caught even if there are no specific unit tests.

I don't also see a problem with Valgrind annotation. It doesn't hide anything, nor does it sanitises. But yes, it is not needed if we go for -ENOSYS trick.

That's all I was thinking, two birds one stone. I think it is a bonus if we don't paper over the kernel randomly serving up garbage -- but at the same time random failures are not the easiest to debug. But at least they serve as canaries.
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#4 lore raw
In reply to Tvrtko Ursulin
Quoted 15 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Let Valgrind know the ioctl initializes the passed in info block to reduce the noise while debugging.

---
 lib/sw_sync.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/sw_sync.c +0 -0
index f208603312c2..73f3f7015d9d 100644

lib/sw_sync.c line 50

Quoted 10 lines
lib/sw_sync.c +7 -0
@@ -41,6 +41,15 @@
 #include "drmtest.h"
 #include "ioctl_wrappers.h"
 
+#ifdef HAVE_VALGRIND
+#include <valgrind/valgrind.h>
+#include <valgrind/memcheck.h>
+
+#define VG(x) x
+#else
+#define VG(x) do {} while (0)

OOC, why not just

#define VALGRIND_MAKE_MEM_DEFINED(...)

BR,
Jani.

Quoted 13 lines
lib/sw_sync.c +4 -0
+#endif
+
 /**
  * SECTION:sw_sync
  * @short_description: Software sync (fencing) support library
@@ -218,6 +227,8 @@ int sync_fence_status(int fence)
 	if (file_info.num_fences != 1)
 		return -EINVAL;
 
+	VG(VALGRIND_MAKE_MEM_DEFINED(&fence_info, sizeof(fence_info)));
+
 	return fence_info.status;
 }
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Quoting Jani Nikula (2019-06-27 14:59:52)

Quoted 29 lines · Tvrtko Ursulin
Quoted 15 lines

From: Tvrtko Ursulin <[email protected]>

Let Valgrind know the ioctl initializes the passed in info block to reduce the noise while debugging.

---
 lib/sw_sync.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/sw_sync.c +0 -0
index f208603312c2..73f3f7015d9d 100644

lib/sw_sync.c line 50

Quoted 10 lines
lib/sw_sync.c +7 -0
@@ -41,6 +41,15 @@
 #include "drmtest.h"
 #include "ioctl_wrappers.h"
 
+#ifdef HAVE_VALGRIND
+#include <valgrind/valgrind.h>
+#include <valgrind/memcheck.h>
+
+#define VG(x) x
+#else
+#define VG(x) do {} while (0)

OOC, why not just

Quoted 1 line

#define VALGRIND_MAKE_MEM_DEFINED(...)

Once upon a time, in a project far far away, VG() was used to conditionally compile code for extra debug under valgrind and so the pattern took root.
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#6 lore raw
In reply to Jani Nikula
Quoted 29 lines · Jani Nikula
Quoted 15 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Let Valgrind know the ioctl initializes the passed in info block to reduce the noise while debugging.

---
  lib/sw_sync.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
lib/sw_sync.c +0 -0
index f208603312c2..73f3f7015d9d 100644

lib/sw_sync.c line 50

Quoted 10 lines
lib/sw_sync.c +7 -0
@@ -41,6 +41,15 @@
  #include "drmtest.h"
  #include "ioctl_wrappers.h"
 
+#ifdef HAVE_VALGRIND
+#include <valgrind/valgrind.h>
+#include <valgrind/memcheck.h>
+
+#define VG(x) x
+#else
+#define VG(x) do {} while (0)

OOC, why not just

Quoted 1 line

#define VALGRIND_MAKE_MEM_DEFINED(...)

Copy and paste isn't an established practice? :))

Regards,

Tvrtko
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#7 lore raw
In reply to Jani Nikula
Quoted 29 lines · Jani Nikula
Quoted 15 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Let Valgrind know the ioctl initializes the passed in info block to reduce the noise while debugging.

---
 lib/sw_sync.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/sw_sync.c +0 -0
index f208603312c2..73f3f7015d9d 100644

lib/sw_sync.c line 50

Quoted 10 lines
lib/sw_sync.c +7 -0
@@ -41,6 +41,15 @@
 #include "drmtest.h"
 #include "ioctl_wrappers.h"
 
+#ifdef HAVE_VALGRIND
+#include <valgrind/valgrind.h>
+#include <valgrind/memcheck.h>
+
+#define VG(x) x
+#else
+#define VG(x) do {} while (0)

OOC, why not just

Quoted 1 line

#define VALGRIND_MAKE_MEM_DEFINED(...)

And to underline, this is not a request to change anything!

BR,
Jani.

Quoted 17 lines

BR,
Jani.

Quoted 13 lines
lib/sw_sync.c +4 -0
+#endif
+
 /**
  * SECTION:sw_sync
  * @short_description: Software sync (fencing) support library
@@ -218,6 +227,8 @@ int sync_fence_status(int fence)
 	if (file_info.num_fences != 1)
 		return -EINVAL;
 
+	VG(VALGRIND_MAKE_MEM_DEFINED(&fence_info, sizeof(fence_info)));
+
 	return fence_info.status;
 }
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#8 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for lib: Silence Valgrind warning in synce_fence_status

In reply to Tvrtko Ursulin
== Series Details ==

== Series Details ==

Series: lib: Silence Valgrind warning in synce_fence_status
URL : https://patchwork.freedesktop.org/series/62855/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_6375 -> IGTPW_3206
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_3206 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_3206, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

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

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

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_pm_rpm@module-reload:
- fi-cml-u: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-cml-u/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/fi-cml-u/igt@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_ctx_switch@basic-default:
- fi-icl-guc: [PASS][3] -> [INCOMPLETE][4] ([fdo#107713] / [fdo#108569])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-icl-guc/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/fi-icl-guc/igt@[email protected]

* igt@i915_module_load@reload:
- fi-blb-e6850: [PASS][5] -> [INCOMPLETE][6] ([fdo#107718])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-blb-e6850/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/fi-blb-e6850/igt@[email protected]

* igt@i915_selftest@live_blt:
- fi-skl-iommu: [PASS][7] -> [INCOMPLETE][8] ([fdo#108602])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-skl-iommu/igt@i915_selftest@live_blt.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/fi-skl-iommu/igt@i915_selftest@live_blt.html

* igt@kms_busy@basic-flip-a:
- fi-kbl-7567u: [PASS][9] -> [SKIP][10] ([fdo#109271] / [fdo#109278]) +2 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-kbl-7567u/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/fi-kbl-7567u/igt@[email protected]

* igt@kms_chamelium@dp-crc-fast:
- fi-icl-u2: [PASS][11] -> [FAIL][12] ([fdo#109635 ] / [fdo#110387])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-icl-u2/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/fi-icl-u2/igt@[email protected]

#### Possible fixes ####

* igt@kms_chamelium@common-hpd-after-suspend:
- fi-kbl-7567u: [WARN][13] ([fdo#109380]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-kbl-7567u/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/fi-kbl-7567u/igt@[email protected]

* igt@kms_pipe_crc_basic@read-crc-pipe-c:
- fi-kbl-7567u: [SKIP][15] ([fdo#109271]) -> [PASS][16] +23 similar issues
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-kbl-7567u/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/fi-kbl-7567u/igt@[email protected]

* igt@prime_self_import@basic-with_two_bos:
- fi-icl-u3: [DMESG-WARN][17] ([fdo#107724]) -> [PASS][18] +1 similar issue
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-icl-u3/igt@prime_self_import@basic-with_two_bos.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/fi-icl-u3/igt@prime_self_import@basic-with_two_bos.html

#### Warnings ####

* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-kbl-guc: [FAIL][19] ([fdo#110829]) -> [SKIP][20] ([fdo#109271])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-kbl-guc/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/fi-kbl-guc/igt@[email protected]

[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#108602]: https://bugs.freedesktop.org/show_bug.cgi?id=108602
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109380]: https://bugs.freedesktop.org/show_bug.cgi?id=109380
[fdo#109635 ]: https://bugs.freedesktop.org/show_bug.cgi?id=109635
[fdo#110387]: https://bugs.freedesktop.org/show_bug.cgi?id=110387
[fdo#110829]: https://bugs.freedesktop.org/show_bug.cgi?id=110829

Participating hosts (53 -> 45)
------------------------------

Additional (1): fi-skl-6600u
Missing (9): fi-kbl-soraka fi-ilk-m540 fi-skl-gvtdvm fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus

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

* IGT: IGT_5070 -> IGTPW_3206

CI_DRM_6375: 44b3a556c682d3ae6d1cf94f6ec7c155ebeeff50 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3206: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/
IGT_5070: 250475af7bc52ba64956e6b35591fdd7176954d7 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3206/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev