Skip to content

fix(percpu): report the guest nice CPU value - #3685

Merged
nicolargo merged 1 commit into
nicolargo:developfrom
justadityaraj:fix/percpu-guest-nice
Aug 26, 2026
Merged

nicolargo merged 1 commit into
nicolargo:developfrom
justadityaraj:fix/percpu-guest-nice

Conversation

@justadityaraj

Copy link
Copy Markdown
Contributor

Problem / Context

CpuPercent._compute_percpu() checks whether psutil exposes guest_nice, but currently returns the steal value for that field. When the two counters differ, per-CPU consumers receive incorrect guest nice usage.

Fix / Changes

Read cpu_times.guest_nice for the corresponding output field. Add a focused regression test with distinct steal and guest nice values so the mapping cannot silently regress.

User impact

Linux hosts running niced guest workloads now report the correct per-CPU guest_nice percentage instead of repeating stolen CPU time.

Verification

  • uv run python -m pytest tests/test_core.py tests/test_cpu_percent.py -q — 47 passed, 6 skipped
  • uv run ruff check . — passed
  • uv run ruff format --check . — 241 files already formatted
  • uv run python -m pytest -q — 622 passed, 106 skipped; the remaining 58 failures and 15 errors were in Windows-sensitive shell, subprocess-server, web UI, memory, and performance tests. Neither the changed module nor the new regression test failed.

Resume

  • Bug fix: yes
  • New feature: no
  • Fixed tickets: none

Per-CPU stats checked for guest_nice but returned the steal field, so systems exposing both values reported incorrect guest_nice usage. Read the matching psutil field and cover the conversion with distinct fixture values.
@nicolargo

Copy link
Copy Markdown
Owner

Thanks for the PR @justadityaraj

Damed... copy/paste issue :)

Merged into develop.

@nicolargo
nicolargo merged commit c15ab4c into nicolargo:develop Aug 26, 2026
18 of 19 checks passed
@nicolargo nicolargo added this to the Glances 4.5.7 milestone Aug 26, 2026
@justadityaraj

Copy link
Copy Markdown
Contributor Author

Thanks for the PR @justadityaraj

Damed... copy/paste issue :)

Merged into develop.

Welcome @nicolargo :)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants