Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove LXC special handling for the CPU count #1197

Merged
merged 1 commit into from
Feb 25, 2023

Conversation

fasterit
Copy link
Member

LXC shows the real host CPU ids but can be limited in configuration as to which cores are used. Still the sysfs files are visible and the CPUs (stay) marked online. We will need to parse
/sys/devices/system/cpu/online to follow LXC's logic. Revert for now until we can come up with a better handling of the LXC hacks.

Cf. issue #1195
Essentially reverting 33973f7 and 0d53245 (#993, #995)

LXC shows the real host CPU ids but can be limited in configuration
as to which cores are used. Still the sysfs files are visible and the
CPUs (stay) marked online. We will need to parse
/sys/devices/system/cpu/online to follow LXC's logic.
Revert for now until we can come up with a better handling of the LXC hacks.

Cf. issue htop-dev#1195
Essentially reverting 33973f7 and 0d53245 (htop-dev#993, htop-dev#995)
@C0rn3j
Copy link
Contributor

C0rn3j commented Feb 25, 2023

Applying this against 3.2.2 tarball, that does indeed go back to the old behavior.

image

@BenBE BenBE added bug 🐛 Something isn't working Linux 🐧 Linux related issues labels Feb 25, 2023
@BenBE BenBE added this to the 3.3.0 milestone Feb 25, 2023
@BenBE BenBE merged commit 11318b5 into htop-dev:main Feb 25, 2023
@Napsty
Copy link

Napsty commented Dec 5, 2023

Actually if I apply this patch to htop 3.2.2, I get the WRONG number of cpus in the htop output.

Inside a LXC container with a cgroup limit to 2 cpus.

htop 3.2.2 compiled from the release tar.xz:

image

htop 3.2.2 with this patch added:

image

To me this looks wrong. Why are now all cpus showing up again when the cgroup limit is in place?
The same behaviour can be seen in the current htop package in the Debian repositories. htop 3.2.2 for Bookworm contains this pull request as patch, too.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1057466

@fasterit fasterit deleted the revert-LXC-special-casing branch January 10, 2024 09:25
@C0rn3j
Copy link
Contributor

C0rn3j commented Jan 31, 2024

@Napsty Two reasons.

  1. There is a bug introduced in 3.1.0 that does not mark trailing offline threads offline, which Linux: Correctly mark trailing offline CPU threads #1394 fixes and it is kinda tracked here [sparc64] limit cpu shown on active (online) cpus only? #757

  2. htop isn't able to show CPUs properly dynamically, this depends on Dynamic display of online CPUs in CPU meter #1198
    Currently, if you assign a machine a singular thread ID 5, the removed handling caused you to see a singular thread ID 0 in htop, which was incorrect, so now you see all threads, but due to the bug you don't even see them marked as offline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working Linux 🐧 Linux related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Regression in 3.2.1] Wrong CPU threads are shown when running in a container
4 participants