Fix the slowdown for Vega 20 server boards
Subsystems (2)
cover Fix the slowdown for Vega 20 server boards
This patch fixes the interactive--to the point of unusability--slowdown when RAS is enabled on Vega 20 server boards--which support full RAS.
Luben Tuikov (1):
drm/amdgpu: Poll of RAS errors asynchronously
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 32 +++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 61 +++++++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 8 ++-- 5 files changed, 85 insertions(+), 26 deletions(-)
Signature · 6 lines
2.31.0.97.g1424303384 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 1/1 drm/amdgpu: Poll of RAS errors asynchronously
When using Vega 20 with RAS support and RAS is enabled, the system interactivity is extremely slow, to the point of being unusable. After debugging, it was determined that this is due to the polling loop performed for AMDGPU_CTX_OP_QUERY_STATE2 under amdgpu_ctx_ioctl(), which seems to be executed on every ioctl from X/Mesa.
The latter seems to call amdgpu_ctx_query2() which calls amdgpu_ras_query_error_count() twice, once for each of ue_count and ce_count. This is unnecessarily wasteful since amdgpu_ras_query_error_count() calculates both, but with the current interface it returns one or the other, depending on its Boolean input, when it can in fact return both, in a single invocation, if it had a better interface.
Further down, the query_ras_error_count() callback is called, which could be quite a large polling loop, and very time consuming. For instance, gfx_v9_0_query_ras_error_count() is at least O(n^3). A similar situation is seen with umc_v6_1_query_ras_error_count().
This commit implements asynchronous RAS error count polling to that of the ioctl. A kernel thread polls the RAS error counters once in a while. The ioctl reads the values asynchronously. The poll frequency is a module parameter, with range [500, 10000] milliseconds, default 3000.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 32 +++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 61 +++++++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 8 ++-- 5 files changed, 85 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -196,6 +196,7 @@ extern struct amdgpu_mgpu_info mgpu_info;extern int amdgpu_ras_enable;extern uint amdgpu_ras_mask;extern int amdgpu_bad_page_threshold; +extern uint amdgpu_ras_thread_poll_ms;extern struct amdgpu_watchdog_timer amdgpu_watchdog_timer;extern int amdgpu_async_gfx_ring;extern int amdgpu_mcbp;
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +17 -15
@@ -332,12 +332,12 @@ static int amdgpu_ctx_query(struct amdgpu_device *adev, }static int amdgpu_ctx_query2 (struct amdgpu_device *adev, -struct amdgpu_fpriv *fpriv,uint32_t id, -union drm_amdgpu_ctx_out *out) +struct amdgpu_fpriv *fpriv,uint32_t id, +union drm_amdgpu_ctx_out *out) { +struct amdgpu_ras *con =amdgpu_ras_get_context (adev);struct amdgpu_ctx *ctx;struct amdgpu_ctx_mgr *mgr; -unsigned long ras_counter;if (!fpriv)return -EINVAL ;
@@ -362,19 +362,21 @@ static int amdgpu_ctx_query2(struct amdgpu_device *adev,if (atomic_read (&ctx->guilty)) out->state.flags |=AMDGPU_CTX_QUERY2_FLAGS_GUILTY ; -/*query ue count*/ - ras_counter =amdgpu_ras_query_error_count (adev, false); -/*ras counter is monotonic increasing*/ -if (ras_counter != ctx->ras_counter_ue) { - out->state.flags |=AMDGPU_CTX_QUERY2_FLAGS_RAS_UE ; - ctx->ras_counter_ue = ras_counter; - } +if (con) { +int ce_count, ue_count; + + ce_count =atomic_read (&con->ras_ce_count); + ue_count =atomic_read (&con->ras_ue_count); -/*query ce count*/ - ras_counter =amdgpu_ras_query_error_count (adev, true); -if (ras_counter != ctx->ras_counter_ce) { - out->state.flags |=AMDGPU_CTX_QUERY2_FLAGS_RAS_CE ; - ctx->ras_counter_ce = ras_counter; +if (ce_count != ctx->ras_counter_ce) { + out->state.flags |=AMDGPU_CTX_QUERY2_FLAGS_RAS_CE ; + ctx->ras_counter_ce = ce_count; + } + +if (ue_count != ctx->ras_counter_ue) { + out->state.flags |=AMDGPU_CTX_QUERY2_FLAGS_RAS_UE ; + ctx->ras_counter_ue = ue_count; + } }mutex_unlock (&mgr->lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +9 -0
@@ -183,6 +183,7 @@ struct amdgpu_mgpu_info mgpu_info = {int amdgpu_ras_enable =-1 ;uint amdgpu_ras_mask =0xffffffff ;int amdgpu_bad_page_threshold =-1 ; +uint amdgpu_ras_thread_poll_ms =3000 ;struct amdgpu_watchdog_timer amdgpu_watchdog_timer = { .timeout_fatal_disable = false, .period =0x0 ,/* default to 0x0 (timeout disable) */
@@ -534,6 +535,14 @@ module_param_named(emu_mode, amdgpu_emu_mode, int, 0444);MODULE_PARM_DESC (ras_enable,"Enable RAS features on the GPU (0 = disable, 1 = enable, -1 = auto (default))" );module_param_named (ras_enable, amdgpu_ras_enable, int,0444 ); +/** +* DOC: ras_thread_poll (uint) +* Number of milliseconds between RAS poll for errors. Valid range [500,10000]. +* Default: 3000. +*/ +MODULE_PARM_DESC (ras_thread_poll,"Number of milliseconds between RAS poll for errors. Valid range [500,10000]. Default: 3000." ); +module_param_named (ras_thread_poll, amdgpu_ras_thread_poll_ms, uint,0444 ); +/** * DOC: ras_mask (uint) * Mask of RAS features to enable (default 0xffffffff), only valid when ras_enable == 1
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +53 -8
93 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +5 -3
@@ -340,6 +340,11 @@ struct amdgpu_ras {/* disable ras error count harvest in recovery */ bool disable_ras_err_cnt_harvest; + +struct task_struct *ras_thread; +unsigned int ras_thread_poll_ms; +atomic_t ras_ue_count; +atomic_t ras_ce_count; };struct ras_fs_data {
@@ -485,9 +490,6 @@ int amdgpu_ras_request_reset_on_boot(struct amdgpu_device *adev,void amdgpu_ras_resume (struct amdgpu_device *adev);void amdgpu_ras_suspend (struct amdgpu_device *adev); -unsigned long amdgpu_ras_query_error_count (struct amdgpu_device *adev, -bool is_ce); -/* error handling functions */ int amdgpu_ras_add_bad_pages (struct amdgpu_device *adev,struct eeprom_table_record *bps,int pages);
Signature · 6 lines
2.31.0.97.g1424303384 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
Patch is:
________________________________
From: Tuikov, Luben <[email protected]>
Sent: Thursday, May 6, 2021 8:10 AM
To: [email protected] <[email protected]>
Cc: Tuikov, Luben <[email protected]>; Deucher, Alexander <[email protected]>; Clements, John <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH 0/1] Fix the slowdown for Vega 20 server boards
This patch fixes the interactive--to the point of unusability--slowdown when RAS is enabled on Vega 20 server boards--which support full RAS.
Luben Tuikov (1):
drm/amdgpu: Poll of RAS errors asynchronously
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 32 +++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 61 +++++++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 8 ++-- 5 files changed, 85 insertions(+), 26 deletions(-)
--
2.31.0.97.g1424303384
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx