From: Felix Kuehling <felix.kuehling@amd.com>
To: amd-gfx@lists.freedesktop.org, "Russell, Kent" <Kent.Russell@amd.com>
Cc: Luben Tuikov <luben.tuikov@amd.com>, Mukul Joshi <Mukul.Joshi@amd.com>
Subject: Re: [PATCH 1/3] drm/amdgpu: Warn when bad pages approaches 90% threshold
Date: Wed, 20 Oct 2021 18:31:52 -0400 [thread overview]
Message-ID: <b61505ea-d736-8efc-5edf-b8d08f5bd60b@amd.com> (raw)
In-Reply-To: <50882392-beb7-b7bc-01c9-04945ffdec00@amd.com>
On 2021-10-20 5:50 p.m., Felix Kuehling wrote:
> On 2021-10-20 12:35 p.m., Kent Russell wrote:
>> Currently dmesg doesn't warn when the number of bad pages approaches the
>> threshold for page retirement. WARN when the number of bad pages
>> is at 90% or greater for easier checks and planning, instead of waiting
>> until the GPU is full of bad pages
>>
>> Cc: Luben Tuikov <luben.tuikov@amd.com>
>> Cc: Mukul Joshi <Mukul.Joshi@amd.com>
>> Signed-off-by: Kent Russell <kent.russell@amd.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 17 +++++++++++++++++
>> 1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
>> index f4c05ff4b26c..1ede0f0d6f55 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
>> @@ -1071,12 +1071,29 @@ int amdgpu_ras_eeprom_init(struct
>> amdgpu_ras_eeprom_control *control,
>> control->ras_fri = RAS_OFFSET_TO_INDEX(control,
>> hdr->first_rec_offset);
>> if (hdr->header == RAS_TABLE_HDR_VAL) {
>> + int threshold = 0;
>
> ras->bad_page_cnt_threshold is uint32_t. I'd recommend using the same
> type. Also add an empty line after the declaration to avoid a
> checkpatch warning.
>
>
>> DRM_DEBUG_DRIVER("Found existing EEPROM table with %d
>> records",
>> control->ras_num_recs);
>> res = __verify_ras_table_checksum(control);
>> if (res)
>> DRM_ERROR("RAS table incorrect checksum or error:%d\n",
>> res);
>> +
>> + /* threshold = 0 means that page retirement is disabled, while
>> + * threshold = -1 means default behaviour
>> + */
>> + if (amdgpu_bad_page_threshold == -1)
>> + threshold = ras->bad_page_cnt_threshold;
>> + else if (amdgpu_bad_page_threshold > 0)
>> + threshold = amdgpu_bad_page_threshold;
>> +
>> + /* Since multiplcation is transitive, a = 9b/10 is the same
>> + * as 10a = 9b. Use this for our 90% limit to avoid rounding
>> + */
>> + if (threshold > 0 && ((control->ras_num_recs * 10) >=
>> (threshold * 9)))
>
> Not sure how big these values can get, but you may need to cast to
> (uint64_t) before the multiplications to avoid overflows.
> Alternatively you could use (control->ras_num_recs / 9 >= threshold /
> 10). It'll round, but never overflow.
Ignore this comment. If you follow Luben's recommendation to check
ras->bad_page_cnt_threshold instead of the raw module parameter, the
limit is small enough that multiplication will never overflow.
Regards,
Felix
>
>
>> + DRM_WARN("RAS records:%u exceeds 90%% of threshold:%d",
>
> Nitpick: I'd add space after the two colons for readability. The
> threshold should use %u if you make it uint32_t. This can never be
> negative.
>
> Regards,
> Felix
>
>
>> + control->ras_num_recs,
>> + threshold);
>> } else if (hdr->header == RAS_TABLE_HDR_BAD &&
>> amdgpu_bad_page_threshold != 0) {
>> res = __verify_ras_table_checksum(control);
next prev parent reply other threads:[~2021-10-20 22:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-20 16:35 [PATCH 1/3] drm/amdgpu: Warn when bad pages approaches 90% threshold Kent Russell
2021-10-20 16:35 ` [PATCH 2/3] drm/amdgpu: Add kernel parameter support for ignoring bad page threshold Kent Russell
2021-10-20 16:35 ` [PATCH 3/3] drm/amdgpu: Implement bad_page_threshold = -2 case Kent Russell
2021-10-20 21:54 ` Felix Kuehling
2021-10-20 22:01 ` Luben Tuikov
2021-10-21 13:57 ` Russell, Kent
2021-10-21 5:24 ` Lazar, Lijo
2021-10-21 13:56 ` Russell, Kent
2021-10-22 11:26 ` Lazar, Lijo
2021-10-20 21:47 ` [PATCH 1/3] drm/amdgpu: Warn when bad pages approaches 90% threshold Luben Tuikov
2021-10-21 14:04 ` Russell, Kent
2021-10-20 21:50 ` Felix Kuehling
2021-10-20 22:09 ` Luben Tuikov
2021-10-20 22:31 ` Felix Kuehling [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-10-21 17:26 Kent Russell
2021-10-21 17:40 ` Luben Tuikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b61505ea-d736-8efc-5edf-b8d08f5bd60b@amd.com \
--to=felix.kuehling@amd.com \
--cc=Kent.Russell@amd.com \
--cc=Mukul.Joshi@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=luben.tuikov@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox