* [igt-dev] [PATCH i-g-t v2 0/4] Add flat-ccs tests
@ 2023-10-13 11:28 Zbigniew Kempczyński
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 1/4] lib/intel_blt: Release an offset in the allocator on buffer destroy Zbigniew Kempczyński
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Zbigniew Kempczyński @ 2023-10-13 11:28 UTC (permalink / raw)
To: igt-dev
On DG2 I observe data inconsistency with flat-ccs when buffers are
returning back from system to vram. For the verification first group
of subtests is run on 20% of vram, second on 110% which triggers
eviction. Issue is visible mostly on 'parallel' subtests.
v2: Add different cmdline switches to exercise eviction using different
sizes and vram overcommitment percent
Zbigniew Kempczyński (4):
lib/intel_blt: Release an offset in the allocator on buffer destroy
lib/igt_sizes: Add common SZ_* header
tests/xe_evict_ccs: Add evict ccs test
intel-ci/xe-fast-feedback: Add two xe_evict_ccs subtests for Xe run
lib/igt.h | 1 +
lib/igt_sizes.h | 44 ++
lib/intel_blt.c | 15 +-
lib/intel_blt.h | 2 +
lib/xe/xe_query.h | 4 +-
tests/intel-ci/xe-fast-feedback.testlist | 2 +
tests/intel/gem_exec_async.c | 2 -
tests/intel/gem_lmem_swapping.c | 1 -
tests/intel/i915_query.c | 1 -
tests/intel/xe_evict.c | 3 -
tests/intel/xe_evict_ccs.c | 522 +++++++++++++++++++++++
tests/meson.build | 1 +
tests/msm/msm_shrink.c | 2 -
13 files changed, 587 insertions(+), 13 deletions(-)
create mode 100644 lib/igt_sizes.h
create mode 100644 tests/intel/xe_evict_ccs.c
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [igt-dev] [PATCH i-g-t v2 1/4] lib/intel_blt: Release an offset in the allocator on buffer destroy
2023-10-13 11:28 [igt-dev] [PATCH i-g-t v2 0/4] Add flat-ccs tests Zbigniew Kempczyński
@ 2023-10-13 11:28 ` Zbigniew Kempczyński
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_sizes: Add common SZ_* header Zbigniew Kempczyński
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Zbigniew Kempczyński @ 2023-10-13 11:28 UTC (permalink / raw)
To: igt-dev
Blitter library code requires allocator handle only at the execution
time. That means blt_copy_object structure is allocator agnostic and
offsets are taken for block-copy or fast-copy just before operation.
Operations on bo's like close/create requires to reflect on the
allocator state, otherwise allocator will contain outdated
offsets + sizes leading to fail on allocator operations or the exec.
Helpers blt_create_object() and blt_destroy_object() are unaware
of allocator so if in the meantime object was used in block-copy or
fast-copy it has assigned offset in the allocator. Destroying object
with blt_destroy_object() doesn't release this offset what might
cause failures described above.
There're two possibilities how to solve this - to couple blitter
library with allocator or provide additional helpers which will
release offset in the allocator on destroy path. Latter one is
easier to provide so this is a subject of this change.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Karolina Stolarek <karolina.stolarek@intel.com>
Reviewed-by: Karolina Stolarek <karolina.stolarek@intel.com>
---
lib/intel_blt.c | 15 ++++++++++++++-
lib/intel_blt.h | 2 ++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/lib/intel_blt.c b/lib/intel_blt.c
index a76c7a4045..3c5e97963d 100644
--- a/lib/intel_blt.c
+++ b/lib/intel_blt.c
@@ -1635,15 +1635,28 @@ blt_create_object(const struct blt_copy_data *blt, uint32_t region,
return obj;
}
-void blt_destroy_object(int fd, struct blt_copy_object *obj)
+static void __blt_destroy_object(int fd, uint64_t ahnd, struct blt_copy_object *obj)
{
if (obj->ptr)
munmap(obj->ptr, obj->size);
gem_close(fd, obj->handle);
+ if (ahnd)
+ intel_allocator_free(ahnd, obj->handle);
free(obj);
}
+void blt_destroy_object(int fd, struct blt_copy_object *obj)
+{
+ __blt_destroy_object(fd, 0, obj);
+}
+
+void blt_destroy_object_and_alloc_free(int fd, uint64_t ahnd,
+ struct blt_copy_object *obj)
+{
+ __blt_destroy_object(fd, ahnd, obj);
+}
+
void blt_set_object(struct blt_copy_object *obj,
uint32_t handle, uint64_t size, uint32_t region,
uint8_t mocs_index, enum blt_tiling_type tiling,
diff --git a/lib/intel_blt.h b/lib/intel_blt.h
index 7b4271620a..657e51dd57 100644
--- a/lib/intel_blt.h
+++ b/lib/intel_blt.h
@@ -245,6 +245,8 @@ blt_create_object(const struct blt_copy_data *blt, uint32_t region,
enum blt_compression_type compression_type,
bool create_mapping);
void blt_destroy_object(int fd, struct blt_copy_object *obj);
+void blt_destroy_object_and_alloc_free(int fd, uint64_t ahnd,
+ struct blt_copy_object *obj);
void blt_set_object(struct blt_copy_object *obj,
uint32_t handle, uint64_t size, uint32_t region,
uint8_t mocs_index, enum blt_tiling_type tiling,
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_sizes: Add common SZ_* header
2023-10-13 11:28 [igt-dev] [PATCH i-g-t v2 0/4] Add flat-ccs tests Zbigniew Kempczyński
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 1/4] lib/intel_blt: Release an offset in the allocator on buffer destroy Zbigniew Kempczyński
@ 2023-10-13 11:28 ` Zbigniew Kempczyński
2023-10-17 10:58 ` Kamil Konieczny
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 3/4] tests/xe_evict_ccs: Add evict ccs test Zbigniew Kempczyński
` (3 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Zbigniew Kempczyński @ 2023-10-13 11:28 UTC (permalink / raw)
To: igt-dev
We're often use SZ_.* macros so add this globally to IGTs.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
lib/igt.h | 1 +
lib/igt_sizes.h | 44 +++++++++++++++++++++++++++++++++
lib/xe/xe_query.h | 4 +--
tests/intel/gem_exec_async.c | 2 --
tests/intel/gem_lmem_swapping.c | 1 -
tests/intel/i915_query.c | 1 -
tests/intel/xe_evict.c | 3 ---
tests/msm/msm_shrink.c | 2 --
8 files changed, 46 insertions(+), 12 deletions(-)
create mode 100644 lib/igt_sizes.h
diff --git a/lib/igt.h b/lib/igt.h
index 73b6f77272..7af3d10cbc 100644
--- a/lib/igt.h
+++ b/lib/igt.h
@@ -39,6 +39,7 @@
#include "igt_params.h"
#include "igt_pipe_crc.h"
#include "igt_pm.h"
+#include "igt_sizes.h"
#include "igt_stats.h"
#include "igt_dsc.h"
#ifdef HAVE_CHAMELIUM
diff --git a/lib/igt_sizes.h b/lib/igt_sizes.h
new file mode 100644
index 0000000000..a3bc93cdd7
--- /dev/null
+++ b/lib/igt_sizes.h
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Taken and adopted to IGT from kernel include/linux/sizes.h
+ */
+#ifndef __IGT_SIZES_H__
+#define __IGT_SIZES_H__
+
+#define SZ_1 0x00000001
+#define SZ_2 0x00000002
+#define SZ_4 0x00000004
+#define SZ_8 0x00000008
+#define SZ_16 0x00000010
+#define SZ_32 0x00000020
+#define SZ_64 0x00000040
+#define SZ_128 0x00000080
+#define SZ_256 0x00000100
+#define SZ_512 0x00000200
+
+#define SZ_1K 0x00000400
+#define SZ_2K 0x00000800
+#define SZ_4K 0x00001000
+#define SZ_8K 0x00002000
+#define SZ_16K 0x00004000
+#define SZ_32K 0x00008000
+#define SZ_64K 0x00010000
+#define SZ_128K 0x00020000
+#define SZ_256K 0x00040000
+#define SZ_512K 0x00080000
+
+#define SZ_1M 0x00100000
+#define SZ_2M 0x00200000
+#define SZ_4M 0x00400000
+#define SZ_8M 0x00800000
+#define SZ_16M 0x01000000
+#define SZ_32M 0x02000000
+#define SZ_64M 0x04000000
+#define SZ_128M 0x08000000
+#define SZ_256M 0x10000000
+#define SZ_512M 0x20000000
+
+#define SZ_1G 0x40000000
+#define SZ_2G 0x80000000
+
+#endif /* __IGT_SIZES_H__ */
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index 20dbfa12c4..a21c419fb5 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -12,9 +12,7 @@
#include <stdint.h>
#include <xe_drm.h>
#include "igt_list.h"
-
-#define SZ_4K 0x1000
-#define SZ_64K 0x10000
+#include "igt_sizes.h"
#define XE_DEFAULT_ALIGNMENT SZ_4K
#define XE_DEFAULT_ALIGNMENT_64K SZ_64K
diff --git a/tests/intel/gem_exec_async.c b/tests/intel/gem_exec_async.c
index 8c131d8e13..1497c5c6c8 100644
--- a/tests/intel/gem_exec_async.c
+++ b/tests/intel/gem_exec_async.c
@@ -41,8 +41,6 @@
IGT_TEST_DESCRIPTION("Check that we can issue concurrent writes across the engines.");
-#define SZ_1M (1024 * 1024)
-
static void store_dword(int fd, int id, const intel_ctx_t *ctx,
unsigned ring, uint32_t target, uint64_t target_offset,
uint32_t offset, uint32_t value)
diff --git a/tests/intel/gem_lmem_swapping.c b/tests/intel/gem_lmem_swapping.c
index 2e0ba07935..6aed806294 100644
--- a/tests/intel/gem_lmem_swapping.c
+++ b/tests/intel/gem_lmem_swapping.c
@@ -198,7 +198,6 @@ IGT_TEST_DESCRIPTION("Exercise local memory swapping.");
#define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1)
#define PAGE_SIZE (1ULL << 12)
-#define SZ_64K (16 * PAGE_SIZE)
static const char *readable_unit(uint64_t size)
{
diff --git a/tests/intel/i915_query.c b/tests/intel/i915_query.c
index f97379b83b..e9cc495973 100644
--- a/tests/intel/i915_query.c
+++ b/tests/intel/i915_query.c
@@ -863,7 +863,6 @@ static void test_query_regions_sanity_check(int fd)
}
#define rounddown(x, y) (x - (x % y))
-#define SZ_64K (1ULL << 16)
static void fill_unallocated(int fd, struct drm_i915_query_item *item, int idx,
bool cpu_access)
diff --git a/tests/intel/xe_evict.c b/tests/intel/xe_evict.c
index 5b64e56b45..d0c7e93e1c 100644
--- a/tests/intel/xe_evict.c
+++ b/tests/intel/xe_evict.c
@@ -453,9 +453,6 @@ threads(int fd, struct drm_xe_engine_class_instance *eci,
pthread_join(threads_data[i].thread, NULL);
}
-#define SZ_256M 0x10000000
-#define SZ_1G 0x40000000
-
static uint64_t calc_bo_size(uint64_t vram_size, int mul, int div)
{
if (vram_size >= SZ_1G)
diff --git a/tests/msm/msm_shrink.c b/tests/msm/msm_shrink.c
index d0b098aaf3..8e6c582ffc 100644
--- a/tests/msm/msm_shrink.c
+++ b/tests/msm/msm_shrink.c
@@ -30,8 +30,6 @@
#include "igt_os.h"
#include "igt_sysfs.h"
-#define SZ_1M (1024 * 1024)
-
static void leak(uint64_t alloc)
{
char *ptr;
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [igt-dev] [PATCH i-g-t v2 3/4] tests/xe_evict_ccs: Add evict ccs test
2023-10-13 11:28 [igt-dev] [PATCH i-g-t v2 0/4] Add flat-ccs tests Zbigniew Kempczyński
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 1/4] lib/intel_blt: Release an offset in the allocator on buffer destroy Zbigniew Kempczyński
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_sizes: Add common SZ_* header Zbigniew Kempczyński
@ 2023-10-13 11:28 ` Zbigniew Kempczyński
2023-10-17 15:28 ` Matthew Auld
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 4/4] intel-ci/xe-fast-feedback: Add two xe_evict_ccs subtests for Xe run Zbigniew Kempczyński
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Zbigniew Kempczyński @ 2023-10-13 11:28 UTC (permalink / raw)
To: igt-dev
Exercise is flat-ccs eviction working fine in the kernel driver
when buffers takes more than available vram. Differentiate with
standalone/parallel execution, same or separate drm fd and buffer
freeing time. Tests are divided to two groups - first which won't
exceed vram memory size (thus don't trigger eviction, but it is
good for the reference logic is properly compress/decompress
buffers) and second which exceeds.
v2:
- Add command line switches to exercise kernel with different
sizes, number of objects and vram overcommitment
- Add -simple test which creates single big object which enforces
eviction (Matt)
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
---
tests/intel/xe_evict_ccs.c | 522 +++++++++++++++++++++++++++++++++++++
tests/meson.build | 1 +
2 files changed, 523 insertions(+)
create mode 100644 tests/intel/xe_evict_ccs.c
diff --git a/tests/intel/xe_evict_ccs.c b/tests/intel/xe_evict_ccs.c
new file mode 100644
index 0000000000..72872f952b
--- /dev/null
+++ b/tests/intel/xe_evict_ccs.c
@@ -0,0 +1,522 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+/**
+ * TEST: Check flat-ccs eviction
+ * Category: Software building block
+ * Sub-category: Flat-CCS
+ * Functionality: evict
+ * GPU requirements: GPU needs to have dedicated VRAM
+ */
+
+#include "igt.h"
+#include "igt_list.h"
+#include "intel_blt.h"
+#include "intel_mocs.h"
+#include "lib/igt_syncobj.h"
+#include "lib/intel_reg.h"
+#include "xe_drm.h"
+
+#include "xe/xe_ioctl.h"
+#include "xe/xe_query.h"
+#include <math.h>
+#include <string.h>
+
+#define OVERCOMMIT_VRAM_PERCENT 110
+#define MIN_OBJ_KB 64
+#define MAX_OBJ_KB (256 * 1024)
+#define DUMP_FILENAME "/tmp/object.data"
+#define DUMP_EXPFILENAME "/tmp/object.expected"
+
+static struct param {
+ bool print_bb;
+ bool disable_compression;
+ bool dump_corrupted_surface;
+ int num_objs;
+ int vram_percent;
+ int min_size_kb;
+ int max_size_kb;
+ bool verify;
+} params = {
+ .num_objs = 0,
+ .vram_percent = OVERCOMMIT_VRAM_PERCENT,
+ .min_size_kb = MIN_OBJ_KB,
+ .max_size_kb = MAX_OBJ_KB,
+};
+
+struct object {
+ uint64_t size;
+ uint32_t start_value;
+ struct blt_copy_object *blt_obj;
+ struct igt_list_head link;
+};
+
+#define TEST_PARALLEL (1 << 0)
+#define TEST_INSTANTFREE (1 << 1)
+#define TEST_REOPEN (1 << 2)
+#define TEST_SIMPLE (1 << 3)
+
+#define MAX_NPROC 8
+struct config {
+ uint32_t flags;
+ int nproc;
+ int free_mb, total_mb;
+ int test_mb, mb_per_proc;
+ const struct param *param;
+};
+
+static void copy_obj(struct blt_copy_data *blt,
+ struct blt_copy_object *src_obj,
+ struct blt_copy_object *dst_obj,
+ intel_ctx_t *ctx,
+ uint64_t ahnd)
+{
+ struct blt_block_copy_data_ext ext = {};
+ int fd = blt->fd;
+ uint64_t bb_size = xe_get_default_alignment(fd);
+ uint32_t bb;
+ uint32_t w, h;
+
+ w = src_obj->x2;
+ h = src_obj->y2;
+
+ bb = xe_bo_create_flags(fd, 0, bb_size,
+ vram_memory(fd, 0) | XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
+
+ blt->color_depth = CD_32bit;
+ blt->print_bb = params.print_bb;
+ blt_set_copy_object(&blt->src, src_obj);
+ blt_set_copy_object(&blt->dst, dst_obj);
+ blt_set_object_ext(&ext.src, 0, w, h, SURFACE_TYPE_2D);
+ blt_set_object_ext(&ext.dst, 0, w, h, SURFACE_TYPE_2D);
+ blt_set_batch(&blt->bb, bb, bb_size, vram_if_possible(fd, 0));
+ blt_block_copy(fd, ctx, NULL, ahnd, blt, &ext);
+ intel_ctx_xe_sync(ctx, true);
+
+ gem_close(fd, bb);
+ put_offset(ahnd, bb);
+ put_offset(ahnd, blt->src.handle);
+ put_offset(ahnd, blt->dst.handle);
+ intel_allocator_bind(ahnd, 0, 0);
+}
+
+static uint32_t rand_and_update(uint32_t *left, uint32_t min, uint32_t max)
+{
+ int left_bit, min_bit, max_bit, rand_id, rand_kb;
+
+ left_bit = igt_fls(*left) - 1;
+ min_bit = igt_fls(min) - 1;
+ max_bit = max_t(int, min_t(int, igt_fls(max) - 1, left_bit), igt_fls(max));
+ rand_id = rand() % (max_bit - min_bit);
+ rand_kb = 1 << (rand_id + min_bit);
+
+ if (*left >= rand_kb)
+ *left -= rand_kb;
+ else
+ *left = 0;
+
+ return rand_kb;
+}
+
+static struct object *create_obj(struct blt_copy_data *blt,
+ intel_ctx_t *ctx, uint64_t ahnd,
+ uint64_t size, int start_value,
+ bool disable_compression)
+{
+ int fd = blt->fd;
+ struct object *obj;
+ uint32_t w, h;
+ uint8_t uc_mocs = intel_get_uc_mocs_index(fd);
+ int i;
+ struct blt_copy_object *src;
+
+ obj = calloc(1, sizeof(*obj));
+ igt_assert(obj);
+ obj->size = size;
+ obj->start_value = start_value;
+
+ w = max_t(int, 1024, roundup_power_of_two(sqrt(size/4)));
+ h = size / w / 4; /* /4 - 32bpp */
+
+ igt_debug("Obj size: %ldKiB (%ldMiB) <w: %d, h: %d>\n",
+ size / SZ_1K, size / SZ_1M, w, h);
+
+ src = blt_create_object(blt,
+ system_memory(fd),
+ w, h, 32, uc_mocs,
+ T_LINEAR, COMPRESSION_DISABLED,
+ COMPRESSION_TYPE_3D, true);
+
+ obj->blt_obj = blt_create_object(blt,
+ vram_memory(fd, 0) | XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM,
+ w, h, 32, uc_mocs,
+ T_LINEAR,
+ disable_compression ? COMPRESSION_DISABLED :
+ COMPRESSION_ENABLED,
+ COMPRESSION_TYPE_3D, true);
+
+ for (i = 0; i < size / sizeof(uint32_t); i++)
+ src->ptr[i] = start_value++;
+
+ copy_obj(blt, src, obj->blt_obj, ctx, ahnd);
+
+ blt_destroy_object_and_alloc_free(fd, ahnd, src);
+ intel_allocator_bind(ahnd, 0, 0);
+
+ return obj;
+}
+
+static void dump_obj(const struct blt_copy_object *obj, int start_value)
+{
+ FILE *out;
+
+ if (!params.dump_corrupted_surface)
+ return;
+
+ out = fopen(DUMP_FILENAME, "wb");
+ fwrite(obj->ptr, obj->size, 1, out);
+ fclose(out);
+
+ out = fopen(DUMP_EXPFILENAME, "wb");
+ for (int i = 0; i < obj->size / 4; i++) {
+ int v = start_value + i;
+
+ fwrite(&v, sizeof(int), 1, out);
+ }
+ fclose(out);
+}
+
+static void check_obj(const char *check_mode,
+ const struct blt_copy_object *obj, uint64_t size,
+ int start_value, int num_obj)
+{
+ int i, idx;
+
+ if (obj->ptr[0] != start_value ||
+ (obj->ptr[size/4 - 1] != start_value + size/4 - 1)) {
+ igt_info("[%s] Failed object w: %d, h: %d, size: %ldKiB (%ldMiB)\n",
+ check_mode, obj->x2, obj->y2, obj->size / SZ_1K, obj->size / SZ_1M);
+ dump_obj(obj, start_value);
+ }
+
+ igt_assert_eq(obj->ptr[0], start_value);
+ igt_assert_eq(obj->ptr[size/4 - 1], start_value + size/4 - 1);
+
+ /* Couple of checks of random indices */
+ for (i = 0; i < 128; i++) {
+ idx = rand() % (size/4);
+
+ if (obj->ptr[idx] != start_value + idx) {
+ igt_info("[%s] Failed object w: %d, h: %d, size: %ldKiB (%ldMiB)\n",
+ check_mode, obj->x2, obj->y2,
+ obj->size / SZ_1K, obj->size / SZ_1M);
+ dump_obj(obj, start_value);
+ }
+
+ igt_assert_f(obj->ptr[idx] == start_value + idx,
+ "[%s] Object number %d doesn't contain valid data",
+ check_mode, num_obj);
+ }
+}
+
+static void evict_single(int fd, int child, const struct config *config)
+{
+ struct blt_copy_data blt = {};
+ struct blt_copy_object *orig_obj;
+ uint32_t kb_left = config->mb_per_proc * SZ_1K;
+ uint32_t min_alloc_kb = config->param->min_size_kb;
+ uint32_t max_alloc_kb = config->param->max_size_kb;
+ uint32_t vm = xe_vm_create(fd, DRM_XE_VM_CREATE_ASYNC_BIND_OPS, 0);
+ uint64_t ahnd = intel_allocator_open(fd, vm, INTEL_ALLOCATOR_RELOC);
+ uint8_t uc_mocs = intel_get_uc_mocs_index(fd);
+ struct object *obj, *tmp;
+ struct igt_list_head list;
+ struct drm_xe_engine_class_instance inst = {
+ .engine_class = DRM_XE_ENGINE_CLASS_COPY,
+ };
+ intel_ctx_t *ctx;
+ uint32_t exec_queue, big_obj;
+ int num_obj = 0;
+
+ srandom(time(NULL));
+ IGT_INIT_LIST_HEAD(&list);
+ igt_debug("[%2d] child : to allocate: %uMiB\n", child, kb_left/SZ_1K);
+
+ blt_copy_init(fd, &blt);
+
+ exec_queue = xe_exec_queue_create(fd, vm, &inst, 0);
+ ctx = intel_ctx_xe(fd, vm, exec_queue, 0, 0, 0);
+
+ while (kb_left) {
+ struct blt_copy_object *verify_obj;
+ uint64_t obj_size = rand_and_update(&kb_left, min_alloc_kb, max_alloc_kb) * SZ_1K;
+ int start_value = rand();
+
+ if (config->flags & TEST_SIMPLE)
+ obj_size = max_alloc_kb * SZ_1K;
+
+ obj = create_obj(&blt, ctx, ahnd, obj_size, start_value,
+ config->param->disable_compression);
+ igt_list_add(&obj->link, &list);
+
+ if (config->param->verify) {
+ verify_obj = blt_create_object(&blt, system_memory(fd),
+ obj->blt_obj->x2,
+ obj->blt_obj->y2,
+ 32, uc_mocs,
+ T_LINEAR, COMPRESSION_DISABLED,
+ 0, true);
+ copy_obj(&blt, obj->blt_obj, verify_obj, ctx, ahnd);
+ check_obj("Verify", verify_obj, obj->blt_obj->size,
+ obj->start_value, num_obj++);
+ blt_destroy_object_and_alloc_free(fd, ahnd, verify_obj);
+ intel_allocator_bind(ahnd, 0, 0);
+ }
+
+ if (config->flags & TEST_SIMPLE) {
+ big_obj = xe_bo_create_flags(fd, vm, kb_left * SZ_1K,
+ vram_memory(fd, 0));
+ break;
+ }
+
+ if (config->param->num_objs && ++num_obj == config->param->num_objs)
+ break;
+ }
+
+ if (config->param->verify)
+ igt_info("[%8d] Verify ok\n", getpid());
+
+ num_obj = 0;
+ igt_list_for_each_entry_safe(obj, tmp, &list, link) {
+ orig_obj = blt_create_object(&blt, system_memory(fd),
+ obj->blt_obj->x2,
+ obj->blt_obj->y2,
+ 32, uc_mocs,
+ T_LINEAR, COMPRESSION_DISABLED,
+ 0, true);
+ copy_obj(&blt, obj->blt_obj, orig_obj, ctx, ahnd);
+ check_obj("Check", orig_obj, obj->blt_obj->size, obj->start_value, num_obj++);
+ blt_destroy_object_and_alloc_free(fd, ahnd, orig_obj);
+
+ if (config->flags & TEST_INSTANTFREE) {
+ igt_list_del(&obj->link);
+ blt_destroy_object_and_alloc_free(fd, ahnd, obj->blt_obj);
+ free(obj);
+ }
+ intel_allocator_bind(ahnd, 0, 0);
+ }
+
+ if (!(config->flags & TEST_INSTANTFREE))
+ igt_list_for_each_entry_safe(obj, tmp, &list, link) {
+ igt_list_del(&obj->link);
+ blt_destroy_object_and_alloc_free(fd, ahnd, obj->blt_obj);
+ free(obj);
+ }
+
+ if (config->flags & TEST_SIMPLE)
+ gem_close(fd, big_obj);
+}
+
+static void set_config(int fd, uint32_t flags, const struct param *param,
+ struct config *config)
+{
+ int nproc = 1;
+
+ config->param = param;
+ config->flags = flags;
+ config->free_mb = xe_vram_available(fd, 0) / SZ_1M;
+ config->total_mb = xe_visible_vram_size(fd, 0) / SZ_1M;
+ config->test_mb = min_t(int, config->free_mb * config->param->vram_percent / 100,
+ config->total_mb * config->param->vram_percent / 100);
+
+ igt_debug("VRAM memory size: %dMB/%dMB (use %dMB), overcommit perc: %d\n",
+ config->free_mb, config->total_mb,
+ config->test_mb, config->param->vram_percent);
+
+ if (flags & TEST_PARALLEL)
+ nproc = min_t(int, sysconf(_SC_NPROCESSORS_ONLN), MAX_NPROC);
+ config->nproc = nproc;
+ config->mb_per_proc = config->test_mb / nproc;
+
+ igt_debug("nproc: %d, mem per proc: %dMB\n", nproc, config->mb_per_proc);
+}
+
+static void evict_ccs(int fd, uint32_t flags, const struct param *param)
+{
+ struct config config;
+ char numstr[32];
+
+ igt_info("Test mode <parallel: %d, instant free: %d, reopen: %d, simple: %d>\n",
+ !!(flags & TEST_PARALLEL),
+ !!(flags & TEST_INSTANTFREE),
+ !!(flags & TEST_REOPEN),
+ !!(flags & TEST_SIMPLE));
+ if (param->num_objs)
+ snprintf(numstr, sizeof(numstr), "%d", param->num_objs);
+ else
+ strncpy(numstr, "limited to vram", sizeof(numstr));
+ igt_info("Params: compression: %s, num objects: %s, vram percent: %d, kb <min: %d, max: %d>\n",
+ param->disable_compression ? "disabled" : "enabled",
+ numstr, param->vram_percent,
+ param->min_size_kb, param->max_size_kb);
+
+ set_config(fd, flags, param, &config);
+
+ if (flags & TEST_PARALLEL) {
+ igt_fork(n, config.nproc) {
+ if (flags & TEST_REOPEN) {
+ fd = drm_reopen_driver(fd);
+ intel_allocator_init();
+ }
+ evict_single(fd, n, &config);
+ }
+ igt_waitchildren();
+ } else {
+ if (flags & TEST_REOPEN)
+ fd = drm_reopen_driver(fd);
+ evict_single(fd, 0, &config);
+ }
+}
+
+/**
+ *
+ * SUBTEST: evict-ccs-overcommit-simple
+ * Description: FlatCCS eviction test.
+ * Feature: flatccs
+ * Test category: stress test
+ */
+/**
+ *
+ * SUBTEST: evict-ccs-overcommit-%s-%s-%s
+ * Description: FlatCCS eviction test.
+ * Feature: flatccs
+ * Test category: stress test
+ *
+ * arg[1]:
+ *
+ * @standalone: single process
+ * @parallel: multiple processes
+ *
+ * arg[2]:
+ *
+ * @nofree: keep objects till the end of the test
+ * @instantfree: free object after it was verified and it won't
+ * be used anymore
+ *
+ * arg[3]:
+ *
+ * @samefd: operate on same opened drm fd
+ * @reopen: use separately opened drm fds
+ *
+ */
+static int opt_handler(int opt, int opt_index, void *data)
+{
+ switch (opt) {
+ case 'b':
+ params.print_bb = true;
+ igt_debug("Print bb: %d\n", params.print_bb);
+ break;
+ case 'd':
+ params.disable_compression = true;
+ igt_debug("Print bb: %d\n", params.disable_compression);
+ break;
+ case 'D':
+ params.dump_corrupted_surface = true;
+ igt_debug("Print bb: %d\n", params.dump_corrupted_surface);
+ break;
+ case 'n':
+ params.num_objs = atoi(optarg);
+ igt_debug("Number objects: %d\n", params.num_objs);
+ break;
+ case 'p':
+ params.vram_percent = atoi(optarg);
+ igt_debug("Percent vram: %d\n", params.vram_percent);
+ break;
+ case 's':
+ params.min_size_kb = atoi(optarg);
+ igt_debug("Min size kb: %d\n", params.min_size_kb);
+ break;
+ case 'S':
+ params.max_size_kb = atoi(optarg);
+ igt_debug("Max size kb: %d\n", params.max_size_kb);
+ break;
+ case 'V':
+ params.verify = true;
+ igt_debug("Verify: %d\n", params.verify);
+ break;
+ default:
+ return IGT_OPT_HANDLER_ERROR;
+ }
+
+ return IGT_OPT_HANDLER_SUCCESS;
+}
+
+const char *help_str =
+ " -b\tPrint bb\n"
+ " -d\tDisable compression (don't use flatccs area)\n"
+ " -D\tDump surface which doesn't match\n"
+ " -e\tAdd temporary object which enforce eviction\n"
+ " -n\tNumber of objects to create (0 - 31)\n"
+ " -p\tPercent of VRAM to alloc\n"
+ " -s\tMinimum size of object in kb\n"
+ " -S\tMaximum size of object in kb\n"
+ " -V\tVerify object after compressing\n"
+ ;
+
+igt_main_args("bdDn:p:s:S:V", NULL, help_str, opt_handler, NULL)
+{
+ struct drm_xe_engine_class_instance *hwe;
+
+ const struct ccs {
+ const char *name;
+ uint32_t flags;
+ } ccs[] = {
+ { "simple",
+ TEST_SIMPLE },
+ { "standalone-nofree-samefd",
+ 0 },
+ { "standalone-nofree-reopen",
+ TEST_REOPEN },
+ { "standalone-instantfree-samefd",
+ TEST_INSTANTFREE },
+ { "standalone-instantfree-reopen",
+ TEST_INSTANTFREE | TEST_REOPEN },
+ { "parallel-nofree-samefd",
+ TEST_PARALLEL },
+ { "parallel-nofree-reopen",
+ TEST_PARALLEL | TEST_REOPEN },
+ { "parallel-instantfree-samefd",
+ TEST_PARALLEL | TEST_INSTANTFREE },
+ { "parallel-instantfree-reopen",
+ TEST_PARALLEL | TEST_INSTANTFREE | TEST_REOPEN },
+ { },
+ };
+ uint64_t vram_size;
+ int fd;
+
+ igt_fixture {
+ fd = drm_open_driver(DRIVER_XE);
+ igt_require(xe_has_vram(fd));
+ vram_size = xe_visible_vram_size(fd, 0);
+ igt_assert(vram_size);
+
+ xe_for_each_hw_engine(fd, hwe)
+ if (hwe->engine_class != DRM_XE_ENGINE_CLASS_COPY)
+ break;
+ }
+
+ igt_fixture
+ intel_allocator_multiprocess_start();
+
+ for (const struct ccs *s = ccs; s->name; s++) {
+ igt_subtest_f("evict-ccs-overcommit-%s", s->name)
+ evict_ccs(fd, s->flags, ¶ms);
+ }
+
+ igt_fixture {
+ intel_allocator_multiprocess_stop();
+ drm_close_driver(fd);
+ }
+}
diff --git a/tests/meson.build b/tests/meson.build
index 2c2e1ca9ac..831947567f 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -279,6 +279,7 @@ intel_xe_progs = [
'xe_debugfs',
'xe_drm_fdinfo',
'xe_evict',
+ 'xe_evict_ccs',
'xe_exec_balancer',
'xe_exec_basic',
'xe_exec_compute_mode',
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [igt-dev] [PATCH i-g-t v2 4/4] intel-ci/xe-fast-feedback: Add two xe_evict_ccs subtests for Xe run
2023-10-13 11:28 [igt-dev] [PATCH i-g-t v2 0/4] Add flat-ccs tests Zbigniew Kempczyński
` (2 preceding siblings ...)
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 3/4] tests/xe_evict_ccs: Add evict ccs test Zbigniew Kempczyński
@ 2023-10-13 11:28 ` Zbigniew Kempczyński
2023-10-13 17:47 ` [igt-dev] ✗ Fi.CI.BAT: failure for Add flat-ccs tests (rev2) Patchwork
2023-10-13 18:22 ` [igt-dev] ✓ CI.xeBAT: success " Patchwork
5 siblings, 0 replies; 11+ messages in thread
From: Zbigniew Kempczyński @ 2023-10-13 11:28 UTC (permalink / raw)
To: igt-dev
There are two subtests which should be run in bat.
First is simple check of eviction, second exercises driver in multiple
processes to check does any race influences on object consistency.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
---
tests/intel-ci/xe-fast-feedback.testlist | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/intel-ci/xe-fast-feedback.testlist b/tests/intel-ci/xe-fast-feedback.testlist
index 610cc958c5..a2c23efb2c 100644
--- a/tests/intel-ci/xe-fast-feedback.testlist
+++ b/tests/intel-ci/xe-fast-feedback.testlist
@@ -26,6 +26,8 @@ igt@xe_evict@evict-small-external-cm
igt@xe_evict@evict-small-multi-vm
igt@xe_evict@evict-small-multi-vm-cm
igt@xe_evict@evict-threads-small
+igt@xe_evict_ccs@evict-ccs-overcommit-simple
+igt@xe_evict_ccs@evict-ccs-overcommit-parallel-nofree-samefd
igt@xe_exec_balancer@twice-virtual-basic
igt@xe_exec_balancer@no-exec-virtual-basic
igt@xe_exec_balancer@twice-cm-virtual-basic
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [igt-dev] ✗ Fi.CI.BAT: failure for Add flat-ccs tests (rev2)
2023-10-13 11:28 [igt-dev] [PATCH i-g-t v2 0/4] Add flat-ccs tests Zbigniew Kempczyński
` (3 preceding siblings ...)
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 4/4] intel-ci/xe-fast-feedback: Add two xe_evict_ccs subtests for Xe run Zbigniew Kempczyński
@ 2023-10-13 17:47 ` Patchwork
2023-10-13 18:22 ` [igt-dev] ✓ CI.xeBAT: success " Patchwork
5 siblings, 0 replies; 11+ messages in thread
From: Patchwork @ 2023-10-13 17:47 UTC (permalink / raw)
To: Zbigniew Kempczyński; +Cc: igt-dev
[-- Attachment #1: Type: text/plain, Size: 10562 bytes --]
== Series Details ==
Series: Add flat-ccs tests (rev2)
URL : https://patchwork.freedesktop.org/series/124626/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_13753 -> IGTPW_9999
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_9999 absolutely need to be
verified manually.
If you think the reported changes have nothing to do with the changes
introduced in IGTPW_9999, please notify your bug team (lgci.bug.filing@intel.com) to allow them
to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/index.html
Participating hosts (38 -> 37)
------------------------------
Additional (2): bat-dg2-9 fi-pnv-d510
Missing (3): fi-kbl-soraka fi-hsw-4770 fi-snb-2520m
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_9999:
### IGT changes ###
#### Possible regressions ####
* igt@i915_selftest@live@hangcheck:
- bat-dg2-11: [PASS][1] -> [ABORT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13753/bat-dg2-11/igt@i915_selftest@live@hangcheck.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-11/igt@i915_selftest@live@hangcheck.html
Known issues
------------
Here are the changes found in IGTPW_9999 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_suspend@basic-s0@smem:
- bat-rpls-1: NOTRUN -> [FAIL][3] ([fdo#103375]) +1 other test fail
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-rpls-1/igt@gem_exec_suspend@basic-s0@smem.html
* igt@gem_mmap@basic:
- bat-dg2-9: NOTRUN -> [SKIP][4] ([i915#4083])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@gem_mmap@basic.html
* igt@gem_mmap_gtt@basic:
- bat-dg2-9: NOTRUN -> [SKIP][5] ([i915#4077]) +2 other tests skip
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@gem_mmap_gtt@basic.html
* igt@gem_render_tiled_blits@basic:
- bat-dg2-9: NOTRUN -> [SKIP][6] ([i915#4079]) +1 other test skip
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@gem_render_tiled_blits@basic.html
* igt@i915_pm_rps@basic-api:
- bat-dg2-9: NOTRUN -> [SKIP][7] ([i915#6621])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@i915_pm_rps@basic-api.html
* igt@i915_suspend@basic-s2idle-without-i915:
- bat-rpls-1: [PASS][8] -> [FAIL][9] ([fdo#103375])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13753/bat-rpls-1/igt@i915_suspend@basic-s2idle-without-i915.html
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-rpls-1/igt@i915_suspend@basic-s2idle-without-i915.html
* igt@kms_addfb_basic@addfb25-y-tiled-small-legacy:
- bat-dg2-9: NOTRUN -> [SKIP][10] ([i915#5190])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@kms_addfb_basic@addfb25-y-tiled-small-legacy.html
* igt@kms_addfb_basic@basic-y-tiled-legacy:
- bat-dg2-9: NOTRUN -> [SKIP][11] ([i915#4215] / [i915#5190])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@kms_addfb_basic@basic-y-tiled-legacy.html
* igt@kms_addfb_basic@framebuffer-vs-set-tiling:
- bat-dg2-9: NOTRUN -> [SKIP][12] ([i915#4212]) +6 other tests skip
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@kms_addfb_basic@framebuffer-vs-set-tiling.html
* igt@kms_addfb_basic@tile-pitch-mismatch:
- bat-dg2-9: NOTRUN -> [SKIP][13] ([i915#4212] / [i915#5608])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@kms_addfb_basic@tile-pitch-mismatch.html
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- bat-dg2-9: NOTRUN -> [SKIP][14] ([i915#4103] / [i915#4213] / [i915#5608]) +1 other test skip
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy.html
* igt@kms_force_connector_basic@force-load-detect:
- bat-dg2-9: NOTRUN -> [SKIP][15] ([fdo#109285])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@kms_force_connector_basic@force-load-detect.html
* igt@kms_force_connector_basic@prune-stale-modes:
- bat-dg2-9: NOTRUN -> [SKIP][16] ([i915#5274])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@kms_force_connector_basic@prune-stale-modes.html
* igt@kms_pipe_crc_basic@suspend-read-crc:
- bat-rpls-1: NOTRUN -> [SKIP][17] ([i915#1845])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-rpls-1/igt@kms_pipe_crc_basic@suspend-read-crc.html
* igt@kms_pipe_crc_basic@suspend-read-crc@pipe-b-dp-1:
- bat-dg2-9: NOTRUN -> [FAIL][18] ([fdo#103375]) +2 other tests fail
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@kms_pipe_crc_basic@suspend-read-crc@pipe-b-dp-1.html
* igt@kms_psr@primary_page_flip:
- fi-pnv-d510: NOTRUN -> [SKIP][19] ([fdo#109271]) +29 other tests skip
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/fi-pnv-d510/igt@kms_psr@primary_page_flip.html
* igt@kms_psr@sprite_plane_onoff:
- bat-dg2-9: NOTRUN -> [SKIP][20] ([i915#1072]) +3 other tests skip
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@kms_psr@sprite_plane_onoff.html
* igt@kms_setmode@basic-clone-single-crtc:
- bat-dg2-9: NOTRUN -> [SKIP][21] ([i915#3555] / [i915#4098])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@kms_setmode@basic-clone-single-crtc.html
* igt@prime_vgem@basic-fence-flip:
- bat-dg2-9: NOTRUN -> [SKIP][22] ([i915#3708])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@prime_vgem@basic-fence-flip.html
* igt@prime_vgem@basic-fence-mmap:
- bat-dg2-9: NOTRUN -> [SKIP][23] ([i915#3708] / [i915#4077]) +1 other test skip
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@prime_vgem@basic-fence-mmap.html
* igt@prime_vgem@basic-write:
- bat-dg2-9: NOTRUN -> [SKIP][24] ([i915#3291] / [i915#3708]) +2 other tests skip
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-9/igt@prime_vgem@basic-write.html
#### Possible fixes ####
* igt@kms_chamelium_edid@hdmi-edid-read:
- {bat-dg2-13}: [DMESG-WARN][25] ([i915#7952]) -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13753/bat-dg2-13/igt@kms_chamelium_edid@hdmi-edid-read.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-13/igt@kms_chamelium_edid@hdmi-edid-read.html
* igt@kms_hdmi_inject@inject-audio:
- fi-kbl-guc: [FAIL][27] ([IGT#3]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13753/fi-kbl-guc/igt@kms_hdmi_inject@inject-audio.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/fi-kbl-guc/igt@kms_hdmi_inject@inject-audio.html
#### Warnings ####
* igt@i915_suspend@basic-s3-without-i915:
- bat-rpls-1: [ABORT][29] ([i915#7978] / [i915#8668]) -> [FAIL][30] ([fdo#103375])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13753/bat-rpls-1/igt@i915_suspend@basic-s3-without-i915.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-rpls-1/igt@i915_suspend@basic-s3-without-i915.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[IGT#3]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/3
[fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4213]: https://gitlab.freedesktop.org/drm/intel/issues/4213
[i915#4215]: https://gitlab.freedesktop.org/drm/intel/issues/4215
[i915#5190]: https://gitlab.freedesktop.org/drm/intel/issues/5190
[i915#5274]: https://gitlab.freedesktop.org/drm/intel/issues/5274
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#5608]: https://gitlab.freedesktop.org/drm/intel/issues/5608
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#7952]: https://gitlab.freedesktop.org/drm/intel/issues/7952
[i915#7978]: https://gitlab.freedesktop.org/drm/intel/issues/7978
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668
Build changes
-------------
* CI: CI-20190529 -> None
* IGT: IGT_7539 -> IGTPW_9999
CI-20190529: 20190529
CI_DRM_13753: 13e6d61391ba3da0e26ce5c788d1fe26e036294c @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_9999: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/index.html
IGT_7539: 08e87a32fa113a9b6f30cbd9766fec346b53faac @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Testlist changes
----------------
+igt@xe_evict_ccs@evict-ccs-overcommit-parallel-instantfree-reopen
+igt@xe_evict_ccs@evict-ccs-overcommit-parallel-instantfree-samefd
+igt@xe_evict_ccs@evict-ccs-overcommit-parallel-nofree-reopen
+igt@xe_evict_ccs@evict-ccs-overcommit-parallel-nofree-samefd
+igt@xe_evict_ccs@evict-ccs-overcommit-simple
+igt@xe_evict_ccs@evict-ccs-overcommit-standalone-instantfree-reopen
+igt@xe_evict_ccs@evict-ccs-overcommit-standalone-instantfree-samefd
+igt@xe_evict_ccs@evict-ccs-overcommit-standalone-nofree-reopen
+igt@xe_evict_ccs@evict-ccs-overcommit-standalone-nofree-samefd
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/index.html
[-- Attachment #2: Type: text/html, Size: 12381 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* [igt-dev] ✓ CI.xeBAT: success for Add flat-ccs tests (rev2)
2023-10-13 11:28 [igt-dev] [PATCH i-g-t v2 0/4] Add flat-ccs tests Zbigniew Kempczyński
` (4 preceding siblings ...)
2023-10-13 17:47 ` [igt-dev] ✗ Fi.CI.BAT: failure for Add flat-ccs tests (rev2) Patchwork
@ 2023-10-13 18:22 ` Patchwork
5 siblings, 0 replies; 11+ messages in thread
From: Patchwork @ 2023-10-13 18:22 UTC (permalink / raw)
To: Zbigniew Kempczyński; +Cc: igt-dev
[-- Attachment #1: Type: text/plain, Size: 2246 bytes --]
== Series Details ==
Series: Add flat-ccs tests (rev2)
URL : https://patchwork.freedesktop.org/series/124626/
State : success
== Summary ==
CI Bug Log - changes from XEIGT_7539_BAT -> XEIGTPW_9999_BAT
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Participating hosts (4 -> 4)
------------------------------
No changes in participating hosts
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in XEIGTPW_9999_BAT:
### IGT changes ###
#### Possible regressions ####
* {igt@xe_evict_ccs@evict-ccs-overcommit-parallel-nofree-samefd} (NEW):
- bat-pvc-2: NOTRUN -> [INCOMPLETE][1]
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9999/bat-pvc-2/igt@xe_evict_ccs@evict-ccs-overcommit-parallel-nofree-samefd.html
- bat-adlp-7: NOTRUN -> [SKIP][2] +1 other test skip
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9999/bat-adlp-7/igt@xe_evict_ccs@evict-ccs-overcommit-parallel-nofree-samefd.html
New tests
---------
New tests have been introduced between XEIGT_7539_BAT and XEIGTPW_9999_BAT:
### New IGT tests (2) ###
* igt@xe_evict_ccs@evict-ccs-overcommit-parallel-nofree-samefd:
- Statuses : 1 incomplete(s) 2 pass(s) 1 skip(s)
- Exec time: [0.0] s
* igt@xe_evict_ccs@evict-ccs-overcommit-simple:
- Statuses : 3 pass(s) 1 skip(s)
- Exec time: [0.0] s
Known issues
------------
Here are the changes found in XEIGTPW_9999_BAT that come from known issues:
### IGT changes ###
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[Intel XE#524]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/524
Build changes
-------------
* IGT: IGT_7539 -> IGTPW_9999
IGTPW_9999: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/index.html
IGT_7539: 08e87a32fa113a9b6f30cbd9766fec346b53faac @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
xe-433-037b6c8b23818fa71223e996c68a4f55f2d91338: 037b6c8b23818fa71223e996c68a4f55f2d91338
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9999/index.html
[-- Attachment #2: Type: text/html, Size: 2844 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_sizes: Add common SZ_* header
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_sizes: Add common SZ_* header Zbigniew Kempczyński
@ 2023-10-17 10:58 ` Kamil Konieczny
2023-10-18 7:24 ` Zbigniew Kempczyński
0 siblings, 1 reply; 11+ messages in thread
From: Kamil Konieczny @ 2023-10-17 10:58 UTC (permalink / raw)
To: igt-dev
Hi Zbigniew,
On 2023-10-13 at 13:28:46 +0200, Zbigniew Kempczyński wrote:
> We're often use SZ_.* macros so add this globally to IGTs.
>
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
> ---
> lib/igt.h | 1 +
> lib/igt_sizes.h | 44 +++++++++++++++++++++++++++++++++
> lib/xe/xe_query.h | 4 +--
> tests/intel/gem_exec_async.c | 2 --
> tests/intel/gem_lmem_swapping.c | 1 -
> tests/intel/i915_query.c | 1 -
> tests/intel/xe_evict.c | 3 ---
> tests/msm/msm_shrink.c | 2 --
> 8 files changed, 46 insertions(+), 12 deletions(-)
> create mode 100644 lib/igt_sizes.h
>
> diff --git a/lib/igt.h b/lib/igt.h
> index 73b6f77272..7af3d10cbc 100644
> --- a/lib/igt.h
> +++ b/lib/igt.h
> @@ -39,6 +39,7 @@
> #include "igt_params.h"
> #include "igt_pipe_crc.h"
> #include "igt_pm.h"
> +#include "igt_sizes.h"
> #include "igt_stats.h"
> #include "igt_dsc.h"
> #ifdef HAVE_CHAMELIUM
> diff --git a/lib/igt_sizes.h b/lib/igt_sizes.h
> new file mode 100644
> index 0000000000..a3bc93cdd7
> --- /dev/null
> +++ b/lib/igt_sizes.h
> @@ -0,0 +1,44 @@
> +// SPDX-License-Identifier: GPL-2.0-only
We should use MIT licence, adding Petri on Cc.
Sometimes it can be MIT or GPL but GPL-only is excluding this.
> +/*
> + * Taken and adopted to IGT from kernel include/linux/sizes.h
> + */
> +#ifndef __IGT_SIZES_H__
> +#define __IGT_SIZES_H__
> +
> +#define SZ_1 0x00000001
Why not simple numbers here?
> +#define SZ_2 0x00000002
> +#define SZ_4 0x00000004
> +#define SZ_8 0x00000008
> +#define SZ_16 0x00000010
> +#define SZ_32 0x00000020
> +#define SZ_64 0x00000040
> +#define SZ_128 0x00000080
> +#define SZ_256 0x00000100
> +#define SZ_512 0x00000200
> +
> +#define SZ_1K 0x00000400
imho better just 1024
> +#define SZ_2K 0x00000800
imho better:
#define SZ_2K (2 * SZ_1K)
> +#define SZ_4K 0x00001000
> +#define SZ_8K 0x00002000
> +#define SZ_16K 0x00004000
> +#define SZ_32K 0x00008000
> +#define SZ_64K 0x00010000
> +#define SZ_128K 0x00020000
> +#define SZ_256K 0x00040000
> +#define SZ_512K 0x00080000
> +
> +#define SZ_1M 0x00100000
What about:
#define SZ_1M (1024 * SZ_1K)
> +#define SZ_2M 0x00200000
> +#define SZ_4M 0x00400000
> +#define SZ_8M 0x00800000
> +#define SZ_16M 0x01000000
> +#define SZ_32M 0x02000000
> +#define SZ_64M 0x04000000
> +#define SZ_128M 0x08000000
> +#define SZ_256M 0x10000000
> +#define SZ_512M 0x20000000
> +
> +#define SZ_1G 0x40000000
What about:
#define SZ_1G (1024 * SZ_1M)
Btw for big numbers we may need to define ULL types,
see below.
> +#define SZ_2G 0x80000000
> +
> +#endif /* __IGT_SIZES_H__ */
> diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
> index 20dbfa12c4..a21c419fb5 100644
> --- a/lib/xe/xe_query.h
> +++ b/lib/xe/xe_query.h
> @@ -12,9 +12,7 @@
> #include <stdint.h>
> #include <xe_drm.h>
> #include "igt_list.h"
> -
> -#define SZ_4K 0x1000
> -#define SZ_64K 0x10000
> +#include "igt_sizes.h"
>
> #define XE_DEFAULT_ALIGNMENT SZ_4K
> #define XE_DEFAULT_ALIGNMENT_64K SZ_64K
> diff --git a/tests/intel/gem_exec_async.c b/tests/intel/gem_exec_async.c
> index 8c131d8e13..1497c5c6c8 100644
> --- a/tests/intel/gem_exec_async.c
> +++ b/tests/intel/gem_exec_async.c
> @@ -41,8 +41,6 @@
>
> IGT_TEST_DESCRIPTION("Check that we can issue concurrent writes across the engines.");
>
> -#define SZ_1M (1024 * 1024)
> -
> static void store_dword(int fd, int id, const intel_ctx_t *ctx,
> unsigned ring, uint32_t target, uint64_t target_offset,
> uint32_t offset, uint32_t value)
> diff --git a/tests/intel/gem_lmem_swapping.c b/tests/intel/gem_lmem_swapping.c
> index 2e0ba07935..6aed806294 100644
> --- a/tests/intel/gem_lmem_swapping.c
> +++ b/tests/intel/gem_lmem_swapping.c
> @@ -198,7 +198,6 @@ IGT_TEST_DESCRIPTION("Exercise local memory swapping.");
> #define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1)
>
> #define PAGE_SIZE (1ULL << 12)
> -#define SZ_64K (16 * PAGE_SIZE)
Here it is not the same type ULL.
>
> static const char *readable_unit(uint64_t size)
> {
> diff --git a/tests/intel/i915_query.c b/tests/intel/i915_query.c
> index f97379b83b..e9cc495973 100644
> --- a/tests/intel/i915_query.c
> +++ b/tests/intel/i915_query.c
> @@ -863,7 +863,6 @@ static void test_query_regions_sanity_check(int fd)
> }
>
> #define rounddown(x, y) (x - (x % y))
> -#define SZ_64K (1ULL << 16)
Same here, what about SULL_64K ? or SZ_ULL_64K ?
Regards,
Kamil
>
> static void fill_unallocated(int fd, struct drm_i915_query_item *item, int idx,
> bool cpu_access)
> diff --git a/tests/intel/xe_evict.c b/tests/intel/xe_evict.c
> index 5b64e56b45..d0c7e93e1c 100644
> --- a/tests/intel/xe_evict.c
> +++ b/tests/intel/xe_evict.c
> @@ -453,9 +453,6 @@ threads(int fd, struct drm_xe_engine_class_instance *eci,
> pthread_join(threads_data[i].thread, NULL);
> }
>
> -#define SZ_256M 0x10000000
> -#define SZ_1G 0x40000000
> -
> static uint64_t calc_bo_size(uint64_t vram_size, int mul, int div)
> {
> if (vram_size >= SZ_1G)
> diff --git a/tests/msm/msm_shrink.c b/tests/msm/msm_shrink.c
> index d0b098aaf3..8e6c582ffc 100644
> --- a/tests/msm/msm_shrink.c
> +++ b/tests/msm/msm_shrink.c
> @@ -30,8 +30,6 @@
> #include "igt_os.h"
> #include "igt_sysfs.h"
>
> -#define SZ_1M (1024 * 1024)
> -
> static void leak(uint64_t alloc)
> {
> char *ptr;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 3/4] tests/xe_evict_ccs: Add evict ccs test
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 3/4] tests/xe_evict_ccs: Add evict ccs test Zbigniew Kempczyński
@ 2023-10-17 15:28 ` Matthew Auld
2023-10-18 17:37 ` Zbigniew Kempczyński
0 siblings, 1 reply; 11+ messages in thread
From: Matthew Auld @ 2023-10-17 15:28 UTC (permalink / raw)
To: Zbigniew Kempczyński; +Cc: igt-dev
On Fri, 13 Oct 2023 at 12:31, Zbigniew Kempczyński
<zbigniew.kempczynski@intel.com> wrote:
>
> Exercise is flat-ccs eviction working fine in the kernel driver
> when buffers takes more than available vram. Differentiate with
> standalone/parallel execution, same or separate drm fd and buffer
> freeing time. Tests are divided to two groups - first which won't
> exceed vram memory size (thus don't trigger eviction, but it is
> good for the reference logic is properly compress/decompress
> buffers) and second which exceeds.
>
> v2:
> - Add command line switches to exercise kernel with different
> sizes, number of objects and vram overcommitment
> - Add -simple test which creates single big object which enforces
> eviction (Matt)
>
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> ---
> tests/intel/xe_evict_ccs.c | 522 +++++++++++++++++++++++++++++++++++++
> tests/meson.build | 1 +
> 2 files changed, 523 insertions(+)
> create mode 100644 tests/intel/xe_evict_ccs.c
>
> diff --git a/tests/intel/xe_evict_ccs.c b/tests/intel/xe_evict_ccs.c
> new file mode 100644
> index 0000000000..72872f952b
> --- /dev/null
> +++ b/tests/intel/xe_evict_ccs.c
> @@ -0,0 +1,522 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2023 Intel Corporation
> + */
> +
> +/**
> + * TEST: Check flat-ccs eviction
> + * Category: Software building block
> + * Sub-category: Flat-CCS
> + * Functionality: evict
> + * GPU requirements: GPU needs to have dedicated VRAM
> + */
> +
> +#include "igt.h"
> +#include "igt_list.h"
> +#include "intel_blt.h"
> +#include "intel_mocs.h"
> +#include "lib/igt_syncobj.h"
> +#include "lib/intel_reg.h"
> +#include "xe_drm.h"
> +
> +#include "xe/xe_ioctl.h"
> +#include "xe/xe_query.h"
> +#include <math.h>
> +#include <string.h>
> +
> +#define OVERCOMMIT_VRAM_PERCENT 110
> +#define MIN_OBJ_KB 64
> +#define MAX_OBJ_KB (256 * 1024)
> +#define DUMP_FILENAME "/tmp/object.data"
> +#define DUMP_EXPFILENAME "/tmp/object.expected"
> +
> +static struct param {
> + bool print_bb;
> + bool disable_compression;
> + bool dump_corrupted_surface;
> + int num_objs;
> + int vram_percent;
> + int min_size_kb;
> + int max_size_kb;
> + bool verify;
> +} params = {
> + .num_objs = 0,
> + .vram_percent = OVERCOMMIT_VRAM_PERCENT,
> + .min_size_kb = MIN_OBJ_KB,
> + .max_size_kb = MAX_OBJ_KB,
> +};
> +
> +struct object {
> + uint64_t size;
> + uint32_t start_value;
> + struct blt_copy_object *blt_obj;
> + struct igt_list_head link;
> +};
> +
> +#define TEST_PARALLEL (1 << 0)
> +#define TEST_INSTANTFREE (1 << 1)
> +#define TEST_REOPEN (1 << 2)
> +#define TEST_SIMPLE (1 << 3)
> +
> +#define MAX_NPROC 8
> +struct config {
> + uint32_t flags;
> + int nproc;
> + int free_mb, total_mb;
> + int test_mb, mb_per_proc;
> + const struct param *param;
> +};
> +
> +static void copy_obj(struct blt_copy_data *blt,
> + struct blt_copy_object *src_obj,
> + struct blt_copy_object *dst_obj,
> + intel_ctx_t *ctx,
> + uint64_t ahnd)
> +{
> + struct blt_block_copy_data_ext ext = {};
> + int fd = blt->fd;
> + uint64_t bb_size = xe_get_default_alignment(fd);
> + uint32_t bb;
> + uint32_t w, h;
> +
> + w = src_obj->x2;
> + h = src_obj->y2;
> +
> + bb = xe_bo_create_flags(fd, 0, bb_size,
> + vram_memory(fd, 0) | XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
Nit: we can use visible_vram_memory() here.
> +
> + blt->color_depth = CD_32bit;
> + blt->print_bb = params.print_bb;
> + blt_set_copy_object(&blt->src, src_obj);
> + blt_set_copy_object(&blt->dst, dst_obj);
> + blt_set_object_ext(&ext.src, 0, w, h, SURFACE_TYPE_2D);
> + blt_set_object_ext(&ext.dst, 0, w, h, SURFACE_TYPE_2D);
> + blt_set_batch(&blt->bb, bb, bb_size, vram_if_possible(fd, 0));
> + blt_block_copy(fd, ctx, NULL, ahnd, blt, &ext);
> + intel_ctx_xe_sync(ctx, true);
> +
> + gem_close(fd, bb);
> + put_offset(ahnd, bb);
> + put_offset(ahnd, blt->src.handle);
> + put_offset(ahnd, blt->dst.handle);
> + intel_allocator_bind(ahnd, 0, 0);
> +}
> +
> +static uint32_t rand_and_update(uint32_t *left, uint32_t min, uint32_t max)
> +{
> + int left_bit, min_bit, max_bit, rand_id, rand_kb;
> +
> + left_bit = igt_fls(*left) - 1;
> + min_bit = igt_fls(min) - 1;
> + max_bit = max_t(int, min_t(int, igt_fls(max) - 1, left_bit), igt_fls(max));
> + rand_id = rand() % (max_bit - min_bit);
> + rand_kb = 1 << (rand_id + min_bit);
> +
> + if (*left >= rand_kb)
> + *left -= rand_kb;
> + else
> + *left = 0;
> +
> + return rand_kb;
> +}
> +
> +static struct object *create_obj(struct blt_copy_data *blt,
> + intel_ctx_t *ctx, uint64_t ahnd,
> + uint64_t size, int start_value,
> + bool disable_compression)
> +{
> + int fd = blt->fd;
> + struct object *obj;
> + uint32_t w, h;
> + uint8_t uc_mocs = intel_get_uc_mocs_index(fd);
> + int i;
> + struct blt_copy_object *src;
> +
> + obj = calloc(1, sizeof(*obj));
> + igt_assert(obj);
> + obj->size = size;
> + obj->start_value = start_value;
> +
> + w = max_t(int, 1024, roundup_power_of_two(sqrt(size/4)));
> + h = size / w / 4; /* /4 - 32bpp */
> +
> + igt_debug("Obj size: %ldKiB (%ldMiB) <w: %d, h: %d>\n",
> + size / SZ_1K, size / SZ_1M, w, h);
> +
> + src = blt_create_object(blt,
> + system_memory(fd),
> + w, h, 32, uc_mocs,
> + T_LINEAR, COMPRESSION_DISABLED,
> + COMPRESSION_TYPE_3D, true);
> +
> + obj->blt_obj = blt_create_object(blt,
> + vram_memory(fd, 0) | XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM,
Same here. I assume blt_create_object() knows to ignore the non-region
bits when setting obj->region, or doesn't it really matter?
> + w, h, 32, uc_mocs,
> + T_LINEAR,
> + disable_compression ? COMPRESSION_DISABLED :
> + COMPRESSION_ENABLED,
> + COMPRESSION_TYPE_3D, true);
> +
> + for (i = 0; i < size / sizeof(uint32_t); i++)
> + src->ptr[i] = start_value++;
> +
> + copy_obj(blt, src, obj->blt_obj, ctx, ahnd);
> +
> + blt_destroy_object_and_alloc_free(fd, ahnd, src);
> + intel_allocator_bind(ahnd, 0, 0);
> +
> + return obj;
> +}
> +
> +static void dump_obj(const struct blt_copy_object *obj, int start_value)
> +{
> + FILE *out;
> +
> + if (!params.dump_corrupted_surface)
> + return;
> +
> + out = fopen(DUMP_FILENAME, "wb");
> + fwrite(obj->ptr, obj->size, 1, out);
> + fclose(out);
> +
> + out = fopen(DUMP_EXPFILENAME, "wb");
> + for (int i = 0; i < obj->size / 4; i++) {
> + int v = start_value + i;
> +
> + fwrite(&v, sizeof(int), 1, out);
> + }
> + fclose(out);
> +}
> +
> +static void check_obj(const char *check_mode,
> + const struct blt_copy_object *obj, uint64_t size,
> + int start_value, int num_obj)
> +{
> + int i, idx;
> +
> + if (obj->ptr[0] != start_value ||
> + (obj->ptr[size/4 - 1] != start_value + size/4 - 1)) {
> + igt_info("[%s] Failed object w: %d, h: %d, size: %ldKiB (%ldMiB)\n",
> + check_mode, obj->x2, obj->y2, obj->size / SZ_1K, obj->size / SZ_1M);
> + dump_obj(obj, start_value);
> + }
> +
> + igt_assert_eq(obj->ptr[0], start_value);
> + igt_assert_eq(obj->ptr[size/4 - 1], start_value + size/4 - 1);
> +
> + /* Couple of checks of random indices */
> + for (i = 0; i < 128; i++) {
> + idx = rand() % (size/4);
> +
> + if (obj->ptr[idx] != start_value + idx) {
> + igt_info("[%s] Failed object w: %d, h: %d, size: %ldKiB (%ldMiB)\n",
> + check_mode, obj->x2, obj->y2,
> + obj->size / SZ_1K, obj->size / SZ_1M);
> + dump_obj(obj, start_value);
> + }
> +
> + igt_assert_f(obj->ptr[idx] == start_value + idx,
> + "[%s] Object number %d doesn't contain valid data",
> + check_mode, num_obj);
> + }
> +}
> +
> +static void evict_single(int fd, int child, const struct config *config)
> +{
> + struct blt_copy_data blt = {};
> + struct blt_copy_object *orig_obj;
> + uint32_t kb_left = config->mb_per_proc * SZ_1K;
> + uint32_t min_alloc_kb = config->param->min_size_kb;
> + uint32_t max_alloc_kb = config->param->max_size_kb;
> + uint32_t vm = xe_vm_create(fd, DRM_XE_VM_CREATE_ASYNC_BIND_OPS, 0);
> + uint64_t ahnd = intel_allocator_open(fd, vm, INTEL_ALLOCATOR_RELOC);
> + uint8_t uc_mocs = intel_get_uc_mocs_index(fd);
> + struct object *obj, *tmp;
> + struct igt_list_head list;
> + struct drm_xe_engine_class_instance inst = {
> + .engine_class = DRM_XE_ENGINE_CLASS_COPY,
> + };
> + intel_ctx_t *ctx;
> + uint32_t exec_queue, big_obj;
> + int num_obj = 0;
> +
> + srandom(time(NULL));
> + IGT_INIT_LIST_HEAD(&list);
> + igt_debug("[%2d] child : to allocate: %uMiB\n", child, kb_left/SZ_1K);
> +
> + blt_copy_init(fd, &blt);
> +
> + exec_queue = xe_exec_queue_create(fd, vm, &inst, 0);
> + ctx = intel_ctx_xe(fd, vm, exec_queue, 0, 0, 0);
> +
> + while (kb_left) {
> + struct blt_copy_object *verify_obj;
> + uint64_t obj_size = rand_and_update(&kb_left, min_alloc_kb, max_alloc_kb) * SZ_1K;
> + int start_value = rand();
> +
> + if (config->flags & TEST_SIMPLE)
> + obj_size = max_alloc_kb * SZ_1K;
> +
> + obj = create_obj(&blt, ctx, ahnd, obj_size, start_value,
> + config->param->disable_compression);
> + igt_list_add(&obj->link, &list);
> +
> + if (config->param->verify) {
> + verify_obj = blt_create_object(&blt, system_memory(fd),
> + obj->blt_obj->x2,
> + obj->blt_obj->y2,
> + 32, uc_mocs,
> + T_LINEAR, COMPRESSION_DISABLED,
> + 0, true);
> + copy_obj(&blt, obj->blt_obj, verify_obj, ctx, ahnd);
> + check_obj("Verify", verify_obj, obj->blt_obj->size,
> + obj->start_value, num_obj++);
> + blt_destroy_object_and_alloc_free(fd, ahnd, verify_obj);
> + intel_allocator_bind(ahnd, 0, 0);
> + }
> +
> + if (config->flags & TEST_SIMPLE) {
> + big_obj = xe_bo_create_flags(fd, vm, kb_left * SZ_1K,
> + vram_memory(fd, 0));
> + break;
> + }
> +
> + if (config->param->num_objs && ++num_obj == config->param->num_objs)
> + break;
> + }
> +
> + if (config->param->verify)
> + igt_info("[%8d] Verify ok\n", getpid());
> +
> + num_obj = 0;
> + igt_list_for_each_entry_safe(obj, tmp, &list, link) {
> + orig_obj = blt_create_object(&blt, system_memory(fd),
> + obj->blt_obj->x2,
> + obj->blt_obj->y2,
> + 32, uc_mocs,
> + T_LINEAR, COMPRESSION_DISABLED,
> + 0, true);
> + copy_obj(&blt, obj->blt_obj, orig_obj, ctx, ahnd);
> + check_obj("Check", orig_obj, obj->blt_obj->size, obj->start_value, num_obj++);
> + blt_destroy_object_and_alloc_free(fd, ahnd, orig_obj);
> +
> + if (config->flags & TEST_INSTANTFREE) {
> + igt_list_del(&obj->link);
> + blt_destroy_object_and_alloc_free(fd, ahnd, obj->blt_obj);
> + free(obj);
> + }
> + intel_allocator_bind(ahnd, 0, 0);
> + }
> +
> + if (!(config->flags & TEST_INSTANTFREE))
> + igt_list_for_each_entry_safe(obj, tmp, &list, link) {
> + igt_list_del(&obj->link);
> + blt_destroy_object_and_alloc_free(fd, ahnd, obj->blt_obj);
> + free(obj);
> + }
> +
> + if (config->flags & TEST_SIMPLE)
> + gem_close(fd, big_obj);
> +}
> +
> +static void set_config(int fd, uint32_t flags, const struct param *param,
> + struct config *config)
> +{
> + int nproc = 1;
> +
> + config->param = param;
> + config->flags = flags;
> + config->free_mb = xe_vram_available(fd, 0) / SZ_1M;
Should this be visible avail?
> + config->total_mb = xe_visible_vram_size(fd, 0) / SZ_1M;
> + config->test_mb = min_t(int, config->free_mb * config->param->vram_percent / 100,
> + config->total_mb * config->param->vram_percent / 100);
> +
> + igt_debug("VRAM memory size: %dMB/%dMB (use %dMB), overcommit perc: %d\n",
> + config->free_mb, config->total_mb,
> + config->test_mb, config->param->vram_percent);
> +
> + if (flags & TEST_PARALLEL)
> + nproc = min_t(int, sysconf(_SC_NPROCESSORS_ONLN), MAX_NPROC);
> + config->nproc = nproc;
> + config->mb_per_proc = config->test_mb / nproc;
> +
> + igt_debug("nproc: %d, mem per proc: %dMB\n", nproc, config->mb_per_proc);
> +}
> +
> +static void evict_ccs(int fd, uint32_t flags, const struct param *param)
> +{
> + struct config config;
> + char numstr[32];
> +
> + igt_info("Test mode <parallel: %d, instant free: %d, reopen: %d, simple: %d>\n",
> + !!(flags & TEST_PARALLEL),
> + !!(flags & TEST_INSTANTFREE),
> + !!(flags & TEST_REOPEN),
> + !!(flags & TEST_SIMPLE));
> + if (param->num_objs)
> + snprintf(numstr, sizeof(numstr), "%d", param->num_objs);
> + else
> + strncpy(numstr, "limited to vram", sizeof(numstr));
> + igt_info("Params: compression: %s, num objects: %s, vram percent: %d, kb <min: %d, max: %d>\n",
> + param->disable_compression ? "disabled" : "enabled",
> + numstr, param->vram_percent,
> + param->min_size_kb, param->max_size_kb);
> +
> + set_config(fd, flags, param, &config);
> +
> + if (flags & TEST_PARALLEL) {
> + igt_fork(n, config.nproc) {
> + if (flags & TEST_REOPEN) {
> + fd = drm_reopen_driver(fd);
> + intel_allocator_init();
> + }
> + evict_single(fd, n, &config);
> + }
> + igt_waitchildren();
> + } else {
> + if (flags & TEST_REOPEN)
> + fd = drm_reopen_driver(fd);
> + evict_single(fd, 0, &config);
> + }
> +}
> +
> +/**
> + *
> + * SUBTEST: evict-ccs-overcommit-simple
> + * Description: FlatCCS eviction test.
> + * Feature: flatccs
> + * Test category: stress test
> + */
> +/**
> + *
> + * SUBTEST: evict-ccs-overcommit-%s-%s-%s
> + * Description: FlatCCS eviction test.
> + * Feature: flatccs
> + * Test category: stress test
> + *
> + * arg[1]:
> + *
> + * @standalone: single process
> + * @parallel: multiple processes
> + *
> + * arg[2]:
> + *
> + * @nofree: keep objects till the end of the test
> + * @instantfree: free object after it was verified and it won't
> + * be used anymore
> + *
> + * arg[3]:
> + *
> + * @samefd: operate on same opened drm fd
> + * @reopen: use separately opened drm fds
> + *
> + */
> +static int opt_handler(int opt, int opt_index, void *data)
> +{
> + switch (opt) {
> + case 'b':
> + params.print_bb = true;
> + igt_debug("Print bb: %d\n", params.print_bb);
> + break;
> + case 'd':
> + params.disable_compression = true;
> + igt_debug("Print bb: %d\n", params.disable_compression);
> + break;
> + case 'D':
> + params.dump_corrupted_surface = true;
> + igt_debug("Print bb: %d\n", params.dump_corrupted_surface);
> + break;
> + case 'n':
> + params.num_objs = atoi(optarg);
> + igt_debug("Number objects: %d\n", params.num_objs);
> + break;
> + case 'p':
> + params.vram_percent = atoi(optarg);
> + igt_debug("Percent vram: %d\n", params.vram_percent);
> + break;
> + case 's':
> + params.min_size_kb = atoi(optarg);
> + igt_debug("Min size kb: %d\n", params.min_size_kb);
> + break;
> + case 'S':
> + params.max_size_kb = atoi(optarg);
> + igt_debug("Max size kb: %d\n", params.max_size_kb);
> + break;
> + case 'V':
> + params.verify = true;
> + igt_debug("Verify: %d\n", params.verify);
> + break;
> + default:
> + return IGT_OPT_HANDLER_ERROR;
> + }
> +
> + return IGT_OPT_HANDLER_SUCCESS;
> +}
> +
> +const char *help_str =
> + " -b\tPrint bb\n"
> + " -d\tDisable compression (don't use flatccs area)\n"
> + " -D\tDump surface which doesn't match\n"
> + " -e\tAdd temporary object which enforce eviction\n"
> + " -n\tNumber of objects to create (0 - 31)\n"
> + " -p\tPercent of VRAM to alloc\n"
> + " -s\tMinimum size of object in kb\n"
> + " -S\tMaximum size of object in kb\n"
> + " -V\tVerify object after compressing\n"
> + ;
> +
> +igt_main_args("bdDn:p:s:S:V", NULL, help_str, opt_handler, NULL)
> +{
> + struct drm_xe_engine_class_instance *hwe;
> +
> + const struct ccs {
> + const char *name;
> + uint32_t flags;
> + } ccs[] = {
> + { "simple",
> + TEST_SIMPLE },
> + { "standalone-nofree-samefd",
> + 0 },
> + { "standalone-nofree-reopen",
> + TEST_REOPEN },
> + { "standalone-instantfree-samefd",
> + TEST_INSTANTFREE },
> + { "standalone-instantfree-reopen",
> + TEST_INSTANTFREE | TEST_REOPEN },
> + { "parallel-nofree-samefd",
> + TEST_PARALLEL },
> + { "parallel-nofree-reopen",
> + TEST_PARALLEL | TEST_REOPEN },
> + { "parallel-instantfree-samefd",
> + TEST_PARALLEL | TEST_INSTANTFREE },
> + { "parallel-instantfree-reopen",
> + TEST_PARALLEL | TEST_INSTANTFREE | TEST_REOPEN },
> + { },
> + };
> + uint64_t vram_size;
> + int fd;
> +
> + igt_fixture {
> + fd = drm_open_driver(DRIVER_XE);
> + igt_require(xe_has_vram(fd));
> + vram_size = xe_visible_vram_size(fd, 0);
> + igt_assert(vram_size);
> +
> + xe_for_each_hw_engine(fd, hwe)
> + if (hwe->engine_class != DRM_XE_ENGINE_CLASS_COPY)
> + break;
> + }
> +
> + igt_fixture
> + intel_allocator_multiprocess_start();
> +
> + for (const struct ccs *s = ccs; s->name; s++) {
> + igt_subtest_f("evict-ccs-overcommit-%s", s->name)
> + evict_ccs(fd, s->flags, ¶ms);
> + }
> +
> + igt_fixture {
> + intel_allocator_multiprocess_stop();
> + drm_close_driver(fd);
> + }
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 2c2e1ca9ac..831947567f 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -279,6 +279,7 @@ intel_xe_progs = [
> 'xe_debugfs',
> 'xe_drm_fdinfo',
> 'xe_evict',
> + 'xe_evict_ccs',
> 'xe_exec_balancer',
> 'xe_exec_basic',
> 'xe_exec_compute_mode',
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_sizes: Add common SZ_* header
2023-10-17 10:58 ` Kamil Konieczny
@ 2023-10-18 7:24 ` Zbigniew Kempczyński
0 siblings, 0 replies; 11+ messages in thread
From: Zbigniew Kempczyński @ 2023-10-18 7:24 UTC (permalink / raw)
To: Kamil Konieczny, igt-dev, Petri Latvala
On Tue, Oct 17, 2023 at 12:58:52PM +0200, Kamil Konieczny wrote:
> Hi Zbigniew,
>
> On 2023-10-13 at 13:28:46 +0200, Zbigniew Kempczyński wrote:
> > We're often use SZ_.* macros so add this globally to IGTs.
> >
> > Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> > Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
> > ---
> > lib/igt.h | 1 +
> > lib/igt_sizes.h | 44 +++++++++++++++++++++++++++++++++
> > lib/xe/xe_query.h | 4 +--
> > tests/intel/gem_exec_async.c | 2 --
> > tests/intel/gem_lmem_swapping.c | 1 -
> > tests/intel/i915_query.c | 1 -
> > tests/intel/xe_evict.c | 3 ---
> > tests/msm/msm_shrink.c | 2 --
> > 8 files changed, 46 insertions(+), 12 deletions(-)
> > create mode 100644 lib/igt_sizes.h
> >
> > diff --git a/lib/igt.h b/lib/igt.h
> > index 73b6f77272..7af3d10cbc 100644
> > --- a/lib/igt.h
> > +++ b/lib/igt.h
> > @@ -39,6 +39,7 @@
> > #include "igt_params.h"
> > #include "igt_pipe_crc.h"
> > #include "igt_pm.h"
> > +#include "igt_sizes.h"
> > #include "igt_stats.h"
> > #include "igt_dsc.h"
> > #ifdef HAVE_CHAMELIUM
> > diff --git a/lib/igt_sizes.h b/lib/igt_sizes.h
> > new file mode 100644
> > index 0000000000..a3bc93cdd7
> > --- /dev/null
> > +++ b/lib/igt_sizes.h
> > @@ -0,0 +1,44 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
>
> We should use MIT licence, adding Petri on Cc.
> Sometimes it can be MIT or GPL but GPL-only is excluding this.
I'm not sure what license should be in this file.
>
> > +/*
> > + * Taken and adopted to IGT from kernel include/linux/sizes.h
> > + */
> > +#ifndef __IGT_SIZES_H__
> > +#define __IGT_SIZES_H__
> > +
> > +#define SZ_1 0x00000001
>
> Why not simple numbers here?
This is verbatim copy and I have nothing against it has SZ_x
defined as direct hex. Looks consistent for me.
>
> > +#define SZ_2 0x00000002
> > +#define SZ_4 0x00000004
> > +#define SZ_8 0x00000008
> > +#define SZ_16 0x00000010
> > +#define SZ_32 0x00000020
> > +#define SZ_64 0x00000040
> > +#define SZ_128 0x00000080
> > +#define SZ_256 0x00000100
> > +#define SZ_512 0x00000200
> > +
> > +#define SZ_1K 0x00000400
>
> imho better just 1024
What for we should mix this?
>
> > +#define SZ_2K 0x00000800
>
> imho better:
>
> #define SZ_2K (2 * SZ_1K)
>
> > +#define SZ_4K 0x00001000
> > +#define SZ_8K 0x00002000
> > +#define SZ_16K 0x00004000
> > +#define SZ_32K 0x00008000
> > +#define SZ_64K 0x00010000
> > +#define SZ_128K 0x00020000
> > +#define SZ_256K 0x00040000
> > +#define SZ_512K 0x00080000
> > +
> > +#define SZ_1M 0x00100000
>
> What about:
> #define SZ_1M (1024 * SZ_1K)
>
> > +#define SZ_2M 0x00200000
> > +#define SZ_4M 0x00400000
> > +#define SZ_8M 0x00800000
> > +#define SZ_16M 0x01000000
> > +#define SZ_32M 0x02000000
> > +#define SZ_64M 0x04000000
> > +#define SZ_128M 0x08000000
> > +#define SZ_256M 0x10000000
> > +#define SZ_512M 0x20000000
> > +
> > +#define SZ_1G 0x40000000
>
> What about:
> #define SZ_1G (1024 * SZ_1M)
>
> Btw for big numbers we may need to define ULL types,
> see below.
>
> > +#define SZ_2G 0x80000000
> > +
> > +#endif /* __IGT_SIZES_H__ */
> > diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
> > index 20dbfa12c4..a21c419fb5 100644
> > --- a/lib/xe/xe_query.h
> > +++ b/lib/xe/xe_query.h
> > @@ -12,9 +12,7 @@
> > #include <stdint.h>
> > #include <xe_drm.h>
> > #include "igt_list.h"
> > -
> > -#define SZ_4K 0x1000
> > -#define SZ_64K 0x10000
> > +#include "igt_sizes.h"
> >
> > #define XE_DEFAULT_ALIGNMENT SZ_4K
> > #define XE_DEFAULT_ALIGNMENT_64K SZ_64K
> > diff --git a/tests/intel/gem_exec_async.c b/tests/intel/gem_exec_async.c
> > index 8c131d8e13..1497c5c6c8 100644
> > --- a/tests/intel/gem_exec_async.c
> > +++ b/tests/intel/gem_exec_async.c
> > @@ -41,8 +41,6 @@
> >
> > IGT_TEST_DESCRIPTION("Check that we can issue concurrent writes across the engines.");
> >
> > -#define SZ_1M (1024 * 1024)
> > -
> > static void store_dword(int fd, int id, const intel_ctx_t *ctx,
> > unsigned ring, uint32_t target, uint64_t target_offset,
> > uint32_t offset, uint32_t value)
> > diff --git a/tests/intel/gem_lmem_swapping.c b/tests/intel/gem_lmem_swapping.c
> > index 2e0ba07935..6aed806294 100644
> > --- a/tests/intel/gem_lmem_swapping.c
> > +++ b/tests/intel/gem_lmem_swapping.c
> > @@ -198,7 +198,6 @@ IGT_TEST_DESCRIPTION("Exercise local memory swapping.");
> > #define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1)
> >
> > #define PAGE_SIZE (1ULL << 12)
> > -#define SZ_64K (16 * PAGE_SIZE)
>
> Here it is not the same type ULL.
SZ_64K is unused in this test thus removed.
>
> >
> > static const char *readable_unit(uint64_t size)
> > {
> > diff --git a/tests/intel/i915_query.c b/tests/intel/i915_query.c
> > index f97379b83b..e9cc495973 100644
> > --- a/tests/intel/i915_query.c
> > +++ b/tests/intel/i915_query.c
> > @@ -863,7 +863,6 @@ static void test_query_regions_sanity_check(int fd)
> > }
> >
> > #define rounddown(x, y) (x - (x % y))
> > -#define SZ_64K (1ULL << 16)
>
> Same here, what about SULL_64K ? or SZ_ULL_64K ?
I've check usage of SZ_64K here. It is used in arithmetic along with
uint64_t so compiler will promote whole expression to 64bit. I think
there's useless to add SULL suffix/prefix. I think SZ_x defined like
now are safe - you can use them in 32bit or 64bit expressions. Of
course if you try sth like this:
uint32_t v = 0xffffffff;
uint64_t x = v + SZ_4K;
you're shooting to your foot on your own. But I believe user
should use explicit casting here.
--
Zbigniew
>
> Regards,
> Kamil
>
> >
> > static void fill_unallocated(int fd, struct drm_i915_query_item *item, int idx,
> > bool cpu_access)
> > diff --git a/tests/intel/xe_evict.c b/tests/intel/xe_evict.c
> > index 5b64e56b45..d0c7e93e1c 100644
> > --- a/tests/intel/xe_evict.c
> > +++ b/tests/intel/xe_evict.c
> > @@ -453,9 +453,6 @@ threads(int fd, struct drm_xe_engine_class_instance *eci,
> > pthread_join(threads_data[i].thread, NULL);
> > }
> >
> > -#define SZ_256M 0x10000000
> > -#define SZ_1G 0x40000000
> > -
> > static uint64_t calc_bo_size(uint64_t vram_size, int mul, int div)
> > {
> > if (vram_size >= SZ_1G)
> > diff --git a/tests/msm/msm_shrink.c b/tests/msm/msm_shrink.c
> > index d0b098aaf3..8e6c582ffc 100644
> > --- a/tests/msm/msm_shrink.c
> > +++ b/tests/msm/msm_shrink.c
> > @@ -30,8 +30,6 @@
> > #include "igt_os.h"
> > #include "igt_sysfs.h"
> >
> > -#define SZ_1M (1024 * 1024)
> > -
> > static void leak(uint64_t alloc)
> > {
> > char *ptr;
> > --
> > 2.34.1
> >
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 3/4] tests/xe_evict_ccs: Add evict ccs test
2023-10-17 15:28 ` Matthew Auld
@ 2023-10-18 17:37 ` Zbigniew Kempczyński
0 siblings, 0 replies; 11+ messages in thread
From: Zbigniew Kempczyński @ 2023-10-18 17:37 UTC (permalink / raw)
To: Matthew Auld; +Cc: igt-dev
On Tue, Oct 17, 2023 at 04:28:12PM +0100, Matthew Auld wrote:
> On Fri, 13 Oct 2023 at 12:31, Zbigniew Kempczyński
> <zbigniew.kempczynski@intel.com> wrote:
> >
> > Exercise is flat-ccs eviction working fine in the kernel driver
> > when buffers takes more than available vram. Differentiate with
> > standalone/parallel execution, same or separate drm fd and buffer
> > freeing time. Tests are divided to two groups - first which won't
> > exceed vram memory size (thus don't trigger eviction, but it is
> > good for the reference logic is properly compress/decompress
> > buffers) and second which exceeds.
> >
> > v2:
> > - Add command line switches to exercise kernel with different
> > sizes, number of objects and vram overcommitment
> > - Add -simple test which creates single big object which enforces
> > eviction (Matt)
> >
> > Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> > Cc: Matthew Auld <matthew.auld@intel.com>
> > ---
> > tests/intel/xe_evict_ccs.c | 522 +++++++++++++++++++++++++++++++++++++
> > tests/meson.build | 1 +
> > 2 files changed, 523 insertions(+)
> > create mode 100644 tests/intel/xe_evict_ccs.c
> >
> > diff --git a/tests/intel/xe_evict_ccs.c b/tests/intel/xe_evict_ccs.c
> > new file mode 100644
> > index 0000000000..72872f952b
> > --- /dev/null
> > +++ b/tests/intel/xe_evict_ccs.c
> > @@ -0,0 +1,522 @@
> > +// SPDX-License-Identifier: MIT
> > +/*
> > + * Copyright © 2023 Intel Corporation
> > + */
> > +
> > +/**
> > + * TEST: Check flat-ccs eviction
> > + * Category: Software building block
> > + * Sub-category: Flat-CCS
> > + * Functionality: evict
> > + * GPU requirements: GPU needs to have dedicated VRAM
> > + */
> > +
> > +#include "igt.h"
> > +#include "igt_list.h"
> > +#include "intel_blt.h"
> > +#include "intel_mocs.h"
> > +#include "lib/igt_syncobj.h"
> > +#include "lib/intel_reg.h"
> > +#include "xe_drm.h"
> > +
> > +#include "xe/xe_ioctl.h"
> > +#include "xe/xe_query.h"
> > +#include <math.h>
> > +#include <string.h>
> > +
> > +#define OVERCOMMIT_VRAM_PERCENT 110
> > +#define MIN_OBJ_KB 64
> > +#define MAX_OBJ_KB (256 * 1024)
> > +#define DUMP_FILENAME "/tmp/object.data"
> > +#define DUMP_EXPFILENAME "/tmp/object.expected"
> > +
> > +static struct param {
> > + bool print_bb;
> > + bool disable_compression;
> > + bool dump_corrupted_surface;
> > + int num_objs;
> > + int vram_percent;
> > + int min_size_kb;
> > + int max_size_kb;
> > + bool verify;
> > +} params = {
> > + .num_objs = 0,
> > + .vram_percent = OVERCOMMIT_VRAM_PERCENT,
> > + .min_size_kb = MIN_OBJ_KB,
> > + .max_size_kb = MAX_OBJ_KB,
> > +};
> > +
> > +struct object {
> > + uint64_t size;
> > + uint32_t start_value;
> > + struct blt_copy_object *blt_obj;
> > + struct igt_list_head link;
> > +};
> > +
> > +#define TEST_PARALLEL (1 << 0)
> > +#define TEST_INSTANTFREE (1 << 1)
> > +#define TEST_REOPEN (1 << 2)
> > +#define TEST_SIMPLE (1 << 3)
> > +
> > +#define MAX_NPROC 8
> > +struct config {
> > + uint32_t flags;
> > + int nproc;
> > + int free_mb, total_mb;
> > + int test_mb, mb_per_proc;
> > + const struct param *param;
> > +};
> > +
> > +static void copy_obj(struct blt_copy_data *blt,
> > + struct blt_copy_object *src_obj,
> > + struct blt_copy_object *dst_obj,
> > + intel_ctx_t *ctx,
> > + uint64_t ahnd)
> > +{
> > + struct blt_block_copy_data_ext ext = {};
> > + int fd = blt->fd;
> > + uint64_t bb_size = xe_get_default_alignment(fd);
> > + uint32_t bb;
> > + uint32_t w, h;
> > +
> > + w = src_obj->x2;
> > + h = src_obj->y2;
> > +
> > + bb = xe_bo_create_flags(fd, 0, bb_size,
> > + vram_memory(fd, 0) | XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
>
> Nit: we can use visible_vram_memory() here.
Previously I tried to limit the test to visible vram and
it passes whereas this one which works with full vram size
failed.
I missed in last uapi change series that vram_memory() now
may implicitly switch to system memory and this is likely
not we want.
>
> > +
> > + blt->color_depth = CD_32bit;
> > + blt->print_bb = params.print_bb;
> > + blt_set_copy_object(&blt->src, src_obj);
> > + blt_set_copy_object(&blt->dst, dst_obj);
> > + blt_set_object_ext(&ext.src, 0, w, h, SURFACE_TYPE_2D);
> > + blt_set_object_ext(&ext.dst, 0, w, h, SURFACE_TYPE_2D);
> > + blt_set_batch(&blt->bb, bb, bb_size, vram_if_possible(fd, 0));
> > + blt_block_copy(fd, ctx, NULL, ahnd, blt, &ext);
> > + intel_ctx_xe_sync(ctx, true);
> > +
> > + gem_close(fd, bb);
> > + put_offset(ahnd, bb);
> > + put_offset(ahnd, blt->src.handle);
> > + put_offset(ahnd, blt->dst.handle);
> > + intel_allocator_bind(ahnd, 0, 0);
> > +}
> > +
> > +static uint32_t rand_and_update(uint32_t *left, uint32_t min, uint32_t max)
> > +{
> > + int left_bit, min_bit, max_bit, rand_id, rand_kb;
> > +
> > + left_bit = igt_fls(*left) - 1;
> > + min_bit = igt_fls(min) - 1;
> > + max_bit = max_t(int, min_t(int, igt_fls(max) - 1, left_bit), igt_fls(max));
> > + rand_id = rand() % (max_bit - min_bit);
> > + rand_kb = 1 << (rand_id + min_bit);
> > +
> > + if (*left >= rand_kb)
> > + *left -= rand_kb;
> > + else
> > + *left = 0;
> > +
> > + return rand_kb;
> > +}
> > +
> > +static struct object *create_obj(struct blt_copy_data *blt,
> > + intel_ctx_t *ctx, uint64_t ahnd,
> > + uint64_t size, int start_value,
> > + bool disable_compression)
> > +{
> > + int fd = blt->fd;
> > + struct object *obj;
> > + uint32_t w, h;
> > + uint8_t uc_mocs = intel_get_uc_mocs_index(fd);
> > + int i;
> > + struct blt_copy_object *src;
> > +
> > + obj = calloc(1, sizeof(*obj));
> > + igt_assert(obj);
> > + obj->size = size;
> > + obj->start_value = start_value;
> > +
> > + w = max_t(int, 1024, roundup_power_of_two(sqrt(size/4)));
> > + h = size / w / 4; /* /4 - 32bpp */
> > +
> > + igt_debug("Obj size: %ldKiB (%ldMiB) <w: %d, h: %d>\n",
> > + size / SZ_1K, size / SZ_1M, w, h);
> > +
> > + src = blt_create_object(blt,
> > + system_memory(fd),
> > + w, h, 32, uc_mocs,
> > + T_LINEAR, COMPRESSION_DISABLED,
> > + COMPRESSION_TYPE_3D, true);
> > +
> > + obj->blt_obj = blt_create_object(blt,
> > + vram_memory(fd, 0) | XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM,
>
> Same here. I assume blt_create_object() knows to ignore the non-region
> bits when setting obj->region, or doesn't it really matter?
Eh, you're right. This bits should be get rid off before storing
on to obj->region. Thanks for spotting this, I'm going to fix this
and respin in v3.
>
> > + w, h, 32, uc_mocs,
> > + T_LINEAR,
> > + disable_compression ? COMPRESSION_DISABLED :
> > + COMPRESSION_ENABLED,
> > + COMPRESSION_TYPE_3D, true);
> > +
> > + for (i = 0; i < size / sizeof(uint32_t); i++)
> > + src->ptr[i] = start_value++;
> > +
> > + copy_obj(blt, src, obj->blt_obj, ctx, ahnd);
> > +
> > + blt_destroy_object_and_alloc_free(fd, ahnd, src);
> > + intel_allocator_bind(ahnd, 0, 0);
> > +
> > + return obj;
> > +}
> > +
> > +static void dump_obj(const struct blt_copy_object *obj, int start_value)
> > +{
> > + FILE *out;
> > +
> > + if (!params.dump_corrupted_surface)
> > + return;
> > +
> > + out = fopen(DUMP_FILENAME, "wb");
> > + fwrite(obj->ptr, obj->size, 1, out);
> > + fclose(out);
> > +
> > + out = fopen(DUMP_EXPFILENAME, "wb");
> > + for (int i = 0; i < obj->size / 4; i++) {
> > + int v = start_value + i;
> > +
> > + fwrite(&v, sizeof(int), 1, out);
> > + }
> > + fclose(out);
> > +}
> > +
> > +static void check_obj(const char *check_mode,
> > + const struct blt_copy_object *obj, uint64_t size,
> > + int start_value, int num_obj)
> > +{
> > + int i, idx;
> > +
> > + if (obj->ptr[0] != start_value ||
> > + (obj->ptr[size/4 - 1] != start_value + size/4 - 1)) {
> > + igt_info("[%s] Failed object w: %d, h: %d, size: %ldKiB (%ldMiB)\n",
> > + check_mode, obj->x2, obj->y2, obj->size / SZ_1K, obj->size / SZ_1M);
> > + dump_obj(obj, start_value);
> > + }
> > +
> > + igt_assert_eq(obj->ptr[0], start_value);
> > + igt_assert_eq(obj->ptr[size/4 - 1], start_value + size/4 - 1);
> > +
> > + /* Couple of checks of random indices */
> > + for (i = 0; i < 128; i++) {
> > + idx = rand() % (size/4);
> > +
> > + if (obj->ptr[idx] != start_value + idx) {
> > + igt_info("[%s] Failed object w: %d, h: %d, size: %ldKiB (%ldMiB)\n",
> > + check_mode, obj->x2, obj->y2,
> > + obj->size / SZ_1K, obj->size / SZ_1M);
> > + dump_obj(obj, start_value);
> > + }
> > +
> > + igt_assert_f(obj->ptr[idx] == start_value + idx,
> > + "[%s] Object number %d doesn't contain valid data",
> > + check_mode, num_obj);
> > + }
> > +}
> > +
> > +static void evict_single(int fd, int child, const struct config *config)
> > +{
> > + struct blt_copy_data blt = {};
> > + struct blt_copy_object *orig_obj;
> > + uint32_t kb_left = config->mb_per_proc * SZ_1K;
> > + uint32_t min_alloc_kb = config->param->min_size_kb;
> > + uint32_t max_alloc_kb = config->param->max_size_kb;
> > + uint32_t vm = xe_vm_create(fd, DRM_XE_VM_CREATE_ASYNC_BIND_OPS, 0);
> > + uint64_t ahnd = intel_allocator_open(fd, vm, INTEL_ALLOCATOR_RELOC);
> > + uint8_t uc_mocs = intel_get_uc_mocs_index(fd);
> > + struct object *obj, *tmp;
> > + struct igt_list_head list;
> > + struct drm_xe_engine_class_instance inst = {
> > + .engine_class = DRM_XE_ENGINE_CLASS_COPY,
> > + };
> > + intel_ctx_t *ctx;
> > + uint32_t exec_queue, big_obj;
> > + int num_obj = 0;
> > +
> > + srandom(time(NULL));
> > + IGT_INIT_LIST_HEAD(&list);
> > + igt_debug("[%2d] child : to allocate: %uMiB\n", child, kb_left/SZ_1K);
> > +
> > + blt_copy_init(fd, &blt);
> > +
> > + exec_queue = xe_exec_queue_create(fd, vm, &inst, 0);
> > + ctx = intel_ctx_xe(fd, vm, exec_queue, 0, 0, 0);
> > +
> > + while (kb_left) {
> > + struct blt_copy_object *verify_obj;
> > + uint64_t obj_size = rand_and_update(&kb_left, min_alloc_kb, max_alloc_kb) * SZ_1K;
> > + int start_value = rand();
> > +
> > + if (config->flags & TEST_SIMPLE)
> > + obj_size = max_alloc_kb * SZ_1K;
> > +
> > + obj = create_obj(&blt, ctx, ahnd, obj_size, start_value,
> > + config->param->disable_compression);
> > + igt_list_add(&obj->link, &list);
> > +
> > + if (config->param->verify) {
> > + verify_obj = blt_create_object(&blt, system_memory(fd),
> > + obj->blt_obj->x2,
> > + obj->blt_obj->y2,
> > + 32, uc_mocs,
> > + T_LINEAR, COMPRESSION_DISABLED,
> > + 0, true);
> > + copy_obj(&blt, obj->blt_obj, verify_obj, ctx, ahnd);
> > + check_obj("Verify", verify_obj, obj->blt_obj->size,
> > + obj->start_value, num_obj++);
> > + blt_destroy_object_and_alloc_free(fd, ahnd, verify_obj);
> > + intel_allocator_bind(ahnd, 0, 0);
> > + }
> > +
> > + if (config->flags & TEST_SIMPLE) {
> > + big_obj = xe_bo_create_flags(fd, vm, kb_left * SZ_1K,
> > + vram_memory(fd, 0));
> > + break;
> > + }
> > +
> > + if (config->param->num_objs && ++num_obj == config->param->num_objs)
> > + break;
> > + }
> > +
> > + if (config->param->verify)
> > + igt_info("[%8d] Verify ok\n", getpid());
> > +
> > + num_obj = 0;
> > + igt_list_for_each_entry_safe(obj, tmp, &list, link) {
> > + orig_obj = blt_create_object(&blt, system_memory(fd),
> > + obj->blt_obj->x2,
> > + obj->blt_obj->y2,
> > + 32, uc_mocs,
> > + T_LINEAR, COMPRESSION_DISABLED,
> > + 0, true);
> > + copy_obj(&blt, obj->blt_obj, orig_obj, ctx, ahnd);
> > + check_obj("Check", orig_obj, obj->blt_obj->size, obj->start_value, num_obj++);
> > + blt_destroy_object_and_alloc_free(fd, ahnd, orig_obj);
> > +
> > + if (config->flags & TEST_INSTANTFREE) {
> > + igt_list_del(&obj->link);
> > + blt_destroy_object_and_alloc_free(fd, ahnd, obj->blt_obj);
> > + free(obj);
> > + }
> > + intel_allocator_bind(ahnd, 0, 0);
> > + }
> > +
> > + if (!(config->flags & TEST_INSTANTFREE))
> > + igt_list_for_each_entry_safe(obj, tmp, &list, link) {
> > + igt_list_del(&obj->link);
> > + blt_destroy_object_and_alloc_free(fd, ahnd, obj->blt_obj);
> > + free(obj);
> > + }
> > +
> > + if (config->flags & TEST_SIMPLE)
> > + gem_close(fd, big_obj);
> > +}
> > +
> > +static void set_config(int fd, uint32_t flags, const struct param *param,
> > + struct config *config)
> > +{
> > + int nproc = 1;
> > +
> > + config->param = param;
> > + config->flags = flags;
> > + config->free_mb = xe_vram_available(fd, 0) / SZ_1M;
>
> Should this be visible avail?
That was something weird here, I'm going to recheck this.
Thanks for the review.
--
Zbigniew
>
> > + config->total_mb = xe_visible_vram_size(fd, 0) / SZ_1M;
> > + config->test_mb = min_t(int, config->free_mb * config->param->vram_percent / 100,
> > + config->total_mb * config->param->vram_percent / 100);
> > +
> > + igt_debug("VRAM memory size: %dMB/%dMB (use %dMB), overcommit perc: %d\n",
> > + config->free_mb, config->total_mb,
> > + config->test_mb, config->param->vram_percent);
> > +
> > + if (flags & TEST_PARALLEL)
> > + nproc = min_t(int, sysconf(_SC_NPROCESSORS_ONLN), MAX_NPROC);
> > + config->nproc = nproc;
> > + config->mb_per_proc = config->test_mb / nproc;
> > +
> > + igt_debug("nproc: %d, mem per proc: %dMB\n", nproc, config->mb_per_proc);
> > +}
> > +
> > +static void evict_ccs(int fd, uint32_t flags, const struct param *param)
> > +{
> > + struct config config;
> > + char numstr[32];
> > +
> > + igt_info("Test mode <parallel: %d, instant free: %d, reopen: %d, simple: %d>\n",
> > + !!(flags & TEST_PARALLEL),
> > + !!(flags & TEST_INSTANTFREE),
> > + !!(flags & TEST_REOPEN),
> > + !!(flags & TEST_SIMPLE));
> > + if (param->num_objs)
> > + snprintf(numstr, sizeof(numstr), "%d", param->num_objs);
> > + else
> > + strncpy(numstr, "limited to vram", sizeof(numstr));
> > + igt_info("Params: compression: %s, num objects: %s, vram percent: %d, kb <min: %d, max: %d>\n",
> > + param->disable_compression ? "disabled" : "enabled",
> > + numstr, param->vram_percent,
> > + param->min_size_kb, param->max_size_kb);
> > +
> > + set_config(fd, flags, param, &config);
> > +
> > + if (flags & TEST_PARALLEL) {
> > + igt_fork(n, config.nproc) {
> > + if (flags & TEST_REOPEN) {
> > + fd = drm_reopen_driver(fd);
> > + intel_allocator_init();
> > + }
> > + evict_single(fd, n, &config);
> > + }
> > + igt_waitchildren();
> > + } else {
> > + if (flags & TEST_REOPEN)
> > + fd = drm_reopen_driver(fd);
> > + evict_single(fd, 0, &config);
> > + }
> > +}
> > +
> > +/**
> > + *
> > + * SUBTEST: evict-ccs-overcommit-simple
> > + * Description: FlatCCS eviction test.
> > + * Feature: flatccs
> > + * Test category: stress test
> > + */
> > +/**
> > + *
> > + * SUBTEST: evict-ccs-overcommit-%s-%s-%s
> > + * Description: FlatCCS eviction test.
> > + * Feature: flatccs
> > + * Test category: stress test
> > + *
> > + * arg[1]:
> > + *
> > + * @standalone: single process
> > + * @parallel: multiple processes
> > + *
> > + * arg[2]:
> > + *
> > + * @nofree: keep objects till the end of the test
> > + * @instantfree: free object after it was verified and it won't
> > + * be used anymore
> > + *
> > + * arg[3]:
> > + *
> > + * @samefd: operate on same opened drm fd
> > + * @reopen: use separately opened drm fds
> > + *
> > + */
> > +static int opt_handler(int opt, int opt_index, void *data)
> > +{
> > + switch (opt) {
> > + case 'b':
> > + params.print_bb = true;
> > + igt_debug("Print bb: %d\n", params.print_bb);
> > + break;
> > + case 'd':
> > + params.disable_compression = true;
> > + igt_debug("Print bb: %d\n", params.disable_compression);
> > + break;
> > + case 'D':
> > + params.dump_corrupted_surface = true;
> > + igt_debug("Print bb: %d\n", params.dump_corrupted_surface);
> > + break;
> > + case 'n':
> > + params.num_objs = atoi(optarg);
> > + igt_debug("Number objects: %d\n", params.num_objs);
> > + break;
> > + case 'p':
> > + params.vram_percent = atoi(optarg);
> > + igt_debug("Percent vram: %d\n", params.vram_percent);
> > + break;
> > + case 's':
> > + params.min_size_kb = atoi(optarg);
> > + igt_debug("Min size kb: %d\n", params.min_size_kb);
> > + break;
> > + case 'S':
> > + params.max_size_kb = atoi(optarg);
> > + igt_debug("Max size kb: %d\n", params.max_size_kb);
> > + break;
> > + case 'V':
> > + params.verify = true;
> > + igt_debug("Verify: %d\n", params.verify);
> > + break;
> > + default:
> > + return IGT_OPT_HANDLER_ERROR;
> > + }
> > +
> > + return IGT_OPT_HANDLER_SUCCESS;
> > +}
> > +
> > +const char *help_str =
> > + " -b\tPrint bb\n"
> > + " -d\tDisable compression (don't use flatccs area)\n"
> > + " -D\tDump surface which doesn't match\n"
> > + " -e\tAdd temporary object which enforce eviction\n"
> > + " -n\tNumber of objects to create (0 - 31)\n"
> > + " -p\tPercent of VRAM to alloc\n"
> > + " -s\tMinimum size of object in kb\n"
> > + " -S\tMaximum size of object in kb\n"
> > + " -V\tVerify object after compressing\n"
> > + ;
> > +
> > +igt_main_args("bdDn:p:s:S:V", NULL, help_str, opt_handler, NULL)
> > +{
> > + struct drm_xe_engine_class_instance *hwe;
> > +
> > + const struct ccs {
> > + const char *name;
> > + uint32_t flags;
> > + } ccs[] = {
> > + { "simple",
> > + TEST_SIMPLE },
> > + { "standalone-nofree-samefd",
> > + 0 },
> > + { "standalone-nofree-reopen",
> > + TEST_REOPEN },
> > + { "standalone-instantfree-samefd",
> > + TEST_INSTANTFREE },
> > + { "standalone-instantfree-reopen",
> > + TEST_INSTANTFREE | TEST_REOPEN },
> > + { "parallel-nofree-samefd",
> > + TEST_PARALLEL },
> > + { "parallel-nofree-reopen",
> > + TEST_PARALLEL | TEST_REOPEN },
> > + { "parallel-instantfree-samefd",
> > + TEST_PARALLEL | TEST_INSTANTFREE },
> > + { "parallel-instantfree-reopen",
> > + TEST_PARALLEL | TEST_INSTANTFREE | TEST_REOPEN },
> > + { },
> > + };
> > + uint64_t vram_size;
> > + int fd;
> > +
> > + igt_fixture {
> > + fd = drm_open_driver(DRIVER_XE);
> > + igt_require(xe_has_vram(fd));
> > + vram_size = xe_visible_vram_size(fd, 0);
> > + igt_assert(vram_size);
> > +
> > + xe_for_each_hw_engine(fd, hwe)
> > + if (hwe->engine_class != DRM_XE_ENGINE_CLASS_COPY)
> > + break;
> > + }
> > +
> > + igt_fixture
> > + intel_allocator_multiprocess_start();
> > +
> > + for (const struct ccs *s = ccs; s->name; s++) {
> > + igt_subtest_f("evict-ccs-overcommit-%s", s->name)
> > + evict_ccs(fd, s->flags, ¶ms);
> > + }
> > +
> > + igt_fixture {
> > + intel_allocator_multiprocess_stop();
> > + drm_close_driver(fd);
> > + }
> > +}
> > diff --git a/tests/meson.build b/tests/meson.build
> > index 2c2e1ca9ac..831947567f 100644
> > --- a/tests/meson.build
> > +++ b/tests/meson.build
> > @@ -279,6 +279,7 @@ intel_xe_progs = [
> > 'xe_debugfs',
> > 'xe_drm_fdinfo',
> > 'xe_evict',
> > + 'xe_evict_ccs',
> > 'xe_exec_balancer',
> > 'xe_exec_basic',
> > 'xe_exec_compute_mode',
> > --
> > 2.34.1
> >
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-10-18 17:38 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-13 11:28 [igt-dev] [PATCH i-g-t v2 0/4] Add flat-ccs tests Zbigniew Kempczyński
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 1/4] lib/intel_blt: Release an offset in the allocator on buffer destroy Zbigniew Kempczyński
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_sizes: Add common SZ_* header Zbigniew Kempczyński
2023-10-17 10:58 ` Kamil Konieczny
2023-10-18 7:24 ` Zbigniew Kempczyński
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 3/4] tests/xe_evict_ccs: Add evict ccs test Zbigniew Kempczyński
2023-10-17 15:28 ` Matthew Auld
2023-10-18 17:37 ` Zbigniew Kempczyński
2023-10-13 11:28 ` [igt-dev] [PATCH i-g-t v2 4/4] intel-ci/xe-fast-feedback: Add two xe_evict_ccs subtests for Xe run Zbigniew Kempczyński
2023-10-13 17:47 ` [igt-dev] ✗ Fi.CI.BAT: failure for Add flat-ccs tests (rev2) Patchwork
2023-10-13 18:22 ` [igt-dev] ✓ CI.xeBAT: success " Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox