winsys/amdgpu: make RADEON_ALL_BOS a debug only feature

Improves performance in SPECviewperf13 snx.
e.g.: test10 fps evolution: 235 -> 270.

Extract from "pahole radeonsi_dri.so -C amdgpu_winsys_bo", before:

struct amdgpu_winsys_bo {
	struct pb_buffer           base;                 /*     0    32 */
	union {
		struct {
			struct pb_cache_entry cache_entry; /*    32    56 */

			/* XXX last struct has 4 bytes of padding */

			/* --- cacheline 1 boundary (64 bytes) was 24 bytes ago --- */
			amdgpu_va_handle va_handle;      /*    88     8 */
			int        map_count;            /*    96     4 */
			_Bool      use_reusable_pool;    /*   100     1 */

			/* XXX 3 bytes hole, try to pack */

			struct list_head global_list_item; /*   104    16 */
			uint32_t   kms_handle;           /*   120     4 */
		} real;
		[...]
	} u;                                             /*    32    96 */
	[...]
	/* size: 200, cachelines: 4, members: 15 */
};

After:

struct amdgpu_winsys_bo {
	struct pb_buffer           base;                 /*     0    32 */
	union {
		struct {
			struct pb_cache_entry cache_entry; /*    32    56 */

			/* XXX last struct has 4 bytes of padding */

			/* --- cacheline 1 boundary (64 bytes) was 24 bytes ago --- */
			amdgpu_va_handle va_handle;      /*    88     8 */
			int        map_count;            /*    96     4 */
			_Bool      use_reusable_pool;    /*   100     1 */

			/* XXX 3 bytes hole, try to pack */

			uint32_t   kms_handle;           /*   104     4 */
		} real;                                  /*    32    80 */
	} u;                                             /*    32    80 */
	/* --- cacheline 1 boundary (64 bytes) was 48 bytes ago --- */
	[...]
	/* size: 184, cachelines: 3, members: 15 */
};

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7532>
This commit is contained in:
Pierre-Eric Pelloux-Prayer
2020-11-13 12:19:14 +01:00
committed by Marge Bot
parent 631e18d427
commit 111a1b2e1c
5 changed files with 23 additions and 5 deletions
@@ -176,12 +176,14 @@ void amdgpu_bo_destroy(struct pb_buffer *_buf)
}
assert(bo->is_user_ptr || bo->u.real.map_count == 0);
#if DEBUG
if (ws->debug_all_bos) {
simple_mtx_lock(&ws->global_bo_list_lock);
list_del(&bo->u.real.global_list_item);
ws->num_buffers--;
simple_mtx_unlock(&ws->global_bo_list_lock);
}
#endif
/* Close all KMS handles retrieved for other DRM file descriptions */
simple_mtx_lock(&ws->sws_list_lock);
@@ -431,6 +433,7 @@ static const struct pb_vtbl amdgpu_winsys_bo_vtbl = {
static void amdgpu_add_buffer_to_global_list(struct amdgpu_winsys_bo *bo)
{
#if DEBUG
struct amdgpu_winsys *ws = bo->ws;
assert(bo->bo);
@@ -441,6 +444,7 @@ static void amdgpu_add_buffer_to_global_list(struct amdgpu_winsys_bo *bo)
ws->num_buffers++;
simple_mtx_unlock(&ws->global_bo_list_lock);
}
#endif
}
static unsigned amdgpu_get_optimal_alignment(struct amdgpu_winsys *ws,
+2 -2
View File
@@ -64,9 +64,9 @@ struct amdgpu_winsys_bo {
amdgpu_va_handle va_handle;
int map_count;
bool use_reusable_pool;
#if DEBUG
struct list_head global_list_item;
#endif
uint32_t kms_handle;
} real;
struct {
+4 -1
View File
@@ -1430,6 +1430,7 @@ static void amdgpu_cs_submit_ib(void *job, int thread_index)
bool use_bo_list_create = ws->info.drm_minor < 27;
struct drm_amdgpu_bo_list_in bo_list_in;
#if DEBUG
/* Prepare the buffer list. */
if (ws->debug_all_bos) {
/* The buffer list contains all buffers. This is a slow path that
@@ -1453,7 +1454,9 @@ static void amdgpu_cs_submit_ib(void *job, int thread_index)
fprintf(stderr, "amdgpu: buffer list creation failed (%d)\n", r);
goto cleanup;
}
} else {
} else
#endif
{
if (!amdgpu_add_sparse_backing_buffers(cs)) {
fprintf(stderr, "amdgpu: amdgpu_add_sparse_backing_buffers failed\n");
r = -ENOMEM;
+10 -1
View File
@@ -47,7 +47,9 @@
static struct hash_table *dev_tab = NULL;
static simple_mtx_t dev_tab_mutex = _SIMPLE_MTX_INITIALIZER_NP;
#if DEBUG
DEBUG_GET_ONCE_BOOL_OPTION(all_bos, "RADEON_ALL_BOS", false)
#endif
static void handle_env_var_force_family(struct amdgpu_winsys *ws)
{
@@ -108,7 +110,9 @@ static bool do_winsys_init(struct amdgpu_winsys *ws,
ws->check_vm = strstr(debug_get_option("R600_DEBUG", ""), "check_vm") != NULL ||
strstr(debug_get_option("AMD_DEBUG", ""), "check_vm") != NULL;
#if DEBUG
ws->debug_all_bos = debug_get_option_all_bos();
#endif
ws->reserve_vmid = strstr(debug_get_option("R600_DEBUG", ""), "reserve_vmid") != NULL ||
strstr(debug_get_option("AMD_DEBUG", ""), "reserve_vmid") != NULL;
ws->zero_all_vram_allocs = strstr(debug_get_option("R600_DEBUG", ""), "zerovram") != NULL ||
@@ -138,7 +142,9 @@ static void do_winsys_deinit(struct amdgpu_winsys *ws)
pb_cache_deinit(&ws->bo_cache);
_mesa_hash_table_destroy(ws->bo_export_table, NULL);
simple_mtx_destroy(&ws->sws_list_lock);
#if DEBUG
simple_mtx_destroy(&ws->global_bo_list_lock);
#endif
simple_mtx_destroy(&ws->bo_export_table_lock);
ac_addrlib_destroy(ws->addrlib);
@@ -468,12 +474,15 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
/* init reference */
pipe_reference_init(&aws->reference, 1);
#if DEBUG
list_inithead(&aws->global_bo_list);
#endif
aws->bo_export_table = util_hash_table_create_ptr_keys();
(void) simple_mtx_init(&aws->sws_list_lock, mtx_plain);
#if DEBUG
(void) simple_mtx_init(&aws->global_bo_list_lock, mtx_plain);
#endif
(void) simple_mtx_init(&aws->bo_fence_lock, mtx_plain);
(void) simple_mtx_init(&aws->bo_export_table_lock, mtx_plain);
@@ -82,14 +82,16 @@ struct amdgpu_winsys {
struct ac_addrlib *addrlib;
bool check_vm;
bool debug_all_bos;
bool reserve_vmid;
bool zero_all_vram_allocs;
#if DEBUG
bool debug_all_bos;
/* List of all allocated buffers */
simple_mtx_t global_bo_list_lock;
struct list_head global_bo_list;
unsigned num_buffers;
#endif
/* Single-linked list of all structs amdgpu_screen_winsys referencing this
* struct amdgpu_winsys