[Mesa-dev] [PATCH 2/2] gallium/radeon: pipe AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS into gallium HUD
Samuel Pitoiset
samuel.pitoiset at gmail.com
Wed May 17 19:19:47 UTC 2017
On 05/17/2017 09:15 PM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/gallium/drivers/radeon/r600_query.c | 8 ++++++--
> src/gallium/drivers/radeon/r600_query.h | 1 +
> src/gallium/drivers/radeon/radeon_winsys.h | 1 +
> src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 7 +++++++
> src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 1 +
> 5 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c
> index 0d960bc..7edbb15 100644
> --- a/src/gallium/drivers/radeon/r600_query.c
> +++ b/src/gallium/drivers/radeon/r600_query.c
> @@ -66,20 +66,21 @@ static enum radeon_value_id winsys_id_from_type(unsigned type)
> case R600_QUERY_REQUESTED_VRAM: return RADEON_REQUESTED_VRAM_MEMORY;
> case R600_QUERY_REQUESTED_GTT: return RADEON_REQUESTED_GTT_MEMORY;
> case R600_QUERY_MAPPED_VRAM: return RADEON_MAPPED_VRAM;
> case R600_QUERY_MAPPED_GTT: return RADEON_MAPPED_GTT;
> case R600_QUERY_BUFFER_WAIT_TIME: return RADEON_BUFFER_WAIT_TIME_NS;
> case R600_QUERY_NUM_MAPPED_BUFFERS: return RADEON_NUM_MAPPED_BUFFERS;
> case R600_QUERY_NUM_GFX_IBS: return RADEON_NUM_GFX_IBS;
> case R600_QUERY_NUM_SDMA_IBS: return RADEON_NUM_SDMA_IBS;
> case R600_QUERY_NUM_BYTES_MOVED: return RADEON_NUM_BYTES_MOVED;
> case R600_QUERY_NUM_EVICTIONS: return RADEON_NUM_EVICTIONS;
> + case R600_QUERY_NUM_VRAM_CPU_PAGE_FAULTS: return RADEON_NUM_VRAM_CPU_PAGE_FAULTS;
> case R600_QUERY_VRAM_USAGE: return RADEON_VRAM_USAGE;
> case R600_QUERY_VRAM_VIS_USAGE: return RADEON_VRAM_VIS_USAGE;
> case R600_QUERY_GTT_USAGE: return RADEON_GTT_USAGE;
> case R600_QUERY_GPU_TEMPERATURE: return RADEON_GPU_TEMPERATURE;
> case R600_QUERY_CURRENT_GPU_SCLK: return RADEON_CURRENT_SCLK;
> case R600_QUERY_CURRENT_GPU_MCLK: return RADEON_CURRENT_MCLK;
> case R600_QUERY_CS_THREAD_BUSY: return RADEON_CS_THREAD_TIME;
> default: unreachable("query type does not correspond to winsys id");
> }
> }
> @@ -153,21 +154,22 @@ static bool r600_query_sw_begin(struct r600_common_context *rctx,
> case R600_QUERY_CURRENT_GPU_SCLK:
> case R600_QUERY_CURRENT_GPU_MCLK:
> case R600_QUERY_BACK_BUFFER_PS_DRAW_RATIO:
> case R600_QUERY_NUM_MAPPED_BUFFERS:
> query->begin_result = 0;
> break;
> case R600_QUERY_BUFFER_WAIT_TIME:
> case R600_QUERY_NUM_GFX_IBS:
> case R600_QUERY_NUM_SDMA_IBS:
> case R600_QUERY_NUM_BYTES_MOVED:
> - case R600_QUERY_NUM_EVICTIONS: {
> + case R600_QUERY_NUM_EVICTIONS:
> + case R600_QUERY_NUM_VRAM_CPU_PAGE_FAULTS: {
> enum radeon_value_id ws_id = winsys_id_from_type(query->b.type);
> query->begin_result = rctx->ws->query_value(rctx->ws, ws_id);
> break;
> }
> case R600_QUERY_CS_THREAD_BUSY:
> ws_id = winsys_id_from_type(query->b.type);
> query->begin_result = rctx->ws->query_value(rctx->ws, ws_id);
> query->begin_time = os_time_get_nano();
> break;
> case R600_QUERY_GALLIUM_THREAD_BUSY:
> @@ -291,21 +293,22 @@ static bool r600_query_sw_end(struct r600_common_context *rctx,
> case R600_QUERY_VRAM_VIS_USAGE:
> case R600_QUERY_GTT_USAGE:
> case R600_QUERY_GPU_TEMPERATURE:
> case R600_QUERY_CURRENT_GPU_SCLK:
> case R600_QUERY_CURRENT_GPU_MCLK:
> case R600_QUERY_BUFFER_WAIT_TIME:
> case R600_QUERY_NUM_MAPPED_BUFFERS:
> case R600_QUERY_NUM_GFX_IBS:
> case R600_QUERY_NUM_SDMA_IBS:
> case R600_QUERY_NUM_BYTES_MOVED:
> - case R600_QUERY_NUM_EVICTIONS: {
> + case R600_QUERY_NUM_EVICTIONS:
> + case R600_QUERY_NUM_VRAM_CPU_PAGE_FAULTS: {
> enum radeon_value_id ws_id = winsys_id_from_type(query->b.type);
> query->end_result = rctx->ws->query_value(rctx->ws, ws_id);
> break;
> }
> case R600_QUERY_CS_THREAD_BUSY:
> ws_id = winsys_id_from_type(query->b.type);
> query->end_result = rctx->ws->query_value(rctx->ws, ws_id);
> query->end_time = os_time_get_nano();
> break;
> case R600_QUERY_GALLIUM_THREAD_BUSY:
> @@ -1839,20 +1842,21 @@ static struct pipe_driver_query_info r600_driver_query_list[] = {
> X("requested-VRAM", REQUESTED_VRAM, BYTES, AVERAGE),
> X("requested-GTT", REQUESTED_GTT, BYTES, AVERAGE),
> X("mapped-VRAM", MAPPED_VRAM, BYTES, AVERAGE),
> X("mapped-GTT", MAPPED_GTT, BYTES, AVERAGE),
> X("buffer-wait-time", BUFFER_WAIT_TIME, MICROSECONDS, CUMULATIVE),
> X("num-mapped-buffers", NUM_MAPPED_BUFFERS, UINT64, AVERAGE),
> X("num-GFX-IBs", NUM_GFX_IBS, UINT64, AVERAGE),
> X("num-SDMA-IBs", NUM_SDMA_IBS, UINT64, AVERAGE),
> X("num-bytes-moved", NUM_BYTES_MOVED, BYTES, CUMULATIVE),
> X("num-evictions", NUM_EVICTIONS, UINT64, CUMULATIVE),
> + X("TTM-num-VRAM-CPU-page-faults", NUM_VRAM_CPU_PAGE_FAULTS, UINT64, CUMULATIVE),
VRAM-CPU-page-faults is enough, no?
Except this, series is:
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> X("VRAM-usage", VRAM_USAGE, BYTES, AVERAGE),
> X("VRAM-vis-usage", VRAM_VIS_USAGE, BYTES, AVERAGE),
> X("GTT-usage", GTT_USAGE, BYTES, AVERAGE),
> X("back-buffer-ps-draw-ratio", BACK_BUFFER_PS_DRAW_RATIO, UINT64, AVERAGE),
>
> /* GPIN queries are for the benefit of old versions of GPUPerfStudio,
> * which use it as a fallback path to detect the GPU type.
> *
> * Note: The names of these queries are significant for GPUPerfStudio
> * (and possibly their order as well). */
> diff --git a/src/gallium/drivers/radeon/r600_query.h b/src/gallium/drivers/radeon/r600_query.h
> index 9017fdf..ed607ec 100644
> --- a/src/gallium/drivers/radeon/r600_query.h
> +++ b/src/gallium/drivers/radeon/r600_query.h
> @@ -62,20 +62,21 @@ enum {
> R600_QUERY_REQUESTED_VRAM,
> R600_QUERY_REQUESTED_GTT,
> R600_QUERY_MAPPED_VRAM,
> R600_QUERY_MAPPED_GTT,
> R600_QUERY_BUFFER_WAIT_TIME,
> R600_QUERY_NUM_MAPPED_BUFFERS,
> R600_QUERY_NUM_GFX_IBS,
> R600_QUERY_NUM_SDMA_IBS,
> R600_QUERY_NUM_BYTES_MOVED,
> R600_QUERY_NUM_EVICTIONS,
> + R600_QUERY_NUM_VRAM_CPU_PAGE_FAULTS,
> R600_QUERY_VRAM_USAGE,
> R600_QUERY_VRAM_VIS_USAGE,
> R600_QUERY_GTT_USAGE,
> R600_QUERY_GPU_TEMPERATURE,
> R600_QUERY_CURRENT_GPU_SCLK,
> R600_QUERY_CURRENT_GPU_MCLK,
> R600_QUERY_GPU_LOAD,
> R600_QUERY_GPU_SHADERS_BUSY,
> R600_QUERY_GPU_TA_BUSY,
> R600_QUERY_GPU_GDS_BUSY,
> diff --git a/src/gallium/drivers/radeon/radeon_winsys.h b/src/gallium/drivers/radeon/radeon_winsys.h
> index 2e287c6..c29ff01 100644
> --- a/src/gallium/drivers/radeon/radeon_winsys.h
> +++ b/src/gallium/drivers/radeon/radeon_winsys.h
> @@ -83,20 +83,21 @@ enum radeon_value_id {
> RADEON_REQUESTED_GTT_MEMORY,
> RADEON_MAPPED_VRAM,
> RADEON_MAPPED_GTT,
> RADEON_BUFFER_WAIT_TIME_NS,
> RADEON_NUM_MAPPED_BUFFERS,
> RADEON_TIMESTAMP,
> RADEON_NUM_GFX_IBS,
> RADEON_NUM_SDMA_IBS,
> RADEON_NUM_BYTES_MOVED,
> RADEON_NUM_EVICTIONS,
> + RADEON_NUM_VRAM_CPU_PAGE_FAULTS,
> RADEON_VRAM_USAGE,
> RADEON_VRAM_VIS_USAGE,
> RADEON_GTT_USAGE,
> RADEON_GPU_TEMPERATURE, /* DRM 2.42.0 */
> RADEON_CURRENT_SCLK,
> RADEON_CURRENT_MCLK,
> RADEON_GPU_RESET_COUNTER, /* DRM 2.43.0 */
> RADEON_CS_THREAD_TIME,
> };
>
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> index 70319db..60047c0 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> @@ -36,20 +36,24 @@
>
> #include "util/u_hash_table.h"
> #include <amdgpu_drm.h>
> #include <xf86drm.h>
> #include <stdio.h>
> #include <sys/stat.h>
> #include "amd/common/amdgpu_id.h"
> #include "amd/common/sid.h"
> #include "amd/common/gfx9d.h"
>
> +#ifndef AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS
> +#define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E
> +#endif
> +
> #define CIK_TILE_MODE_COLOR_2D 14
>
> #define CIK__GB_TILE_MODE__PIPE_CONFIG(x) (((x) >> 6) & 0x1f)
> #define CIK__PIPE_CONFIG__ADDR_SURF_P2 0
> #define CIK__PIPE_CONFIG__ADDR_SURF_P4_8x16 4
> #define CIK__PIPE_CONFIG__ADDR_SURF_P4_16x16 5
> #define CIK__PIPE_CONFIG__ADDR_SURF_P4_16x32 6
> #define CIK__PIPE_CONFIG__ADDR_SURF_P4_32x32 7
> #define CIK__PIPE_CONFIG__ADDR_SURF_P8_16x16_8x16 8
> #define CIK__PIPE_CONFIG__ADDR_SURF_P8_16x32_8x16 9
> @@ -458,20 +462,23 @@ static uint64_t amdgpu_query_value(struct radeon_winsys *rws,
> case RADEON_NUM_GFX_IBS:
> return ws->num_gfx_IBs;
> case RADEON_NUM_SDMA_IBS:
> return ws->num_sdma_IBs;
> case RADEON_NUM_BYTES_MOVED:
> amdgpu_query_info(ws->dev, AMDGPU_INFO_NUM_BYTES_MOVED, 8, &retval);
> return retval;
> case RADEON_NUM_EVICTIONS:
> amdgpu_query_info(ws->dev, AMDGPU_INFO_NUM_EVICTIONS, 8, &retval);
> return retval;
> + case RADEON_NUM_VRAM_CPU_PAGE_FAULTS:
> + amdgpu_query_info(ws->dev, AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS, 8, &retval);
> + return retval;
> case RADEON_VRAM_USAGE:
> amdgpu_query_heap_info(ws->dev, AMDGPU_GEM_DOMAIN_VRAM, 0, &heap);
> return heap.heap_usage;
> case RADEON_VRAM_VIS_USAGE:
> amdgpu_query_heap_info(ws->dev, AMDGPU_GEM_DOMAIN_VRAM,
> AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, &heap);
> return heap.heap_usage;
> case RADEON_GTT_USAGE:
> amdgpu_query_heap_info(ws->dev, AMDGPU_GEM_DOMAIN_GTT, 0, &heap);
> return heap.heap_usage;
> diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
> index 2e7bfe9..46adc53 100644
> --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
> +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
> @@ -620,20 +620,21 @@ static uint64_t radeon_query_value(struct radeon_winsys *rws,
> return retval;
> case RADEON_NUM_GFX_IBS:
> return ws->num_gfx_IBs;
> case RADEON_NUM_SDMA_IBS:
> return ws->num_sdma_IBs;
> case RADEON_NUM_BYTES_MOVED:
> radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_BYTES_MOVED,
> "num-bytes-moved", (uint32_t*)&retval);
> return retval;
> case RADEON_NUM_EVICTIONS:
> + case RADEON_NUM_VRAM_CPU_PAGE_FAULTS:
> case RADEON_VRAM_VIS_USAGE:
> return 0; /* unimplemented */
> case RADEON_VRAM_USAGE:
> radeon_get_drm_value(ws->fd, RADEON_INFO_VRAM_USAGE,
> "vram-usage", (uint32_t*)&retval);
> return retval;
> case RADEON_GTT_USAGE:
> radeon_get_drm_value(ws->fd, RADEON_INFO_GTT_USAGE,
> "gtt-usage", (uint32_t*)&retval);
> return retval;
>
More information about the mesa-dev
mailing list