Skip to content

plugins/amdgpu: Cleanup env variable handling#3014

Merged
avagin merged 1 commit into
checkpoint-restore:criu-devfrom
tursulin:cleanup-envvar-handling
May 19, 2026
Merged

plugins/amdgpu: Cleanup env variable handling#3014
avagin merged 1 commit into
checkpoint-restore:criu-devfrom
tursulin:cleanup-envvar-handling

Conversation

@tursulin
Copy link
Copy Markdown

@tursulin tursulin commented May 4, 2026

This is not saving a lot of lines, just two, but perhaps the pattern of:

  kfd_fw_version_check = getenv_bool("KFD_FW_VER_CHECK", true);

Is somewhat cleaner than:

  /* Default Values */
  kfd_fw_version_check = true;
...
  getenv_bool("KFD_FW_VER_CHECK", &kfd_fw_version_check); 

I also make the helpers static and demote parsing errors to warnings since the execution does continue.

I am locally toying with the idea of adding a new env variable to ignore gpu id hence I spotted this cleanup opportunity.

cc @fdavid-amd

It is a bit tidier to make the helpers return the value instead of passing
in the pointer, so lets make them take the default and return the overall
result, allowing the call sites to consolidate into a single line.

While at it we make the helpers static since they are not used outside the
file and demote the parsing errors to warning log messages since the
plugin does continue operating.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.22%. Comparing base (9a1453b) to head (9788da3).
⚠️ Report is 1 commits behind head on criu-dev.

Additional details and impacted files
@@             Coverage Diff              @@
##           criu-dev    #3014      +/-   ##
============================================
- Coverage     57.22%   57.22%   -0.01%     
============================================
  Files           154      154              
  Lines         40440    40441       +1     
  Branches       8863     8863              
============================================
  Hits          23142    23142              
- Misses        17034    17035       +1     
  Partials        264      264              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@avagin avagin requested a review from fdavid-amd May 6, 2026 00:00
@avagin avagin added the gpu/amd label May 6, 2026
@avagin
Copy link
Copy Markdown
Member

avagin commented May 6, 2026

LGTM

@avagin avagin requested a review from Copilot May 19, 2026 23:39
@avagin avagin merged commit 1961c5e into checkpoint-restore:criu-dev May 19, 2026
39 of 43 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors AMDGPU plugin environment-variable parsing helpers to return defaults directly, makes the helpers static, and adjusts log severity for invalid values so the plugin continues with defaults.

Changes:

  • Refactor getenv_bool() / getenv_size_t() to return parsed values (or defaults) instead of mutating via out-params.
  • Demote some invalid-env-value logs from errors to warnings and always log the effective parameter value.
  • Simplify amdgpu_plugin_init() by inlining defaults into the env parsing calls.

}
pr_info("param: %s:%s\n", var, *value ? "Y" : "N");

pr_info("param: %s:%u\n", var, val);
pr_info("param: %s:0x%lx\n", var, *value);

out:
pr_info("param: %s:0x%lx\n", var, val);
Comment on lines 336 to +340
if (value_str) {
size = (size_t)strtoul(value_str, &endp, 0);
val = (size_t)strtoul(value_str, &endp, 0);
if (errno || value_str == endp) {
pr_err("Ignoring invalid value for %s=%s, expecting a positive integer\n", var, value_str);
return;
goto out;
Comment on lines 338 to +340
if (errno || value_str == endp) {
pr_err("Ignoring invalid value for %s=%s, expecting a positive integer\n", var, value_str);
return;
goto out;
default:
pr_err("Ignoring invalid size suffix for %s=%s, expecting 'K'/k', 'M', or 'G'\n", var, value_str);
return;
pr_warn("Ignoring invalid size suffix for %s=%s, expecting 'K'/k', 'M', or 'G'\n", var, value_str);
@avagin
Copy link
Copy Markdown
Member

avagin commented May 20, 2026

@tursulin I have merged this pr by mistake. please review copilot comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants