Skip to content

amd_smi: Update CHECK_SNPRINTF to allow for truncation of descriptions#577

Open
Treece-Burgess wants to merge 1 commit intoicl-utk-edu:masterfrom
Treece-Burgess:03-12-2026-amd-smi-descr-truncation
Open

amd_smi: Update CHECK_SNPRINTF to allow for truncation of descriptions#577
Treece-Burgess wants to merge 1 commit intoicl-utk-edu:masterfrom
Treece-Burgess:03-12-2026-amd-smi-descr-truncation

Conversation

@Treece-Burgess
Copy link
Copy Markdown
Contributor

Pull Request Description

Currently on Instinct at Oregon (1 * MI100), the amd_smi component will be disabled. This is caused by the driver_version_hash description being larger than descr[PAPI_MAX_STR_LEN]. On Instinct the driver_version_hash is:

Linuxversion5.15.0-87-generic(buildd@lcy02-amd64-011)(gcc(Ubuntu11.4.0-1ubuntu1~22.04)11.4.0,GNUld(GNUBinutilsforUbuntu)2.38)#97-UbuntuSMPMonOct221:09:21UTC2023

One way to resolve this issue is by changing descr[PAPI_MAX_STR_LEN] to descr[PAPI_HUGE_STR_LEN]. As the long_descr can take up to PAPI_HUGE_STR_LEN. This has been done in the PR. However, this does not account for cases where the vendor descriptions could be larger than PAPI_HUGE_STR_LEN.

To account for this possibility CHECK_SNPRINTF has been updated to take a truncation argument. This argument can be either:

  1. doNotAllowTruncation - Meaning if we cannot fully write the string to the buffer, we return PAPI_EBUF.
    • Event names fall under this option.
  2. allowTruncation - Meaning if we cannot fully write the string to the buffer, we do not return PAPI_EBUF and proceed on.
    • Event descriptions and the error_string variable fall under this option.

In both cases a SUBDBG message will output.

Testing

Testing was done on Instinct at Oregon with 1 * MI100 and ROCm 7.2.0, the results are:

  • PAPI build: ✅
  • PAPI utilities*: ✅
  • Component tests**: ✅

* - papi_component_avail, papi_native_avail, papi_command_line
** - amdsmi_energy_monotonic fails, but this does not appear to be due to this PR and I lack the permissions to run amdsmi_set_test.c

Author Checklist

  • Description
    Why this PR exists. Reference all relevant information, including background, issues, test failures, etc
  • Commits
    Commits are self contained and only do one thing
    Commits have a header of the form: module: short description
    Commits have a body (whenever relevant) containing a detailed description of the addressed problem and its solution
  • Tests
    The PR needs to pass all the tests

@Treece-Burgess Treece-Burgess added component-amd_smi PRs and Issues related to the amd_smi component status-ready-for-review PR is ready to be reviewed type-bug Issues discussing bugs or PRs fixing bugs labels Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component-amd_smi PRs and Issues related to the amd_smi component status-ready-for-review PR is ready to be reviewed type-bug Issues discussing bugs or PRs fixing bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant