-
-
Notifications
You must be signed in to change notification settings - Fork 412
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
don't include offline CPUs in summary for OpenBSD #580
Conversation
Can you squash your commits? Makes the history cleaner and easier to follow. |
On 2021/03/28 13:37, BenBE wrote:
Can you squash your commits? Makes the history cleaner and easier to follow.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.*
If you can tell me what to type to do that, yes. (I don't normally use git).
|
When on your branch: # Fetch latest changes
git fetch --all
# Apply latest changes
git pull --rebase your-repo your-branch
# Base local changes on upstream master
git rebase -i htop-upstream/master
# Push the modified branch to your repo to update this PR.
git push --force-with-lease your-repo your-branch In the editor that opens change the second line from |
|
||
if (cpu_index_c == pl->cpuCount) | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this loop about?
cpu_index_c
is being increased and the loop is aborted when it reaches a specific value, but there are no further implications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, looks like I missed a bit when I was merging the patch which was originally done against 3.0.1. It will work on Intel CPUs without that loop (the skipped cpus are the higher numbered ones) but they're interspersed on AMD (skipped would be 1,3,5,7,..) I just pushed an updated version that I think should do the trick (I don't have an AMD cpu with SMT to test that part with though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked someone to test on AMD, this version is looking ok.
openbsd/OpenBSDProcessList.c
Outdated
@@ -53,6 +57,13 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui | |||
pl->cpuCount = 1; | |||
} | |||
opl->cpus = xCalloc(pl->cpuCount + 1, sizeof(CPUData)); | |||
opl->cpuIndex = xRealloc(opl->cpuIndex, pl->cpuCount * sizeof(int)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*opl
was initialized in this function, no need to realloc (just malloc (or calloc, see later comment))
openbsd/OpenBSDProcessList.c
Outdated
size = sizeof(cpu_stats); | ||
for (unsigned int i = 0; i < ncpu; i++) { | ||
ncmib[2] = i; | ||
sysctl(ncmib, 3, &cpu_stats, &size, NULL, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check for a sysctl failure
openbsd/OpenBSDProcessList.h
Outdated
@@ -43,7 +43,7 @@ typedef struct OpenBSDProcessList_ { | |||
|
|||
CPUData* cpus; | |||
int cpuSpeed; | |||
|
|||
int* cpuIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe include the index in the CPUData
struct (the one unused int
of the average entry is negligible)
By default, OpenBSD disables SMT (hyperthreading) cpu pseudo-cores. This can be changed at runtime by setting the hw.smt sysctl so they may become active later, therefore they are still present in cpu stat structures but are marked as offline. As done with native top(1), this drops them from the cpu summary graphs.
@@ -76,6 +86,21 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui | |||
|
|||
opl->cpuSpeed = -1; | |||
|
|||
size = sizeof(cpu_stats); | |||
for (unsigned int i = 0; i < ncpu; i++) { | |||
ncmib[2] = i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move actual initialization of ncmib
here and make it const.
ncmib[2] = i; | |
const int ncmib[] = { CTL_KERN, KERN_CPUSTATS, i }; |
int r; | ||
unsigned int cpu_index_c = 0, ncpu; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single variable per line …
size = sizeof(cpu_stats); | ||
for (unsigned int i = 0; i < ncpu; i++) { | ||
ncmib[2] = i; | ||
if (sysctl(ncmib, 3, &cpu_stats, &size, NULL, 0) < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't size
be re-initialized inside the loop?
Since you have a pretty clear idea of what changes you want, could one of you fix it up please? Most of my development work is with OpenBSD and we don't use git so what is probably a 2 minute job for you takes me about half an hour each time to figure out how to rebase the commit history how you want it. Thanks! |
Applied with adjustments via feec16c. |
Many thanks. |
Currently htop does not support offline CPUs and hot-swapping, e.g. via echo 0 > /sys/devices/system/cpu/cpu2/online Split the current single cpuCount variable into activeCPUs and existingCPUs. Supersedes: htop-dev#650 Related: htop-dev#580
Currently htop does not support offline CPUs and hot-swapping, e.g. via echo 0 > /sys/devices/system/cpu/cpu2/online Split the current single cpuCount variable into activeCPUs and existingCPUs. Supersedes: htop-dev#650 Related: htop-dev#580
Currently htop does not support offline CPUs and hot-swapping, e.g. via echo 0 > /sys/devices/system/cpu/cpu2/online Split the current single cpuCount variable into activeCPUs and existingCPUs. Supersedes: htop-dev#650 Related: htop-dev#580
Currently htop does not support offline CPUs and hot-swapping, e.g. via echo 0 > /sys/devices/system/cpu/cpu2/online Split the current single cpuCount variable into activeCPUs and existingCPUs. Supersedes: htop-dev#650 Related: htop-dev#580
Currently htop does not support offline CPUs and hot-swapping, e.g. via echo 0 > /sys/devices/system/cpu/cpu2/online Split the current single cpuCount variable into activeCPUs and existingCPUs. Supersedes: htop-dev#650 Related: htop-dev#580
Currently htop does not support offline CPUs and hot-swapping, e.g. via echo 0 > /sys/devices/system/cpu/cpu2/online Split the current single cpuCount variable into activeCPUs and existingCPUs. Supersedes: htop-dev#650 Related: htop-dev#580
By default, OpenBSD disables SMT (hyperthreading) cpu pseudo-cores.
This can be changed at runtime by setting the hw.smt sysctl so they
may become active later, therefore they are still present in cpu
stat structures but are marked as offline.
As done with native top(1), this drops them from the cpu summary
graphs.