All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 0/2] igt: Add a testsuite to validate VC4 MADV ioctl
@ 2017-09-27 11:51 Boris Brezillon
  2017-09-27 11:51 ` [PATCH i-g-t 1/2] igt: Add a helper function to mark BOs purgeable Boris Brezillon
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Boris Brezillon @ 2017-09-27 11:51 UTC (permalink / raw)
  To: Intel GFX discussion

Hello,
    
This patchset adds VC4 specific tests to validate the
DRM_IOCTL_VC4_GEM_MADVISE ioctl.

Note that this series depends on kernel/libdrm code that has not been
accepted yet and is just provided to show reviewers how the ioctl can be
used and what to expect from it.
    
Please do not consider this for inclusion in IGT until the kernel and
libdrm part have been accepted.
    
Thanks,
    
Boris

Boris Brezillon (2):
  igt: Add a helper function to mark BOs purgeable
  igt: Add VC4 purgeable BO tests

 lib/igt_vc4.c            |  12 +++
 lib/igt_vc4.h            |   1 +
 tests/Makefile.sources   |   1 +
 tests/vc4_purgeable_bo.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 288 insertions(+)
 create mode 100644 tests/vc4_purgeable_bo.c

-- 
2.11.0

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

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

* [PATCH i-g-t 1/2] igt: Add a helper function to mark BOs purgeable
  2017-09-27 11:51 [PATCH i-g-t 0/2] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
@ 2017-09-27 11:51 ` Boris Brezillon
  2017-09-27 11:51 ` [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests Boris Brezillon
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Boris Brezillon @ 2017-09-27 11:51 UTC (permalink / raw)
  To: Intel GFX discussion

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 lib/igt_vc4.c | 12 ++++++++++++
 lib/igt_vc4.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/lib/igt_vc4.c b/lib/igt_vc4.c
index c4682f5688f1..b75c063204ec 100644
--- a/lib/igt_vc4.c
+++ b/lib/igt_vc4.c
@@ -128,3 +128,15 @@ igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot)
 	else
 		return ptr;
 }
+
+bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable)
+{
+	struct drm_vc4_gem_madvise arg = {
+		.handle = handle,
+		.madv = purgeable ? VC4_MADV_DONTNEED : VC4_MADV_WILLNEED,
+	};
+
+	do_ioctl(fd, DRM_IOCTL_VC4_GEM_MADVISE, &arg);
+
+	return arg.retained;
+}
diff --git a/lib/igt_vc4.h b/lib/igt_vc4.h
index e9252461c951..9f0fc59910f6 100644
--- a/lib/igt_vc4.h
+++ b/lib/igt_vc4.h
@@ -27,5 +27,6 @@
 uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval);
 int igt_vc4_create_bo(int fd, size_t size);
 void *igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot);
+bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable);
 
 #endif /* IGT_VC4_H */
-- 
2.11.0

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

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

* [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests
  2017-09-27 11:51 [PATCH i-g-t 0/2] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
  2017-09-27 11:51 ` [PATCH i-g-t 1/2] igt: Add a helper function to mark BOs purgeable Boris Brezillon
@ 2017-09-27 11:51 ` Boris Brezillon
  2017-09-27 11:57   ` Petri Latvala
                     ` (2 more replies)
  2017-09-27 12:25 ` ✓ Fi.CI.BAT: success for igt: Add a testsuite to validate VC4 MADV ioctl Patchwork
                   ` (2 subsequent siblings)
  4 siblings, 3 replies; 14+ messages in thread
From: Boris Brezillon @ 2017-09-27 11:51 UTC (permalink / raw)
  To: Intel GFX discussion

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=a, Size: 8147 bytes --]

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 tests/Makefile.sources   |   1 +
 tests/vc4_purgeable_bo.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 275 insertions(+)
 create mode 100644 tests/vc4_purgeable_bo.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 0adc28a014d2..c78ac9d27921 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -8,6 +8,7 @@ VC4_TESTS = \
 	vc4_create_bo \
 	vc4_dmabuf_poll \
 	vc4_lookup_fail \
+	vc4_purgeable_bo \
 	vc4_wait_bo \
 	vc4_wait_seqno \
 	$(NULL)
diff --git a/tests/vc4_purgeable_bo.c b/tests/vc4_purgeable_bo.c
new file mode 100644
index 000000000000..e3eaf0c24563
--- /dev/null
+++ b/tests/vc4_purgeable_bo.c
@@ -0,0 +1,274 @@
+/*
+ * Copyright © 2017 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+#include "igt_vc4.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include "vc4_drm.h"
+
+struct igt_vc4_bo {
+	struct igt_list node;
+	int handle;
+	void *map;
+	size_t size;
+};
+
+static jmp_buf jmp;
+
+static void __attribute__((noreturn)) sigtrap(int sig)
+{
+	longjmp(jmp, sig);
+}
+
+static void igt_vc4_alloc_mmap_max_bo(int fd, struct igt_list *list,
+				      size_t size)
+{
+	struct igt_vc4_bo *bo;
+	struct drm_vc4_create_bo create = {
+		.size = size,
+	};
+
+	while (true) {
+		if (igt_ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create))
+			break;
+
+		bo = malloc(sizeof(*bo));
+		igt_assert(bo);
+		bo->handle = create.handle;
+		bo->size = create.size;
+		bo->map = igt_vc4_mmap_bo(fd, bo->handle, bo->size,
+					  PROT_READ | PROT_WRITE);
+		igt_list_add_tail(&bo->node, list);
+	}
+}
+
+static void igt_vc4_unmap_free_bo_pool(int fd, struct igt_list *list)
+{
+	struct igt_vc4_bo *bo;
+
+	while (!igt_list_empty(list)) {
+		bo = igt_list_first_entry(list, bo, node);
+		igt_assert(bo);
+		igt_list_del(&bo->node);
+		munmap(bo->map, bo->size);
+		gem_close(fd, bo->handle);
+		free(bo);
+	}
+}
+
+static void igt_vc4_trigger_purge(int fd)
+{
+	struct igt_list list;
+
+	igt_list_init(&list);
+
+	/* Try to allocate as much as we can to trigger a purge. */
+	igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
+	igt_assert(!igt_list_empty(&list));
+	igt_vc4_unmap_free_bo_pool(fd, &list);
+}
+
+igt_main
+{
+	struct igt_vc4_bo *bo;
+	struct igt_list list;
+	uint32_t *map;
+	int fd, ret;
+
+	igt_fixture {
+		fd = drm_open_driver(DRIVER_VC4);
+		igt_list_init(&list);
+
+		igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
+		igt_assert(!igt_list_empty(&list));
+	}
+
+	igt_subtest("mark-purgeable") {
+		igt_list_for_each(bo, &list, node)
+			igt_vc4_purgeable_bo(fd, bo->handle, true);
+
+		igt_list_for_each(bo, &list, node)
+			igt_vc4_purgeable_bo(fd, bo->handle, false);
+	}
+
+	igt_subtest("mark-purgeable-twice") {
+		bo = igt_list_first_entry(&list, bo, node);
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+		igt_vc4_purgeable_bo(fd, bo->handle, false);
+	}
+
+	igt_subtest("mark-unpurgeable-twice") {
+		bo = igt_list_first_entry(&list, bo, node);
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+		igt_vc4_purgeable_bo(fd, bo->handle, false);
+		igt_vc4_purgeable_bo(fd, bo->handle, false);
+	}
+
+	igt_subtest("access-purgeable-bo-mem") {
+		bo = igt_list_first_entry(&list, bo, node);
+		map = (uint32_t *)bo->map;
+
+		/* Mark the BO as purgeable, but do not try to allocate a new
+		 * BO. This should leave the BO in a non-purged state unless
+		 * someone else tries to allocated a new BO.
+		 */
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+
+		/* Accessing a purgeable BO may generate a SIGBUS event if the
+		 * BO has been purged by the system in the meantime.
+		 */
+		signal(SIGSEGV, sigtrap);
+		signal(SIGBUS, sigtrap);
+		ret = setjmp(jmp);
+		if (!ret)
+			*map = 0xdeadbeef;
+		else
+			igt_assert(ret == SIGBUS);
+		signal(SIGBUS, SIG_DFL);
+		signal(SIGSEGV, SIG_DFL);
+	}
+
+	igt_subtest("access-purged-bo-mem") {
+		struct igt_list tmplist;
+
+		igt_list_init(&tmplist);
+
+		/* Mark the first BO in our list as purgeable and try to
+		 * allocate a new one. This should trigger a purge and render
+		 * the first BO inaccessible.
+		 */
+		bo = igt_list_first_entry(&list, bo, node);
+		map = (uint32_t *)bo->map;
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+
+		/* Trigger a purge. */
+		igt_vc4_trigger_purge(fd);
+
+		/* Accessing a purged BO should generate a SIGBUS event. */
+		signal(SIGSEGV, sigtrap);
+		signal(SIGBUS, sigtrap);
+		ret = setjmp(jmp);
+		if (!ret)
+			*map = 0;
+		else
+			igt_assert(ret == SIGBUS);
+		signal(SIGBUS, SIG_DFL);
+		signal(SIGSEGV, SIG_DFL);
+		igt_vc4_purgeable_bo(fd, bo->handle, false);
+	}
+
+	igt_subtest("mark-unpurgeable-not-purged") {
+		igt_list_for_each(bo, &list, node) {
+			map = (uint32_t *)bo->map;
+			*map = 0xdeadbeef;
+			igt_vc4_purgeable_bo(fd, bo->handle, true);
+		}
+
+		igt_list_for_each(bo, &list, node) {
+			map = (uint32_t *)bo->map;
+			igt_assert(igt_vc4_purgeable_bo(fd, bo->handle, false));
+			igt_assert(*map == 0xdeadbeef);
+		}
+	}
+
+	igt_subtest("mark-unpurgeable-purged") {
+		igt_list_for_each(bo, &list, node) {
+			map = (uint32_t *)bo->map;
+			*map = 0xdeadbeef;
+			igt_vc4_purgeable_bo(fd, bo->handle, true);
+		}
+
+		/* Trigger a purge. */
+		igt_vc4_trigger_purge(fd);
+
+		igt_list_for_each(bo, &list, node) {
+			map = (uint32_t *)bo->map;
+			igt_assert(!igt_vc4_purgeable_bo(fd, bo->handle, false));
+			igt_assert(*map != 0xdeadbeef);
+		}
+	}
+
+	igt_subtest("mark-unpurgeable-nomem") {
+		struct igt_list tmplist;
+
+		igt_list_for_each(bo, &list, node)
+			igt_vc4_purgeable_bo(fd, bo->handle, true);
+
+		/* Deplete the CMA pool by allocating as much as we can. This
+		 * should trigger a purge.
+		 */
+		igt_list_init(&tmplist);
+		igt_vc4_alloc_mmap_max_bo(fd, &tmplist, 64 * 1024);
+		igt_assert(!igt_list_empty(&tmplist));
+
+		/* Now try to mark all BOs in the intial pool as unpurgeable.
+		 * We shoud see a failure at some point.
+		 */
+		igt_list_for_each(bo, &list, node) {
+			struct drm_vc4_gem_madvise arg = {
+				.handle = bo->handle,
+				.madv = VC4_MADV_WILLNEED,
+			};
+
+			ret = igt_ioctl(fd, DRM_IOCTL_VC4_GEM_MADVISE, &arg);
+			if (ret)
+				break;
+		}
+
+		igt_assert(ret && errno == ENOMEM);
+
+		/* Release all BOs from the tmplist and try again. This time it
+		 * should succeed.
+		 */
+		igt_vc4_unmap_free_bo_pool(fd, &tmplist);
+		igt_list_for_each(bo, &list, node)
+			igt_vc4_purgeable_bo(fd, bo->handle, false);
+	}
+
+	igt_subtest("free-purged-bo") {
+		bo = igt_list_first_entry(&list, bo, node);
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+
+		/* Trigger a purge. */
+		igt_vc4_trigger_purge(fd);
+
+		igt_list_del(&bo->node);
+		munmap(bo->map, bo->size);
+		gem_close(fd, bo->handle);
+		free(bo);
+	}
+
+	igt_fixture {
+		igt_vc4_unmap_free_bo_pool(fd, &list);
+		close(fd);
+	}
+}
-- 
2.11.0


[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

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

* Re: [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests
  2017-09-27 11:51 ` [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests Boris Brezillon
@ 2017-09-27 11:57   ` Petri Latvala
  2017-09-27 12:43     ` Boris Brezillon
  2017-09-27 12:07   ` Chris Wilson
  2017-09-27 18:08   ` Eric Anholt
  2 siblings, 1 reply; 14+ messages in thread
From: Petri Latvala @ 2017-09-27 11:57 UTC (permalink / raw)
  To: Boris Brezillon; +Cc: Intel GFX discussion

On Wed, Sep 27, 2017 at 01:51:18PM +0200, Boris Brezillon wrote:
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
>  tests/Makefile.sources   |   1 +
>  tests/vc4_purgeable_bo.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 275 insertions(+)
>  create mode 100644 tests/vc4_purgeable_bo.c
> 
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 0adc28a014d2..c78ac9d27921 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -8,6 +8,7 @@ VC4_TESTS = \
>  	vc4_create_bo \
>  	vc4_dmabuf_poll \
>  	vc4_lookup_fail \
> +	vc4_purgeable_bo \
>  	vc4_wait_bo \
>  	vc4_wait_seqno \
>  	$(NULL)


For meson, squash this in:


diff --git a/tests/meson.build b/tests/meson.build
index 1c619179..8f94e3c4 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -243,6 +243,7 @@ if libdrm_vc4.found()
 		'vc4_create_bo',
 		'vc4_dmabuf_poll',
 		'vc4_lookup_fail',
+		'vc4_purgeable_bo',
 		'vc4_wait_bo',
 		'vc4_wait_seqno',
 	]



-- 
Petri Latvala



> diff --git a/tests/vc4_purgeable_bo.c b/tests/vc4_purgeable_bo.c
> new file mode 100644
> index 000000000000..e3eaf0c24563
> --- /dev/null
> +++ b/tests/vc4_purgeable_bo.c
> @@ -0,0 +1,274 @@
> +/*
> + * Copyright © 2017 Broadcom
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include "igt.h"
> +#include "igt_vc4.h"
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <fcntl.h>
> +#include <inttypes.h>
> +#include <errno.h>
> +#include <sys/stat.h>
> +#include <sys/ioctl.h>
> +#include "vc4_drm.h"
> +
> +struct igt_vc4_bo {
> +	struct igt_list node;
> +	int handle;
> +	void *map;
> +	size_t size;
> +};
> +
> +static jmp_buf jmp;
> +
> +static void __attribute__((noreturn)) sigtrap(int sig)
> +{
> +	longjmp(jmp, sig);
> +}
> +
> +static void igt_vc4_alloc_mmap_max_bo(int fd, struct igt_list *list,
> +				      size_t size)
> +{
> +	struct igt_vc4_bo *bo;
> +	struct drm_vc4_create_bo create = {
> +		.size = size,
> +	};
> +
> +	while (true) {
> +		if (igt_ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create))
> +			break;
> +
> +		bo = malloc(sizeof(*bo));
> +		igt_assert(bo);
> +		bo->handle = create.handle;
> +		bo->size = create.size;
> +		bo->map = igt_vc4_mmap_bo(fd, bo->handle, bo->size,
> +					  PROT_READ | PROT_WRITE);
> +		igt_list_add_tail(&bo->node, list);
> +	}
> +}
> +
> +static void igt_vc4_unmap_free_bo_pool(int fd, struct igt_list *list)
> +{
> +	struct igt_vc4_bo *bo;
> +
> +	while (!igt_list_empty(list)) {
> +		bo = igt_list_first_entry(list, bo, node);
> +		igt_assert(bo);
> +		igt_list_del(&bo->node);
> +		munmap(bo->map, bo->size);
> +		gem_close(fd, bo->handle);
> +		free(bo);
> +	}
> +}
> +
> +static void igt_vc4_trigger_purge(int fd)
> +{
> +	struct igt_list list;
> +
> +	igt_list_init(&list);
> +
> +	/* Try to allocate as much as we can to trigger a purge. */
> +	igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
> +	igt_assert(!igt_list_empty(&list));
> +	igt_vc4_unmap_free_bo_pool(fd, &list);
> +}
> +
> +igt_main
> +{
> +	struct igt_vc4_bo *bo;
> +	struct igt_list list;
> +	uint32_t *map;
> +	int fd, ret;
> +
> +	igt_fixture {
> +		fd = drm_open_driver(DRIVER_VC4);
> +		igt_list_init(&list);
> +
> +		igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
> +		igt_assert(!igt_list_empty(&list));
> +	}
> +
> +	igt_subtest("mark-purgeable") {
> +		igt_list_for_each(bo, &list, node)
> +			igt_vc4_purgeable_bo(fd, bo->handle, true);
> +
> +		igt_list_for_each(bo, &list, node)
> +			igt_vc4_purgeable_bo(fd, bo->handle, false);
> +	}
> +
> +	igt_subtest("mark-purgeable-twice") {
> +		bo = igt_list_first_entry(&list, bo, node);
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> +	}
> +
> +	igt_subtest("mark-unpurgeable-twice") {
> +		bo = igt_list_first_entry(&list, bo, node);
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> +	}
> +
> +	igt_subtest("access-purgeable-bo-mem") {
> +		bo = igt_list_first_entry(&list, bo, node);
> +		map = (uint32_t *)bo->map;
> +
> +		/* Mark the BO as purgeable, but do not try to allocate a new
> +		 * BO. This should leave the BO in a non-purged state unless
> +		 * someone else tries to allocated a new BO.
> +		 */
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +
> +		/* Accessing a purgeable BO may generate a SIGBUS event if the
> +		 * BO has been purged by the system in the meantime.
> +		 */
> +		signal(SIGSEGV, sigtrap);
> +		signal(SIGBUS, sigtrap);
> +		ret = setjmp(jmp);
> +		if (!ret)
> +			*map = 0xdeadbeef;
> +		else
> +			igt_assert(ret == SIGBUS);
> +		signal(SIGBUS, SIG_DFL);
> +		signal(SIGSEGV, SIG_DFL);
> +	}
> +
> +	igt_subtest("access-purged-bo-mem") {
> +		struct igt_list tmplist;
> +
> +		igt_list_init(&tmplist);
> +
> +		/* Mark the first BO in our list as purgeable and try to
> +		 * allocate a new one. This should trigger a purge and render
> +		 * the first BO inaccessible.
> +		 */
> +		bo = igt_list_first_entry(&list, bo, node);
> +		map = (uint32_t *)bo->map;
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +
> +		/* Trigger a purge. */
> +		igt_vc4_trigger_purge(fd);
> +
> +		/* Accessing a purged BO should generate a SIGBUS event. */
> +		signal(SIGSEGV, sigtrap);
> +		signal(SIGBUS, sigtrap);
> +		ret = setjmp(jmp);
> +		if (!ret)
> +			*map = 0;
> +		else
> +			igt_assert(ret == SIGBUS);
> +		signal(SIGBUS, SIG_DFL);
> +		signal(SIGSEGV, SIG_DFL);
> +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> +	}
> +
> +	igt_subtest("mark-unpurgeable-not-purged") {
> +		igt_list_for_each(bo, &list, node) {
> +			map = (uint32_t *)bo->map;
> +			*map = 0xdeadbeef;
> +			igt_vc4_purgeable_bo(fd, bo->handle, true);
> +		}
> +
> +		igt_list_for_each(bo, &list, node) {
> +			map = (uint32_t *)bo->map;
> +			igt_assert(igt_vc4_purgeable_bo(fd, bo->handle, false));
> +			igt_assert(*map == 0xdeadbeef);
> +		}
> +	}
> +
> +	igt_subtest("mark-unpurgeable-purged") {
> +		igt_list_for_each(bo, &list, node) {
> +			map = (uint32_t *)bo->map;
> +			*map = 0xdeadbeef;
> +			igt_vc4_purgeable_bo(fd, bo->handle, true);
> +		}
> +
> +		/* Trigger a purge. */
> +		igt_vc4_trigger_purge(fd);
> +
> +		igt_list_for_each(bo, &list, node) {
> +			map = (uint32_t *)bo->map;
> +			igt_assert(!igt_vc4_purgeable_bo(fd, bo->handle, false));
> +			igt_assert(*map != 0xdeadbeef);
> +		}
> +	}
> +
> +	igt_subtest("mark-unpurgeable-nomem") {
> +		struct igt_list tmplist;
> +
> +		igt_list_for_each(bo, &list, node)
> +			igt_vc4_purgeable_bo(fd, bo->handle, true);
> +
> +		/* Deplete the CMA pool by allocating as much as we can. This
> +		 * should trigger a purge.
> +		 */
> +		igt_list_init(&tmplist);
> +		igt_vc4_alloc_mmap_max_bo(fd, &tmplist, 64 * 1024);
> +		igt_assert(!igt_list_empty(&tmplist));
> +
> +		/* Now try to mark all BOs in the intial pool as unpurgeable.
> +		 * We shoud see a failure at some point.
> +		 */
> +		igt_list_for_each(bo, &list, node) {
> +			struct drm_vc4_gem_madvise arg = {
> +				.handle = bo->handle,
> +				.madv = VC4_MADV_WILLNEED,
> +			};
> +
> +			ret = igt_ioctl(fd, DRM_IOCTL_VC4_GEM_MADVISE, &arg);
> +			if (ret)
> +				break;
> +		}
> +
> +		igt_assert(ret && errno == ENOMEM);
> +
> +		/* Release all BOs from the tmplist and try again. This time it
> +		 * should succeed.
> +		 */
> +		igt_vc4_unmap_free_bo_pool(fd, &tmplist);
> +		igt_list_for_each(bo, &list, node)
> +			igt_vc4_purgeable_bo(fd, bo->handle, false);
> +	}
> +
> +	igt_subtest("free-purged-bo") {
> +		bo = igt_list_first_entry(&list, bo, node);
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +
> +		/* Trigger a purge. */
> +		igt_vc4_trigger_purge(fd);
> +
> +		igt_list_del(&bo->node);
> +		munmap(bo->map, bo->size);
> +		gem_close(fd, bo->handle);
> +		free(bo);
> +	}
> +
> +	igt_fixture {
> +		igt_vc4_unmap_free_bo_pool(fd, &list);
> +		close(fd);
> +	}
> +}
> -- 
> 2.11.0
> 

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

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

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

* Re: [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests
  2017-09-27 11:51 ` [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests Boris Brezillon
  2017-09-27 11:57   ` Petri Latvala
@ 2017-09-27 12:07   ` Chris Wilson
  2017-09-27 12:41     ` Boris Brezillon
  2017-09-27 18:08   ` Eric Anholt
  2 siblings, 1 reply; 14+ messages in thread
From: Chris Wilson @ 2017-09-27 12:07 UTC (permalink / raw)
  To: Boris Brezillon, Intel GFX discussion

Quoting Boris Brezillon (2017-09-27 12:51:18)
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
>  tests/Makefile.sources   |   1 +
>  tests/vc4_purgeable_bo.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 275 insertions(+)
>  create mode 100644 tests/vc4_purgeable_bo.c
> 
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 0adc28a014d2..c78ac9d27921 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -8,6 +8,7 @@ VC4_TESTS = \
>         vc4_create_bo \
>         vc4_dmabuf_poll \
>         vc4_lookup_fail \
> +       vc4_purgeable_bo \
>         vc4_wait_bo \
>         vc4_wait_seqno \
>         $(NULL)
> diff --git a/tests/vc4_purgeable_bo.c b/tests/vc4_purgeable_bo.c
> new file mode 100644
> index 000000000000..e3eaf0c24563
> --- /dev/null
> +++ b/tests/vc4_purgeable_bo.c
> @@ -0,0 +1,274 @@
> +/*
> + * Copyright �� 2017 Broadcom
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include "igt.h"
> +#include "igt_vc4.h"
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <fcntl.h>
> +#include <inttypes.h>
> +#include <errno.h>
> +#include <sys/stat.h>
> +#include <sys/ioctl.h>
> +#include "vc4_drm.h"
> +
> +struct igt_vc4_bo {
> +       struct igt_list node;
> +       int handle;
> +       void *map;
> +       size_t size;
> +};
> +
> +static jmp_buf jmp;
> +
> +static void __attribute__((noreturn)) sigtrap(int sig)
> +{
> +       longjmp(jmp, sig);
> +}
> +
> +static void igt_vc4_alloc_mmap_max_bo(int fd, struct igt_list *list,
> +                                     size_t size)
> +{
> +       struct igt_vc4_bo *bo;
> +       struct drm_vc4_create_bo create = {
> +               .size = size,
> +       };
> +
> +       while (true) {
> +               if (igt_ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create))
> +                       break;
> +
> +               bo = malloc(sizeof(*bo));
> +               igt_assert(bo);
> +               bo->handle = create.handle;
> +               bo->size = create.size;
> +               bo->map = igt_vc4_mmap_bo(fd, bo->handle, bo->size,
> +                                         PROT_READ | PROT_WRITE);
> +               igt_list_add_tail(&bo->node, list);
> +       }
> +}
> +
> +static void igt_vc4_unmap_free_bo_pool(int fd, struct igt_list *list)
> +{
> +       struct igt_vc4_bo *bo;
> +
> +       while (!igt_list_empty(list)) {
> +               bo = igt_list_first_entry(list, bo, node);
> +               igt_assert(bo);
> +               igt_list_del(&bo->node);
> +               munmap(bo->map, bo->size);
> +               gem_close(fd, bo->handle);
> +               free(bo);
> +       }
> +}
> +
> +static void igt_vc4_trigger_purge(int fd)
> +{

May I suggest a /proc/sys/vm/drop_caches-esque interface?
For when you want to explicitly control reclaim.

> +       struct igt_list list;
> +
> +       igt_list_init(&list);
> +
> +       /* Try to allocate as much as we can to trigger a purge. */
> +       igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
> +       igt_assert(!igt_list_empty(&list));
> +       igt_vc4_unmap_free_bo_pool(fd, &list);
> +}
> +
> +igt_main
> +{
> +       struct igt_vc4_bo *bo;
> +       struct igt_list list;
> +       uint32_t *map;
> +       int fd, ret;
> +
> +       igt_fixture {
> +               fd = drm_open_driver(DRIVER_VC4);
> +               igt_list_init(&list);
> +
> +               igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
> +               igt_assert(!igt_list_empty(&list));
> +       }

igt_subtest("mark-willneed") {
	/* check that setting willneed on a new bo says retained */
}

> +
> +       igt_subtest("mark-purgeable") {
> +               igt_list_for_each(bo, &list, node)
> +                       igt_vc4_purgeable_bo(fd, bo->handle, true);
> +
> +               igt_list_for_each(bo, &list, node)
> +                       igt_vc4_purgeable_bo(fd, bo->handle, false);

Hmm, if this fails early, the state of the list is unknown. Subsequent
tests depend upon the state being known....

I am not sure if you want to preallocate all the bo, or at least if you
do you should walk the list and verify them at the start of each subtest.

> +       }
> +
> +       igt_subtest("mark-purgeable-twice") {
> +               bo = igt_list_first_entry(&list, bo, node);
> +               igt_vc4_purgeable_bo(fd, bo->handle, true);
> +               igt_vc4_purgeable_bo(fd, bo->handle, true);
> +               igt_vc4_purgeable_bo(fd, bo->handle, false);
> +       }
> +
> +       igt_subtest("mark-unpurgeable-twice") {
> +               bo = igt_list_first_entry(&list, bo, node);
> +               igt_vc4_purgeable_bo(fd, bo->handle, true);
> +               igt_vc4_purgeable_bo(fd, bo->handle, false);
> +               igt_vc4_purgeable_bo(fd, bo->handle, false);
> +       }
> +
> +       igt_subtest("access-purgeable-bo-mem") {
> +               bo = igt_list_first_entry(&list, bo, node);
> +               map = (uint32_t *)bo->map;
> +
> +               /* Mark the BO as purgeable, but do not try to allocate a new
> +                * BO. This should leave the BO in a non-purged state unless
> +                * someone else tries to allocated a new BO.
> +                */
> +               igt_vc4_purgeable_bo(fd, bo->handle, true);

Do you do immediate reaping of backing storage and vma on setting
purgeable? If the bo has been in use in earlier tests, then it will have
pages that it may not free immediately, so the mapping might succeed?
(Spots the purged-bo-mem later)

I personally hate "may" tests with a passion. If the expected outcome is
uncertain, how do you know if what it did matches expectations.

> +
> +               /* Accessing a purgeable BO may generate a SIGBUS event if the
> +                * BO has been purged by the system in the meantime.
> +                */
> +               signal(SIGSEGV, sigtrap);
> +               signal(SIGBUS, sigtrap);
> +               ret = setjmp(jmp);
> +               if (!ret)
> +                       *map = 0xdeadbeef;
> +               else
> +                       igt_assert(ret == SIGBUS);
> +               signal(SIGBUS, SIG_DFL);
> +               signal(SIGSEGV, SIG_DFL);
> +       }
> +

> +       igt_subtest("mark-unpurgeable-not-purged") {
> +               igt_list_for_each(bo, &list, node) {
> +                       map = (uint32_t *)bo->map;
> +                       *map = 0xdeadbeef;
> +                       igt_vc4_purgeable_bo(fd, bo->handle, true);
> +               }

/* lots of intervening time for the system to change state? */

> +
> +               igt_list_for_each(bo, &list, node) {
> +                       map = (uint32_t *)bo->map;
> +                       igt_assert(igt_vc4_purgeable_bo(fd, bo->handle, false));
> +                       igt_assert(*map == 0xdeadbeef);
> +               }
> +       }
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✓ Fi.CI.BAT: success for igt: Add a testsuite to validate VC4 MADV ioctl
  2017-09-27 11:51 [PATCH i-g-t 0/2] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
  2017-09-27 11:51 ` [PATCH i-g-t 1/2] igt: Add a helper function to mark BOs purgeable Boris Brezillon
  2017-09-27 11:51 ` [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests Boris Brezillon
@ 2017-09-27 12:25 ` Patchwork
  2017-09-27 15:57 ` ✗ Fi.CI.IGT: failure " Patchwork
  2017-09-28 16:17 ` Patchwork
  4 siblings, 0 replies; 14+ messages in thread
From: Patchwork @ 2017-09-27 12:25 UTC (permalink / raw)
  To: Petri Latvala; +Cc: intel-gfx

== Series Details ==

Series: igt: Add a testsuite to validate VC4 MADV ioctl
URL   : https://patchwork.freedesktop.org/series/30959/
State : success

== Summary ==

IGT patchset tested on top of latest successful build
2885b10f99b4beeb046e75af8b8488c229f629d3 igt/gem_exec_schedule: Ignore set-priority failures on old kernels

with latest DRM-Tip kernel build CI_DRM_3144
da14aaa14e58 drm-tip: 2017y-09m-27d-09h-50m-55s UTC integration manifest

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:448s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:473s
fi-blb-e6850     total:289  pass:224  dwarn:1   dfail:0   fail:0   skip:64  time:420s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:520s
fi-bwr-2160      total:289  pass:184  dwarn:0   dfail:0   fail:0   skip:105 time:281s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:502s
fi-byt-j1900     total:289  pass:254  dwarn:1   dfail:0   fail:0   skip:34  time:499s
fi-cfl-s         total:241  pass:188  dwarn:24  dfail:0   fail:0   skip:28 
fi-cnl-y         total:289  pass:259  dwarn:0   dfail:0   fail:3   skip:27  time:672s
fi-elk-e7500     total:289  pass:230  dwarn:0   dfail:0   fail:0   skip:59  time:420s
fi-glk-1         total:289  pass:259  dwarn:1   dfail:0   fail:0   skip:29  time:569s
fi-hsw-4770      total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:430s
fi-hsw-4770r     total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:406s
fi-ilk-650       total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:432s
fi-ivb-3520m     total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:495s
fi-ivb-3770      total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:467s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:479s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:576s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:592s
fi-pnv-d510      total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:551s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:457s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:755s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:489s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:474s
fi-snb-2520m     total:289  pass:251  dwarn:0   dfail:0   fail:0   skip:38  time:572s
fi-snb-2600      total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:417s

== Logs ==

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

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

* Re: [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests
  2017-09-27 12:07   ` Chris Wilson
@ 2017-09-27 12:41     ` Boris Brezillon
  2017-09-27 12:50       ` Chris Wilson
  0 siblings, 1 reply; 14+ messages in thread
From: Boris Brezillon @ 2017-09-27 12:41 UTC (permalink / raw)
  To: Chris Wilson; +Cc: Intel GFX discussion

Hi Chris,

On Wed, 27 Sep 2017 13:07:28 +0100
Chris Wilson <chris@chris-wilson.co.uk> wrote:

> Quoting Boris Brezillon (2017-09-27 12:51:18)
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
> >  tests/Makefile.sources   |   1 +
> >  tests/vc4_purgeable_bo.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 275 insertions(+)
> >  create mode 100644 tests/vc4_purgeable_bo.c
> > 
> > diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> > index 0adc28a014d2..c78ac9d27921 100644
> > --- a/tests/Makefile.sources
> > +++ b/tests/Makefile.sources
> > @@ -8,6 +8,7 @@ VC4_TESTS = \
> >         vc4_create_bo \
> >         vc4_dmabuf_poll \
> >         vc4_lookup_fail \
> > +       vc4_purgeable_bo \
> >         vc4_wait_bo \
> >         vc4_wait_seqno \
> >         $(NULL)
> > diff --git a/tests/vc4_purgeable_bo.c b/tests/vc4_purgeable_bo.c
> > new file mode 100644
> > index 000000000000..e3eaf0c24563
> > --- /dev/null
> > +++ b/tests/vc4_purgeable_bo.c
> > @@ -0,0 +1,274 @@
> > +/*
> > + * Copyright �� 2017 Broadcom
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a
> > + * copy of this software and associated documentation files (the "Software"),
> > + * to deal in the Software without restriction, including without limitation
> > + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice (including the next
> > + * paragraph) shall be included in all copies or substantial portions of the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> > + * IN THE SOFTWARE.
> > + */
> > +
> > +#include "igt.h"
> > +#include "igt_vc4.h"
> > +#include <unistd.h>
> > +#include <stdlib.h>
> > +#include <stdio.h>
> > +#include <string.h>
> > +#include <fcntl.h>
> > +#include <inttypes.h>
> > +#include <errno.h>
> > +#include <sys/stat.h>
> > +#include <sys/ioctl.h>
> > +#include "vc4_drm.h"
> > +
> > +struct igt_vc4_bo {
> > +       struct igt_list node;
> > +       int handle;
> > +       void *map;
> > +       size_t size;
> > +};
> > +
> > +static jmp_buf jmp;
> > +
> > +static void __attribute__((noreturn)) sigtrap(int sig)
> > +{
> > +       longjmp(jmp, sig);
> > +}
> > +
> > +static void igt_vc4_alloc_mmap_max_bo(int fd, struct igt_list *list,
> > +                                     size_t size)
> > +{
> > +       struct igt_vc4_bo *bo;
> > +       struct drm_vc4_create_bo create = {
> > +               .size = size,
> > +       };
> > +
> > +       while (true) {
> > +               if (igt_ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create))
> > +                       break;
> > +
> > +               bo = malloc(sizeof(*bo));
> > +               igt_assert(bo);
> > +               bo->handle = create.handle;
> > +               bo->size = create.size;
> > +               bo->map = igt_vc4_mmap_bo(fd, bo->handle, bo->size,
> > +                                         PROT_READ | PROT_WRITE);
> > +               igt_list_add_tail(&bo->node, list);
> > +       }
> > +}
> > +
> > +static void igt_vc4_unmap_free_bo_pool(int fd, struct igt_list *list)
> > +{
> > +       struct igt_vc4_bo *bo;
> > +
> > +       while (!igt_list_empty(list)) {
> > +               bo = igt_list_first_entry(list, bo, node);
> > +               igt_assert(bo);
> > +               igt_list_del(&bo->node);
> > +               munmap(bo->map, bo->size);
> > +               gem_close(fd, bo->handle);
> > +               free(bo);
> > +       }
> > +}
> > +
> > +static void igt_vc4_trigger_purge(int fd)
> > +{  
> 
> May I suggest a /proc/sys/vm/drop_caches-esque interface?
> For when you want to explicitly control reclaim.

Eric suggested to add a debugfs entry to control the purge, I just
thought I didn't really need it since I had a way to trigger this
mechanism without adding yet another userspace -> kernel interface that
will become part of the ABI and will have to be maintained forever.

If you think this is preferable, I'll go for the debugfs hook.

> 
> > +       struct igt_list list;
> > +
> > +       igt_list_init(&list);
> > +
> > +       /* Try to allocate as much as we can to trigger a purge. */
> > +       igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
> > +       igt_assert(!igt_list_empty(&list));
> > +       igt_vc4_unmap_free_bo_pool(fd, &list);
> > +}
> > +
> > +igt_main
> > +{
> > +       struct igt_vc4_bo *bo;
> > +       struct igt_list list;
> > +       uint32_t *map;
> > +       int fd, ret;
> > +
> > +       igt_fixture {
> > +               fd = drm_open_driver(DRIVER_VC4);
> > +               igt_list_init(&list);
> > +
> > +               igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
> > +               igt_assert(!igt_list_empty(&list));
> > +       }  
> 
> igt_subtest("mark-willneed") {
> 	/* check that setting willneed on a new bo says retained */
> }

Will add this test in the next version.

> 
> > +
> > +       igt_subtest("mark-purgeable") {
> > +               igt_list_for_each(bo, &list, node)
> > +                       igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +
> > +               igt_list_for_each(bo, &list, node)
> > +                       igt_vc4_purgeable_bo(fd, bo->handle, false);  
> 
> Hmm, if this fails early, the state of the list is unknown. Subsequent
> tests depend upon the state being known....

Well, yes, that's one of the problem I have with the current
vc4_purgeable_bo testsuite. As soon as one subtest fails it's likely to
impact other subtests.

> 
> I am not sure if you want to preallocate all the bo, or at least if you
> do you should walk the list and verify them at the start of each subtest.

Okay, I'll allocate the BO pool at the beginning of each subtest and
release it before leaving the subtest. Note that I'm not guaranteed
that the release operation works, which means the next subtest might
not be able to allocate new BOs and will fail, but this failure is
actually caused by the previous subtest not the one that reports a
failure in IGT.

> 
> > +       }
> > +
> > +       igt_subtest("mark-purgeable-twice") {
> > +               bo = igt_list_first_entry(&list, bo, node);
> > +               igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +               igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +               igt_vc4_purgeable_bo(fd, bo->handle, false);
> > +       }
> > +
> > +       igt_subtest("mark-unpurgeable-twice") {
> > +               bo = igt_list_first_entry(&list, bo, node);
> > +               igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +               igt_vc4_purgeable_bo(fd, bo->handle, false);
> > +               igt_vc4_purgeable_bo(fd, bo->handle, false);
> > +       }
> > +
> > +       igt_subtest("access-purgeable-bo-mem") {
> > +               bo = igt_list_first_entry(&list, bo, node);
> > +               map = (uint32_t *)bo->map;
> > +
> > +               /* Mark the BO as purgeable, but do not try to allocate a new
> > +                * BO. This should leave the BO in a non-purged state unless
> > +                * someone else tries to allocated a new BO.
> > +                */
> > +               igt_vc4_purgeable_bo(fd, bo->handle, true);  
> 
> Do you do immediate reaping of backing storage and vma on setting
> purgeable?

Nope.

> If the bo has been in use in earlier tests, then it will have
> pages that it may not free immediately, so the mapping might succeed?

It's likely what will happen, and that's actually what I intended to
test initially. Eric just pointed out that someone else (external to
the IGT test) might trigger a purge between the igt_vc4_purgeable_bo()
and the *map access.

> (Spots the purged-bo-mem later)
> 
> I personally hate "may" tests with a passion. If the expected outcome is
> uncertain, how do you know if what it did matches expectations.

Well, it's not completely uncertain, we just have 2 valid results:
- SIGBUS event is received => the BO has been purged
- nothing happens and the *map assignments works => the BO has not been
  purged yet.

> 
> > +
> > +               /* Accessing a purgeable BO may generate a SIGBUS event if the
> > +                * BO has been purged by the system in the meantime.
> > +                */
> > +               signal(SIGSEGV, sigtrap);
> > +               signal(SIGBUS, sigtrap);
> > +               ret = setjmp(jmp);
> > +               if (!ret)
> > +                       *map = 0xdeadbeef;
> > +               else
> > +                       igt_assert(ret == SIGBUS);
> > +               signal(SIGBUS, SIG_DFL);
> > +               signal(SIGSEGV, SIG_DFL);
> > +       }
> > +  
> 
> > +       igt_subtest("mark-unpurgeable-not-purged") {
> > +               igt_list_for_each(bo, &list, node) {
> > +                       map = (uint32_t *)bo->map;
> > +                       *map = 0xdeadbeef;
> > +                       igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +               }  
> 
> /* lots of intervening time for the system to change state? */

That's true.

> 
> > +
> > +               igt_list_for_each(bo, &list, node) {
> > +                       map = (uint32_t *)bo->map;
> > +                       igt_assert(igt_vc4_purgeable_bo(fd, bo->handle, false));
> > +                       igt_assert(*map == 0xdeadbeef);

I can change the above 2 lines into:

			if (igt_vc4_purgeable_bo(fd, bo->handle, false))
				igt_assert(*map == 0xdeadbeef);
			else
				igt_assert(*map != 0xdeadbeef);

so that it works even if someone triggered the purge between
igt_vc4_purgeable_bo(true) and igt_vc4_purgeable_bo(false).

> > +               }
> > +       }  


Thanks for your review.

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

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

* Re: [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests
  2017-09-27 11:57   ` Petri Latvala
@ 2017-09-27 12:43     ` Boris Brezillon
  0 siblings, 0 replies; 14+ messages in thread
From: Boris Brezillon @ 2017-09-27 12:43 UTC (permalink / raw)
  To: Petri Latvala; +Cc: Intel GFX discussion

On Wed, 27 Sep 2017 14:57:05 +0300
Petri Latvala <petri.latvala@intel.com> wrote:

> On Wed, Sep 27, 2017 at 01:51:18PM +0200, Boris Brezillon wrote:
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
> >  tests/Makefile.sources   |   1 +
> >  tests/vc4_purgeable_bo.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 275 insertions(+)
> >  create mode 100644 tests/vc4_purgeable_bo.c
> > 
> > diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> > index 0adc28a014d2..c78ac9d27921 100644
> > --- a/tests/Makefile.sources
> > +++ b/tests/Makefile.sources
> > @@ -8,6 +8,7 @@ VC4_TESTS = \
> >  	vc4_create_bo \
> >  	vc4_dmabuf_poll \
> >  	vc4_lookup_fail \
> > +	vc4_purgeable_bo \
> >  	vc4_wait_bo \
> >  	vc4_wait_seqno \
> >  	$(NULL)  
> 
> 
> For meson, squash this in:

Will do.

Thanks.

Boris

> 
> 
> diff --git a/tests/meson.build b/tests/meson.build
> index 1c619179..8f94e3c4 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -243,6 +243,7 @@ if libdrm_vc4.found()
>  		'vc4_create_bo',
>  		'vc4_dmabuf_poll',
>  		'vc4_lookup_fail',
> +		'vc4_purgeable_bo',
>  		'vc4_wait_bo',
>  		'vc4_wait_seqno',
>  	]
> 
> 
> 

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

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

* Re: [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests
  2017-09-27 12:41     ` Boris Brezillon
@ 2017-09-27 12:50       ` Chris Wilson
  2017-09-27 13:19         ` Boris Brezillon
  0 siblings, 1 reply; 14+ messages in thread
From: Chris Wilson @ 2017-09-27 12:50 UTC (permalink / raw)
  To: Boris Brezillon; +Cc: Intel GFX discussion

Quoting Boris Brezillon (2017-09-27 13:41:41)
> Hi Chris,
> 
> On Wed, 27 Sep 2017 13:07:28 +0100
> Chris Wilson <chris@chris-wilson.co.uk> wrote:
> 
> > Quoting Boris Brezillon (2017-09-27 12:51:18)
> > > +static void igt_vc4_trigger_purge(int fd)
> > > +{  
> > 
> > May I suggest a /proc/sys/vm/drop_caches-esque interface?
> > For when you want to explicitly control reclaim.
> 
> Eric suggested to add a debugfs entry to control the purge, I just
> thought I didn't really need it since I had a way to trigger this
> mechanism without adding yet another userspace -> kernel interface that
> will become part of the ABI and will have to be maintained forever.
> 
> If you think this is preferable, I'll go for the debugfs hook.

I think you will find it useful in future. i915's drop-caches also has
options to make sure the GPU is idle, delayed frees are flushed, etc.
One thing we found useful is that through a debugfs interface, we can
pretend to be the shrinker/in-reclaim, setting
fs_reclaim_acquire(GFP_KERNEL) around the operation. That gives us
better lockdep coverage without having to trigger the shrinker.

Our experience says that you will make good use of a drop-caches
interface, it won't just be a one test wonder. :)
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests
  2017-09-27 12:50       ` Chris Wilson
@ 2017-09-27 13:19         ` Boris Brezillon
  2017-09-27 18:05           ` Eric Anholt
  0 siblings, 1 reply; 14+ messages in thread
From: Boris Brezillon @ 2017-09-27 13:19 UTC (permalink / raw)
  To: Chris Wilson; +Cc: Intel GFX discussion

On Wed, 27 Sep 2017 13:50:30 +0100
Chris Wilson <chris@chris-wilson.co.uk> wrote:

> Quoting Boris Brezillon (2017-09-27 13:41:41)
> > Hi Chris,
> > 
> > On Wed, 27 Sep 2017 13:07:28 +0100
> > Chris Wilson <chris@chris-wilson.co.uk> wrote:
> >   
> > > Quoting Boris Brezillon (2017-09-27 12:51:18)  
> > > > +static void igt_vc4_trigger_purge(int fd)
> > > > +{    
> > > 
> > > May I suggest a /proc/sys/vm/drop_caches-esque interface?
> > > For when you want to explicitly control reclaim.  
> > 
> > Eric suggested to add a debugfs entry to control the purge, I just
> > thought I didn't really need it since I had a way to trigger this
> > mechanism without adding yet another userspace -> kernel interface that
> > will become part of the ABI and will have to be maintained forever.
> > 
> > If you think this is preferable, I'll go for the debugfs hook.  
> 
> I think you will find it useful in future. i915's drop-caches also has
> options to make sure the GPU is idle, delayed frees are flushed, etc.
> One thing we found useful is that through a debugfs interface, we can
> pretend to be the shrinker/in-reclaim, setting
> fs_reclaim_acquire(GFP_KERNEL) around the operation. That gives us
> better lockdep coverage without having to trigger the shrinker.
> 
> Our experience says that you will make good use of a drop-caches
> interface, it won't just be a one test wonder. :)

Just had a look at i915_drop_caches_fops [1] and it seems
over-complicated given what I can do in the VC4 driver: flush memory of
BOs that are marked purgeable.

Right now there's no shrinker object registered to the MM layer to help
the system release memory. The only one who can trigger a purge is the
VC4 BO allocator when it fails to allocate CMA memory.
Also note that all VC4 BOs are backed by CMA mem, so I'm not sure
plugging the BO purge system to the MM shrinker logic makes a lot of
sense (is the MM core expecting shrinkers to release memory coming from
the CMA pool?)

All this to say I'm not comfortable with designing a generic
"drop_caches" debugfs hook that would take various options to delimit
the scope of the cache-flush request. I'd prefer to have a simple
"purge_purgeable_bos" file that does not care about the input value and
flushes everything as soon as someone writes to it.
But let's wait for Eric's feedback, maybe he has other plans and a
better vision of what will be needed after this simple "purgeable-bo"
implementation I'm about to post.

Regards,

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

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

* ✗ Fi.CI.IGT: failure for igt: Add a testsuite to validate VC4 MADV ioctl
  2017-09-27 11:51 [PATCH i-g-t 0/2] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
                   ` (2 preceding siblings ...)
  2017-09-27 12:25 ` ✓ Fi.CI.BAT: success for igt: Add a testsuite to validate VC4 MADV ioctl Patchwork
@ 2017-09-27 15:57 ` Patchwork
  2017-09-28 16:17 ` Patchwork
  4 siblings, 0 replies; 14+ messages in thread
From: Patchwork @ 2017-09-27 15:57 UTC (permalink / raw)
  To: Petri Latvala; +Cc: intel-gfx

== Series Details ==

Series: igt: Add a testsuite to validate VC4 MADV ioctl
URL   : https://patchwork.freedesktop.org/series/30959/
State : failure

== Summary ==

Test kms_draw_crc:
        Subgroup draw-method-xrgb8888-render-xtiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-xrgb8888-blt-xtiled:
                skip       -> PASS       (shard-hsw)
        Subgroup fill-fb:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-xrgb2101010-pwrite-untiled:
                fail       -> PASS       (shard-hsw)
        Subgroup draw-method-rgb565-render-untiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-xrgb2101010-pwrite-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-rgb565-pwrite-xtiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-rgb565-blt-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-xrgb2101010-mmap-cpu-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-rgb565-mmap-gtt-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-xrgb8888-mmap-wc-xtiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-xrgb2101010-mmap-gtt-untiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-xrgb8888-render-untiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-xrgb2101010-mmap-wc-untiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-rgb565-mmap-wc-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-rgb565-mmap-cpu-xtiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-xrgb8888-mmap-wc-untiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-xrgb2101010-mmap-cpu-untiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-xrgb8888-render-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-xrgb2101010-mmap-wc-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-rgb565-pwrite-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-rgb565-mmap-cpu-untiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-rgb565-mmap-wc-untiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-xrgb2101010-blt-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-rgb565-render-xtiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-xrgb8888-mmap-wc-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-xrgb8888-blt-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-xrgb2101010-blt-xtiled:
                skip       -> PASS       (shard-hsw)
        Subgroup draw-method-xrgb8888-pwrite-ytiled:
                pass       -> SKIP       (shard-hsw)
        Subgroup draw-method-xrgb2101010-mmap-cpu-xtiled:
                skip       -> PASS       (shard-hsw)
Test kms_frontbuffer_tracking:
        Subgroup psr-rgb101010-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-primscrn-spr-indfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-shrfb-plflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-spr-indfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-primscrn-pri-shrfb-draw-render:
                skip       -> PASS       (shard-hsw)
        Subgroup psr-2p-scndscrn-indfb-msflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-primscrn-pri-shrfb-draw-mmap-cpu:
                skip       -> PASS       (shard-hsw)
        Subgroup fbc-2p-scndscrn-spr-indfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-primscrn-shrfb-pgflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-spr-indfb-move:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-spr-indfb-fullscreen:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-rgb565-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-cur-indfb-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-spr-indfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-spr-indfb-onoff:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-pri-shrfb-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-primscrn-spr-indfb-fullscreen:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-pri-shrfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-rgb101010-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-pri-shrfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-primscrn-cur-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-indfb-plflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-offscren-pri-shrfb-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-primscrn-spr-indfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-pri-shrfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-offscren-pri-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-offscren-pri-shrfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-spr-indfb-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-cur-indfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-pri-indfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-cur-indfb-move:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-pri-indfb-multidraw:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-cur-indfb-move:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-spr-indfb-onoff:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-indfb-msflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-cur-indfb-draw-pwrite:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-cur-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-pri-shrfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-spr-indfb-move:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-pri-shrfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-primscrn-spr-indfb-draw-pwrite:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-indfb-fliptrack:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-cur-indfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-offscren-pri-indfb-draw-render:
                skip       -> PASS       (shard-hsw)
        Subgroup fbc-tilingchange:
                skip       -> PASS       (shard-hsw)
        Subgroup psr-1p-primscrn-indfb-msflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-rgb101010-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-tilingchange:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-primscrn-pri-indfb-draw-mmap-cpu:
                skip       -> PASS       (shard-hsw)
        Subgroup psr-1p-primscrn-spr-indfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-spr-indfb-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-pri-shrfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-spr-indfb-move:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-spr-indfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-pri-shrfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-cur-indfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-primscrn-cur-indfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-primscrn-pri-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-shrfb-pgflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-rgb101010-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-shrfb-pgflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-pri-shrfb-draw-pwrite:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-spr-indfb-onoff:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-primscrn-cur-indfb-draw-mmap-wc:
                fail       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-primscrn-pri-indfb-draw-blt:
                skip       -> PASS       (shard-hsw)
        Subgroup fbcpsr-2p-primscrn-pri-shrfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-offscren-pri-shrfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-shrfb-pgflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-spr-indfb-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-cur-indfb-move:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-pri-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-primscrn-cur-indfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-indfb-scaledprimary:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-primscrn-pri-shrfb-draw-mmap-gtt:
                skip       -> PASS       (shard-hsw)
        Subgroup fbcpsr-farfromfence:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-pri-indfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-suspend:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-spr-indfb-draw-pwrite:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-shrfb-msflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-primscrn-pri-indfb-draw-render:
                skip       -> PASS       (shard-hsw)
        Subgroup fbc-1p-primscrn-shrfb-msflip-blt:
                skip       -> PASS       (shard-hsw)
        Subgroup fbc-shrfb-scaledprimary:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-pri-shrfb-draw-pwrite:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-pri-shrfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-rte:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-pri-indfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-pri-shrfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-primscrn-indfb-pgflip-blt:
                skip       -> PASS       (shard-hsw)
        Subgroup fbc-2p-pri-indfb-multidraw:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-cur-indfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-suspend:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-shrfb-msflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-pri-shrfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-shrfb-fliptrack:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-suspend:
                skip       -> PASS       (shard-hsw)
        Subgroup fbc-2p-scndscrn-indfb-msflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-cur-indfb-onoff:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-indfb-scaledprimary:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-pri-indfb-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-pri-indfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-offscren-pri-shrfb-draw-mmap-gtt:
                skip       -> PASS       (shard-hsw)
        Subgroup psr-2p-scndscrn-cur-indfb-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-indfb-plflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-pri-indfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-cur-indfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-shrfb-plflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-cur-indfb-onoff:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-pri-indfb-draw-pwrite:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-offscren-pri-shrfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-primscrn-spr-indfb-fullscreen:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-indfb-pgflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-rgb565-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-farfromfence:
                skip       -> PASS       (shard-hsw)
        Subgroup psr-2p-scndscrn-cur-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-cur-indfb-draw-pwrite:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-cur-indfb-onoff:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-stridechange:
                skip       -> PASS       (shard-hsw)
        Subgroup psr-1p-offscren-pri-indfb-draw-pwrite:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-shrfb-pgflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-offscren-pri-indfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-primscrn-cur-indfb-onoff:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-pri-shrfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-cur-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-rte:
                skip       -> PASS       (shard-hsw)
        Subgroup psr-2p-primscrn-pri-shrfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-spr-indfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-pri-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-indfb-scaledprimary:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-primscrn-indfb-pgflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-cur-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-rgb565-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-spr-indfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-shrfb-scaledprimary:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-badstride:
                skip       -> PASS       (shard-hsw)
        Subgroup psr-2p-scndscrn-spr-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-spr-indfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-pri-shrfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-cur-indfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-primscrn-spr-indfb-onoff:
                skip       -> PASS       (shard-hsw)
        Subgroup fbcpsr-rgb101010-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-scndscrn-cur-indfb-draw-render:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-primscrn-cur-indfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-primscrn-pri-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-primscrn-cur-indfb-move:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-scndscrn-spr-indfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-cur-indfb-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-cur-indfb-draw-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-offscren-pri-shrfb-draw-render:
                skip       -> PASS       (shard-hsw)
        Subgroup fbcpsr-2p-primscrn-indfb-plflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-spr-indfb-draw-pwrite:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-1p-primscrn-pri-indfb-draw-pwrite:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-rgb101010-draw-mmap-cpu:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-1p-primscrn-spr-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-pri-indfb-multidraw:
                skip       -> PASS       (shard-hsw)
        Subgroup psr-2p-primscrn-cur-indfb-draw-mmap-gtt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-2p-primscrn-spr-indfb-draw-mmap-wc:
                pass       -> SKIP       (shard-hsw)
        Subgroup psr-2p-scndscrn-indfb-plflip-blt:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbcpsr-2p-primscrn-cur-indfb-move:
                pass       -> SKIP       (shard-hsw)
        Subgroup fbc-1p-primscrn-pri-shrfb-draw-pwrite:
 

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_256/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests
  2017-09-27 13:19         ` Boris Brezillon
@ 2017-09-27 18:05           ` Eric Anholt
  0 siblings, 0 replies; 14+ messages in thread
From: Eric Anholt @ 2017-09-27 18:05 UTC (permalink / raw)
  To: Boris Brezillon, Chris Wilson; +Cc: Intel GFX discussion


[-- Attachment #1.1: Type: text/plain, Size: 3776 bytes --]

Boris Brezillon <boris.brezillon@free-electrons.com> writes:

> On Wed, 27 Sep 2017 13:50:30 +0100
> Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
>> Quoting Boris Brezillon (2017-09-27 13:41:41)
>> > Hi Chris,
>> > 
>> > On Wed, 27 Sep 2017 13:07:28 +0100
>> > Chris Wilson <chris@chris-wilson.co.uk> wrote:
>> >   
>> > > Quoting Boris Brezillon (2017-09-27 12:51:18)  
>> > > > +static void igt_vc4_trigger_purge(int fd)
>> > > > +{    
>> > > 
>> > > May I suggest a /proc/sys/vm/drop_caches-esque interface?
>> > > For when you want to explicitly control reclaim.  
>> > 
>> > Eric suggested to add a debugfs entry to control the purge, I just
>> > thought I didn't really need it since I had a way to trigger this
>> > mechanism without adding yet another userspace -> kernel interface that
>> > will become part of the ABI and will have to be maintained forever.
>> > 
>> > If you think this is preferable, I'll go for the debugfs hook.  
>> 
>> I think you will find it useful in future. i915's drop-caches also has
>> options to make sure the GPU is idle, delayed frees are flushed, etc.
>> One thing we found useful is that through a debugfs interface, we can
>> pretend to be the shrinker/in-reclaim, setting
>> fs_reclaim_acquire(GFP_KERNEL) around the operation. That gives us
>> better lockdep coverage without having to trigger the shrinker.
>> 
>> Our experience says that you will make good use of a drop-caches
>> interface, it won't just be a one test wonder. :)
>
> Just had a look at i915_drop_caches_fops [1] and it seems
> over-complicated given what I can do in the VC4 driver: flush memory of
> BOs that are marked purgeable.
>
> Right now there's no shrinker object registered to the MM layer to help
> the system release memory. The only one who can trigger a purge is the
> VC4 BO allocator when it fails to allocate CMA memory.
> Also note that all VC4 BOs are backed by CMA mem, so I'm not sure
> plugging the BO purge system to the MM shrinker logic makes a lot of
> sense (is the MM core expecting shrinkers to release memory coming from
> the CMA pool?)

Given that general page cache stuff can live in CMA, freeing CMA memory
from your shrinker callback should be good for MM.  So, yeah, it would
be great if (in a later patchset) the mesa BO cache gets purged when the
system is busy doing non-graphics tasks and wants the memory back.

Also, I just landed the userspace side of BO labeling, so
/debug/dri/0/bo_stats will have a lot more useful information in it.  We
should probably have the mark-purgeable path in the kernel label the BO
as purgeable (erasing whatever previous label the BO had).  Then, maybe
after we can make it so that most allocations label their BOs, not just
debug Mesa builds.  Need to do some performance testing there.

> All this to say I'm not comfortable with designing a generic
> "drop_caches" debugfs hook that would take various options to delimit
> the scope of the cache-flush request. I'd prefer to have a simple
> "purge_purgeable_bos" file that does not care about the input value and
> flushes everything as soon as someone writes to it.
> But let's wait for Eric's feedback, maybe he has other plans and a
> better vision of what will be needed after this simple "purgeable-bo"
> implementation I'm about to post.

I thought your use of allocations to force purging was pretty elegant.
Also, it means that we'll be driving the purging code from the same
codepath as Mesa will be (BO allocation) rather than something slightly
different.

I think we'll want debugfs to test the shrinker path, since I don't know
of another good way for userspace to trigger it reliably without also
destabilizing the testing environment.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

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

* Re: [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests
  2017-09-27 11:51 ` [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests Boris Brezillon
  2017-09-27 11:57   ` Petri Latvala
  2017-09-27 12:07   ` Chris Wilson
@ 2017-09-27 18:08   ` Eric Anholt
  2 siblings, 0 replies; 14+ messages in thread
From: Eric Anholt @ 2017-09-27 18:08 UTC (permalink / raw)
  To: Boris Brezillon, Intel GFX discussion


[-- Attachment #1.1: Type: text/plain, Size: 384 bytes --]

Boris Brezillon <boris.brezillon@free-electrons.com> writes:

> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>

Another test we should have: Queue up a big rendering job (Copy a
2048x2048@32bpp BO?), mark the source purgeable, force the purge, wait
for rendering, make sure we correctly rendered, and maybe have some
sanity-checking of purgeable state of the BO.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

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

* ✗ Fi.CI.IGT: failure for igt: Add a testsuite to validate VC4 MADV ioctl
  2017-09-27 11:51 [PATCH i-g-t 0/2] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
                   ` (3 preceding siblings ...)
  2017-09-27 15:57 ` ✗ Fi.CI.IGT: failure " Patchwork
@ 2017-09-28 16:17 ` Patchwork
  4 siblings, 0 replies; 14+ messages in thread
From: Patchwork @ 2017-09-28 16:17 UTC (permalink / raw)
  To: Petri Latvala; +Cc: intel-gfx

== Series Details ==

Series: igt: Add a testsuite to validate VC4 MADV ioctl
URL   : https://patchwork.freedesktop.org/series/30959/
State : failure

== Summary ==

Test prime_mmap:
        Subgroup test_userptr:
                pass       -> DMESG-WARN (shard-hsw) fdo#102939
Test prime_self_import:
        Subgroup export-vs-gem_close-race:
                pass       -> FAIL       (shard-hsw)
Test perf:
        Subgroup polling:
                pass       -> FAIL       (shard-hsw) fdo#102252
Test gem_eio:
        Subgroup throttle:
                pass       -> DMESG-WARN (shard-hsw) fdo#102886 +1

fdo#102939 https://bugs.freedesktop.org/show_bug.cgi?id=102939
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#102886 https://bugs.freedesktop.org/show_bug.cgi?id=102886

shard-hsw        total:2429 pass:1331 dwarn:4   dfail:0   fail:11  skip:1083 time:9867s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_256/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2017-09-28 16:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-27 11:51 [PATCH i-g-t 0/2] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
2017-09-27 11:51 ` [PATCH i-g-t 1/2] igt: Add a helper function to mark BOs purgeable Boris Brezillon
2017-09-27 11:51 ` [PATCH i-g-t 2/2] igt: Add VC4 purgeable BO tests Boris Brezillon
2017-09-27 11:57   ` Petri Latvala
2017-09-27 12:43     ` Boris Brezillon
2017-09-27 12:07   ` Chris Wilson
2017-09-27 12:41     ` Boris Brezillon
2017-09-27 12:50       ` Chris Wilson
2017-09-27 13:19         ` Boris Brezillon
2017-09-27 18:05           ` Eric Anholt
2017-09-27 18:08   ` Eric Anholt
2017-09-27 12:25 ` ✓ Fi.CI.BAT: success for igt: Add a testsuite to validate VC4 MADV ioctl Patchwork
2017-09-27 15:57 ` ✗ Fi.CI.IGT: failure " Patchwork
2017-09-28 16:17 ` Patchwork

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.