Add flat-ccs tests
Subsystems (2)
v2 cover Add flat-ccs tests
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
Signature · 1 line
2.34.1
PATCH v2 1/4 lib/intel_blt: Release an offset in the allocator on buffer destroy
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.
--- lib/intel_blt.c | 15 ++++++++++++++- lib/intel_blt.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-)
lib/intel_blt.c +14 -1
@@ -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,
lib/intel_blt.h +2 -0
@@ -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,
Signature · 1 line
2.34.1
PATCH v2 2/4 lib/igt_sizes: Add common SZ_* header
In reply to Zbigniew KempczyńskiWe're often use SZ_.* macros so add this globally to IGTs.
--- 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
lib/igt.h +1 -0
@@ -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
lib/igt_sizes.h new file +44 -0
44 lines not on this page · raw message
lib/xe/xe_query.h +1 -3
@@ -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
tests/intel/gem_exec_async.c +0 -2
@@ -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)
tests/intel/gem_lmem_swapping.c +0 -1
@@ -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) {
tests/intel/i915_query.c +0 -1
@@ -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)
tests/intel/xe_evict.c +0 -3
@@ -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 )
tests/msm/msm_shrink.c +0 -2
@@ -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;
Signature · 1 line
2.34.1
Re: [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_sizes: Add common SZ_* header
Hi Zbigniew,
Quoted 34 lines · Zbigniew Kempczyński
We're often use SZ_.* macros so add this globally to IGTs.
Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Kamil Konieczny <[email protected]>--- 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.hlib/igt.h +1
-0@@ -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 lib/igt_sizes.h new file +0
-0
lib/igt_sizes.h line 1
Quoted 1 line
lib/igt_sizes.h new file +1
-0@@ -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.
lib/igt_sizes.h line 8
Quoted 7 lines
lib/igt_sizes.h new file +7
-0+/* +* 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?
lib/igt_sizes.h line 19
Quoted 11 lines
lib/igt_sizes.h new file +11
-0+#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
lib/igt_sizes.h line 20
Quoted 1 line
lib/igt_sizes.h new file +1
-0+#define SZ_2K 0x00000800
imho better:
#define SZ_2K (2 * SZ_1K)
lib/igt_sizes.h line 30
Quoted 10 lines
lib/igt_sizes.h new file +10
-0+#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)
lib/igt_sizes.h line 41
Quoted 11 lines
lib/igt_sizes.h new file +11
-0+#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.
Quoted 36 lines
lib/igt_sizes.h new file +3
-0+#define SZ_2G 0x80000000 + +#endif /* __IGT_SIZES_H__ */ lib/xe/xe_query.h +1
-3@@ -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_64Ktests/intel/gem_exec_async.c +0
-2@@ -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)tests/intel/gem_lmem_swapping.c +0
-0
tests/intel/gem_lmem_swapping.c IGT_TEST_DESCRIPTION("Exercise local memory swapping."); · line 201
Quoted 4 lines
tests/intel/gem_lmem_swapping.c +0
-1@@ -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.
tests/intel/i915_query.c static void test_query_regions_sanity_check(int fd) · line 866
Quoted 12 lines
tests/intel/gem_lmem_swapping.c +0
-0static const char *readable_unit (uint64_t size) {tests/intel/i915_query.c +0
-1@@ -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
Quoted 33 lines
tests/intel/i915_query.c +0
-0static void fill_unallocated (int fd,struct drm_i915_query_item *item,int idx,bool cpu_access)tests/intel/xe_evict.c +0
-3@@ -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 )tests/msm/msm_shrink.c +0
-2@@ -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;Signature · 1 line
2.34.1
Re: [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_sizes: Add common SZ_* header
Quoted 33 lines · Kamil Konieczny
Hi Zbigniew,
Quoted 30 lines · Zbigniew Kempczyński
We're often use SZ_.* macros so add this globally to IGTs.
Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Kamil Konieczny <[email protected]>--- 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.hlib/igt.h +1
-0@@ -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 lib/igt_sizes.h new file +0
-0
Quoted 8 lines
lib/igt_sizes.h line 1
Quoted 5 lines
index 0000000000..a3bc93cdd7
lib/igt_sizes.h new file +1
-0@@ -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.
Quoted 10 lines
lib/igt_sizes.h line 8
Quoted 8 lines
lib/igt_sizes.h new file +7
-0+/* +* Taken and adopted to IGT from kernel include/linux/sizes.h +*/ +#ifndef __IGT_SIZES_H__ +#define __IGT_SIZES_H__ + +#define SZ_1 0x00000001Why 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.
Quoted 14 lines
lib/igt_sizes.h line 19
Quoted 12 lines
lib/igt_sizes.h new file +11
-0+#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 0x00000400imho better just 1024
What for we should mix this?
Quoted 77 lines
lib/igt_sizes.h line 20
Quoted 2 lines
lib/igt_sizes.h new file +1
-0+#define SZ_2K 0x00000800imho better:
#define
SZ_2K(2 *SZ_1K)lib/igt_sizes.h line 30
Quoted 10 lines
lib/igt_sizes.h new file +10
-0+#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 0x00100000What about:
#defineSZ_1M(1024 *SZ_1K)lib/igt_sizes.h line 41
Quoted 11 lines
lib/igt_sizes.h new file +11
-0+#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 0x40000000What about:
#defineSZ_1G(1024 *SZ_1M)Btw for big numbers we may need to define ULL types, see below.
Quoted 38 lines
lib/igt_sizes.h new file +3
-0+#define SZ_2G 0x80000000 + +#endif /* __IGT_SIZES_H__ */ lib/xe/xe_query.h +1
-3@@ -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_64Ktests/intel/gem_exec_async.c +0
-2@@ -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)tests/intel/gem_lmem_swapping.c +0
-0@@ -198,7 +198,6 @@ IGT_TEST_DESCRIPTION("Exercise local memory swapping.");#define round_up (x, y) ((((x) - 1) | __round_mask(x, y)) + 1)
Quoted 4 lines
tests/intel/gem_lmem_swapping.c IGT_TEST_DESCRIPTION("Exercise local memory swapping."); · line 201
Quoted 2 lines
tests/intel/gem_lmem_swapping.c +0
-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.
Quoted 11 lines
Quoted 11 lines
tests/intel/gem_lmem_swapping.c +0
-0static const char *readable_unit (uint64_t size) {tests/intel/i915_query.c +0
-0@@ -863,7 +863,6 @@ static void test_query_regions_sanity_check(int fd) }
Quoted 4 lines
tests/intel/i915_query.c static void test_query_regions_sanity_check(int fd) · line 866
Quoted 2 lines
tests/intel/i915_query.c +0
-1#define rounddown (x, y) (x - (x % y)) -#define SZ_64K (1ULL << 16)Same here, what about
SULL_64K? orSZ_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
Quoted 37 lines
Regards,
KamilQuoted 33 lines
tests/intel/i915_query.c +0
-0static void fill_unallocated (int fd,struct drm_i915_query_item *item,int idx,bool cpu_access)tests/intel/xe_evict.c +0
-3@@ -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 )tests/msm/msm_shrink.c +0
-2@@ -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;Signature · 1 line
2.34.1
PATCH v2 3/4 tests/xe_evict_ccs: Add evict ccs test
In reply to Zbigniew KempczyńskiExercise 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)
--- 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
tests/intel/xe_evict_ccs.c new file +522 -0
@@ -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); + } +}
tests/meson.build +1 -0
@@ -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',
Signature · 1 line
2.34.1
Re: [igt-dev] [PATCH i-g-t v2 3/4] tests/xe_evict_ccs: Add evict ccs test
Quoted 105 lines · Zbigniew Kempczyński
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 <[email protected]>Cc Matthew Auld <[email protected]>--- tests/intel/xe_evict_ccs.c | 522 +++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 2 files changed, 523 insertions(+) create mode 100644 tests/intel/xe_evict_ccs.ctests/intel/xe_evict_ccs.c new file +76
-0@@ -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 = {};
tests/intel/xe_evict_ccs.c line 86
Quoted 10 lines
tests/intel/xe_evict_ccs.c new file +10
-0+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.
Quoted 57 lines
tests/intel/xe_evict_ccs.c new file +57
-0+ + 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",
tests/intel/xe_evict_ccs.c line 153
Quoted 10 lines
tests/intel/xe_evict_ccs.c new file +10
-0+ 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?
Quoted 166 lines
tests/intel/xe_evict_ccs.c new file +166
-0+ 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);
tests/intel/xe_evict_ccs.c line 329
Quoted 10 lines
tests/intel/xe_evict_ccs.c new file +10
-0+} + +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?
Quoted 208 lines
tests/intel/xe_evict_ccs.c new file +193
-0+ 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); + } +}tests/meson.build +1
-1@@ -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
Re: [igt-dev] [PATCH i-g-t v2 3/4] tests/xe_evict_ccs: Add evict ccs test
Quoted 111 lines · Matthew Auld
Quoted 109 lines · Zbigniew Kempczyński
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 <[email protected]>Cc Matthew Auld <[email protected]>--- tests/intel/xe_evict_ccs.c | 522 +++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 2 files changed, 523 insertions(+) create mode 100644 tests/intel/xe_evict_ccs.ctests/intel/xe_evict_ccs.c new file +80
-0@@ -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;
Quoted 8 lines
tests/intel/xe_evict_ccs.c line 86
Quoted 6 lines
tests/intel/xe_evict_ccs.c new file +6
-0+ + 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.
Quoted 63 lines
Quoted 63 lines
tests/intel/xe_evict_ccs.c new file +62
-0+ + 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,
Quoted 8 lines
tests/intel/xe_evict_ccs.c line 153
Quoted 5 lines
tests/intel/xe_evict_ccs.c new file +5
-0+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 settingobj->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.
Quoted 171 lines
Quoted 171 lines
tests/intel/xe_evict_ccs.c new file +170
-0+ 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)
Quoted 8 lines
tests/intel/xe_evict_ccs.c line 329
Quoted 6 lines
tests/intel/xe_evict_ccs.c new file +6
-0+{ +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
Quoted 209 lines
Quoted 209 lines
tests/intel/xe_evict_ccs.c new file +193
-0+ 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); + } +}tests/meson.build +1
-1@@ -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
PATCH v2 4/4 intel-ci/xe-fast-feedback: Add two xe_evict_ccs subtests for Xe run
In reply to Zbigniew KempczyńskiThere 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.
--- tests/intel-ci/xe-fast-feedback.testlist | 2 ++ 1 file changed, 2 insertions(+)
tests/intel-ci/xe-fast-feedback.testlist +2 -0
@@ -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
Signature · 1 line
2.34.1
Patchwork
CI[igt-dev] ✗ Fi.CI.BAT: failure for Add flat-ccs tests (rev2)
In reply to Zbigniew Kempczyński== Series Details ==
== 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 ([email protected]) 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@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-11/igt@i915_selftest@[email protected]
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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-rpls-1/igt@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
* 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@[email protected]
#### 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@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-dg2-13/igt@[email protected]
* 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@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/fi-kbl-guc/igt@[email protected]
#### 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@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9999/bat-rpls-1/igt@[email protected]
{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
Patchwork
CI[igt-dev] ✓ CI.xeBAT: success for Add flat-ccs tests (rev2)
In reply to Zbigniew Kempczyński== Series Details ==
== 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@[email protected]
- 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@[email protected]
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