Add flat-ccs tests
Subsystems (2)
v3 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
v3: Handle mappable vram flag in blitter helper + address some minor
nits
Zbigniew Kempczyński (5):
lib/intel_blt: Release an offset in the allocator on buffer destroy lib/intel_blt: Add visible vram flag if object needs to be mapped 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 | 22 +- 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 | 520 +++++++++++++++++++++++ tests/meson.build | 1 + tests/msm/msm_shrink.c | 2 - 13 files changed, 591 insertions(+), 14 deletions(-) create mode 100644 lib/igt_sizes.h create mode 100644 tests/intel/xe_evict_ccs.c
Signature · 1 line
2.34.1
PATCH v3 1/5 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 v3 2/5 lib/intel_blt: Add visible vram flag if object needs to be mapped
In reply to Zbigniew KempczyńskiFor objects with blitter helper in vram which needs to be mapped add visible vram flag to ensure it will be placed in mappable vram region.
--- lib/intel_blt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
lib/intel_blt.c +6 -1
@@ -1618,8 +1618,13 @@ blt_create_object(const struct blt_copy_data *blt, uint32_t region, obj->size = size;if (blt->driver ==INTEL_DRIVER_XE ) { +uint64_t flags = region; + +if (create_mapping && region !=system_memory (blt->fd)) + flags |=XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM ; + size =ALIGN (size,xe_get_default_alignment (blt->fd)); - handle =xe_bo_create_flags (blt->fd,0 , size, region); + handle =xe_bo_create_flags (blt->fd,0 , size, flags); }else {igt_assert (__gem_create_in_memory_regions (blt->fd, &handle, &size, region) ==0 );
Signature · 1 line
2.34.1
Re: [igt-dev] [PATCH i-g-t v3 2/5] lib/intel_blt: Add visible vram flag if object needs to be mapped
Quoted 7 lines · Zbigniew Kempczyński
For objects with blitter helper in vram which needs to be mapped add visible vram flag to ensure it will be placed in mappable vram region.
Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Matthew Auld <[email protected]>
PATCH v3 3/5 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
@@ -448,9 +448,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 v3 3/5] lib/igt_sizes: Add common SZ_* header
Hi Zbigniew,
Quoted 1 line · Zbigniew Kempczyński
We're often use SZ_.* macros so add this globally to IGTs.
--- ^^^
imho: "We often use"
Quoted 33 lines
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 3
Quoted 3 lines
lib/igt_sizes.h new file +3
-0@@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT +/* +* Taken and adopted to IGT from kernel include/linux/sizes.h
We useally add here Copyright, +cc Petri
Quoted 4 lines
lib/igt_sizes.h new file +4
-0+*/ +#ifndef __IGT_SIZES_H__ +#define __IGT_SIZES_H__ +
lib/igt_sizes.h line 17
Quoted 10 lines
lib/igt_sizes.h new file +10
-0+#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
Do we really need this 1...512? They may be used without SZ_? We do not use these anywhere?
Below ones starting with 1K are ok.
Quoted 60 lines
lib/igt_sizes.h new file +27
-0+ +#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__ */ 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)
---------- ^^^^^^
This is not the same... why not change it to 16_PAGES? Also this is ULL, after you change it will become int.
Rest looks ok.
Regards,
Kamil
Quoted 45 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)static void fill_unallocated (int fd,struct drm_i915_query_item *item,int idx,bool cpu_access)tests/intel/xe_evict.c +0
-3@@ -448,9 +448,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 v3 3/5] lib/igt_sizes: Add common SZ_* header
Quoted 5 lines · Kamil Konieczny
Hi Zbigniew,
Quoted 1 line · Zbigniew Kempczyński
We're often use SZ_.* macros so add this globally to IGTs.
--- ^^^
imho: "We often use"
Ack.
Quoted 49 lines
Quoted 34 lines
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
-0lib/igt_sizes.h line 3
Quoted 3 lines
lib/igt_sizes.h new file +3
-0@@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT +/* +* Taken and adopted to IGT from kernel include/linux/sizes.h We useally add here Copyright, +cc Petri
Quoted 9 lines
lib/igt_sizes.h new file +9
-0+*/ +#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
Quoted 8 lines
lib/igt_sizes.h line 17
Quoted 5 lines
lib/igt_sizes.h new file +5
-0+#define SZ_32 0x00000020 +#define SZ_64 0x00000040 +#define SZ_128 0x00000080 +#define SZ_256 0x00000100 +#define SZ_512 0x00000200Do we really need this 1...512? They may be used without
SZ_? We do not use these anywhere?
That was added as verbatim copy for completion, but we're not using this anywhere.
Quoted 2 lines
Below ones starting with 1K are ok.
Ok, I'll truncate this to 1K+.
Quoted 63 lines
Quoted 63 lines
lib/igt_sizes.h new file +27
-0+ +#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__ */ 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 5 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)---------- ^^^^^^
This is not the same... why not change it to 16_PAGES? Also this is ULL, after you change it will become int.
SZ_64K is not used in this test so its type doesn't matter.
Quoted 2 lines
Rest looks ok.
I'll truncate, add copyright and respin.
Thanks for the review.
--
Zbigniew
Quoted 49 lines
Regards,
KamilQuoted 45 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)static void fill_unallocated (int fd,struct drm_i915_query_item *item,int idx,bool cpu_access)tests/intel/xe_evict.c +0
-3@@ -448,9 +448,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 v3 4/5 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)
v3:
- Address review comments (Matt)
--- tests/intel/xe_evict_ccs.c | 520 +++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 2 files changed, 521 insertions(+) create mode 100644 tests/intel/xe_evict_ccs.c
tests/intel/xe_evict_ccs.c new file +520 -0
@@ -0,0 +1,520 @@ +// 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,visible_vram_memory (fd,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 ("[%8d] Obj size: %ldKiB (%ldMiB) <w: %d, h: %d>\n" , +getpid (), 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 ), + 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_DEFAULT ,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 ) +getpid ()); +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_visible_vram_size (fd,0 ) /SZ_1M ; + config->total_mb =xe_vram_available (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 v3 4/5] tests/xe_evict_ccs: Add evict ccs test
Quoted 526 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)
v3:
- Address review comments (Matt)Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Matthew Auld <[email protected]>--- tests/intel/xe_evict_ccs.c | 520 +++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 2 files changed, 521 insertions(+) create mode 100644 tests/intel/xe_evict_ccs.ctests/intel/xe_evict_ccs.c new file +495
-0@@ -0,0 +1,520 @@ +// 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,visible_vram_memory (fd,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 ("[%8d] Obj size: %ldKiB (%ldMiB) <w: %d, h: %d>\n" , +getpid (), 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 ), + 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_DEFAULT ,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 ) +getpid ()); +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_visible_vram_size (fd,0 ) /SZ_1M ; + config->total_mb =xe_vram_available (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;
tests/intel/xe_evict_ccs.c line 505
Quoted 10 lines
tests/intel/xe_evict_ccs.c new file +10
-0+ + 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 ;
What is the purpose of this loop? Maybe I'm blind.
Otherwise,
Quoted 30 lines
tests/intel/xe_evict_ccs.c new file +15
-0+ } + +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 v3 4/5] tests/xe_evict_ccs: Add evict ccs test
Quoted 532 lines · Matthew Auld
Quoted 530 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)
v3:
- Address review comments (Matt)Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Matthew Auld <[email protected]>--- tests/intel/xe_evict_ccs.c | 520 +++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 2 files changed, 521 insertions(+) create mode 100644 tests/intel/xe_evict_ccs.ctests/intel/xe_evict_ccs.c new file +499
-0@@ -0,0 +1,520 @@ +// 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,visible_vram_memory (fd,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 ("[%8d] Obj size: %ldKiB (%ldMiB) <w: %d, h: %d>\n" , +getpid (), 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 ), + 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_DEFAULT ,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 ) +getpid ()); +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_visible_vram_size (fd,0 ) /SZ_1M ; + config->total_mb =xe_vram_available (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));
Quoted 8 lines
tests/intel/xe_evict_ccs.c line 505
Quoted 6 lines
tests/intel/xe_evict_ccs.c new file +6
-0+ 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 ;What is the purpose of this loop? Maybe I'm blind.
You're not blind, I am. Copy-paste issue.
Thanks for the review, I'll pick r-b removing above unnecessary loop.
--
Zbigniew
Quoted 34 lines
Otherwise,
Reviewed-by Matthew Auld <[email protected]>Quoted 30 lines
tests/intel/xe_evict_ccs.c new file +15
-0+ } + +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 v3 5/5 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
Re: [igt-dev] [PATCH i-g-t v3 5/5] intel-ci/xe-fast-feedback: Add two xe_evict_ccs subtests for Xe run
Quoted 7 lines · Zbigniew Kempczyński
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 <[email protected]>Cc Katarzyna Dec <[email protected]>
Patchwork
CI[igt-dev] ✗ Fi.CI.BAT: failure for Add flat-ccs tests (rev3)
In reply to Zbigniew Kempczyński== Series Details ==
== Series Details ==
Series: Add flat-ccs tests (rev3)
URL : https://patchwork.freedesktop.org/series/124626/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_13777 -> IGTPW_10032
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_10032 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes
introduced in IGTPW_10032, 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_10032/index.html
Participating hosts (36 -> 36)
------------------------------
Additional (2): fi-skl-guc bat-kbl-2
Missing (2): fi-hsw-4770 fi-bsw-n3050
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_10032:
### IGT changes ###
#### Possible regressions ####
* igt@i915_selftest@live@late_gt_pm:
- bat-mtlp-6: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13777/bat-mtlp-6/igt@i915_selftest@live@late_gt_pm.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-mtlp-6/igt@i915_selftest@live@late_gt_pm.html
Known issues
------------
Here are the changes found in IGTPW_10032 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@debugfs_test@basic-hwmon:
- bat-jsl-1: NOTRUN -> [SKIP][3] ([i915#9318])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-jsl-1/igt@[email protected]
* igt@fbdev@info:
- bat-kbl-2: NOTRUN -> [SKIP][4] ([fdo#109271] / [i915#1849])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-kbl-2/igt@[email protected]
* igt@gem_huc_copy@huc-copy:
- bat-jsl-1: NOTRUN -> [SKIP][5] ([i915#2190])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-jsl-1/igt@[email protected]
* igt@gem_lmem_swapping@basic:
- fi-skl-guc: NOTRUN -> [SKIP][6] ([fdo#109271] / [i915#4613]) +3 other tests skip
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/fi-skl-guc/igt@[email protected]
* igt@gem_lmem_swapping@parallel-random-engines:
- bat-kbl-2: NOTRUN -> [SKIP][7] ([fdo#109271]) +39 other tests skip
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-kbl-2/igt@[email protected]
* igt@gem_lmem_swapping@verify-random:
- bat-jsl-1: NOTRUN -> [SKIP][8] ([i915#4613]) +3 other tests skip
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-jsl-1/igt@[email protected]
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- bat-jsl-1: NOTRUN -> [SKIP][9] ([i915#4103]) +1 other test skip
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-jsl-1/igt@[email protected]
* igt@kms_dsc@dsc-basic:
- fi-skl-guc: NOTRUN -> [SKIP][10] ([fdo#109271]) +12 other tests skip
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/fi-skl-guc/igt@[email protected]
- bat-jsl-1: NOTRUN -> [SKIP][11] ([i915#3555]) +1 other test skip
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-jsl-1/igt@[email protected]
* igt@kms_force_connector_basic@force-load-detect:
- bat-jsl-1: NOTRUN -> [SKIP][12] ([fdo#109285])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-jsl-1/igt@[email protected]
* igt@kms_hdmi_inject@inject-audio:
- fi-skl-guc: NOTRUN -> [FAIL][13] ([IGT#3])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/fi-skl-guc/igt@[email protected]
* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-d-edp-1:
- bat-rplp-1: [PASS][14] -> [ABORT][15] ([i915#8668])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13777/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]
* igt@kms_pipe_crc_basic@suspend-read-crc:
- bat-dg2-8: NOTRUN -> [SKIP][16] ([i915#1845] / [i915#9197])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-dg2-8/igt@[email protected]
#### Possible fixes ####
* igt@gem_exec_suspend@basic-s0@lmem0:
- bat-dg2-8: [INCOMPLETE][17] ([i915#9275]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13777/bat-dg2-8/igt@gem_exec_suspend@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/bat-dg2-8/igt@gem_exec_suspend@[email protected]
* igt@i915_selftest@live@gt_heartbeat:
- fi-kbl-soraka: [DMESG-FAIL][19] ([i915#5334] / [i915#7872]) -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13777/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.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#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#7872]: https://gitlab.freedesktop.org/drm/intel/issues/7872
[i915#7952]: https://gitlab.freedesktop.org/drm/intel/issues/7952
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668
[i915#9197]: https://gitlab.freedesktop.org/drm/intel/issues/9197
[i915#9275]: https://gitlab.freedesktop.org/drm/intel/issues/9275
[i915#9318]: https://gitlab.freedesktop.org/drm/intel/issues/9318
Build changes
-------------
* CI: CI-20190529 -> None
* IGT: IGT_7549 -> IGTPW_10032
CI-20190529: 20190529
CI_DRM_13777: 1b4fd688d213556268c50f853746c94c9a0cfee7 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_10032: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/index.html
IGT_7549: bc3314b187318a4238c6fae583770b389afa83c3 @ 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_10032/index.html
Patchwork
CI[igt-dev] ✓ CI.xeBAT: success for Add flat-ccs tests (rev3)
In reply to Zbigniew Kempczyński== Series Details ==
== Series Details ==
Series: Add flat-ccs tests (rev3)
URL : https://patchwork.freedesktop.org/series/124626/
State : success
== Summary ==
CI Bug Log - changes from XEIGT_7549_BAT -> XEIGTPW_10032_BAT
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Participating hosts (4 -> 3)
------------------------------
Missing (1): bat-pvc-2
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in XEIGTPW_10032_BAT:
### IGT changes ###
#### Possible regressions ####
* {igt@xe_evict_ccs@evict-ccs-overcommit-parallel-nofree-samefd} (NEW):
- bat-dg2-oem2: NOTRUN -> [FAIL][1]
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10032/bat-dg2-oem2/igt@[email protected]
- bat-adlp-7: NOTRUN -> [SKIP][2] +1 other test skip
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10032/bat-adlp-7/igt@[email protected]
New tests
---------
New tests have been introduced between XEIGT_7549_BAT and XEIGTPW_10032_BAT:
### New IGT tests (2) ###
* igt@xe_evict_ccs@evict-ccs-overcommit-parallel-nofree-samefd:
- Statuses : 1 fail(s) 1 pass(s) 1 skip(s)
- Exec time: [0.0] s
* igt@xe_evict_ccs@evict-ccs-overcommit-simple:
- Statuses : 2 pass(s) 1 skip(s)
- Exec time: [0.0] s
Known issues
------------
Here are the changes found in XEIGTPW_10032_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_7549 -> IGTPW_10032
IGTPW_10032: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10032/index.html
IGT_7549: bc3314b187318a4238c6fae583770b389afa83c3 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
xe-442-a0a80950176b39dbc76f8faa92fddf6caaa06191: a0a80950176b39dbc76f8faa92fddf6caaa06191
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10032/index.html