FreeBSD Bugzilla – Attachment 75803 Details for
Bug 109413
[patch] top(1) shows at least 50% idle when hyperthreading is disabled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 2.25 KB, created by
Craig Leres
on 2007-02-21 23:50:08 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Craig Leres
Created:
2007-02-21 23:50:08 UTC
Size:
2.25 KB
patch
obsolete
>diff -c -r1.1 machine.c >*** machine.c 2007/02/21 22:56:13 1.1 >--- machine.c 2007/02/21 23:07:52 >*************** >*** 150,155 **** >--- 150,156 ---- > static long cp_time[CPUSTATES]; > static long cp_old[CPUSTATES]; > static long cp_diff[CPUSTATES]; >+ static int hyperthread_hack; > > /* these are for detailing the process states */ > >*************** >*** 226,240 **** > machine_init(struct statics *statics) > { > int pagesize; >! size_t modelen; > struct passwd *pw; > >! modelen = sizeof(smpmode); >! if ((sysctlbyname("machdep.smp_active", &smpmode, &modelen, NULL, 0) < 0 && >! sysctlbyname("kern.smp.active", &smpmode, &modelen, NULL, 0) < 0) || >! modelen != sizeof(smpmode)) > smpmode = 0; > > while ((pw = getpwent()) != NULL) { > if (strlen(pw->pw_name) > namelength) > namelength = strlen(pw->pw_name); >--- 227,250 ---- > machine_init(struct statics *statics) > { > int pagesize; >! size_t len; >! int hyperthreading_allowed; > struct passwd *pw; > >! len = sizeof(smpmode); >! if ((sysctlbyname("machdep.smp_active", &smpmode, &len, NULL, 0) < 0 && >! sysctlbyname("kern.smp.active", &smpmode, &len, NULL, 0) < 0) || >! len != sizeof(smpmode)) > smpmode = 0; > >+ /* Determine if hyperthreading is supported but disabled */ >+ len = sizeof(hyperthreading_allowed); >+ if (sysctlbyname("machdep.hyperthreading_allowed", >+ &hyperthreading_allowed, &len, NULL, 0) >= 0 && >+ len == sizeof(hyperthreading_allowed) && >+ !hyperthreading_allowed) >+ ++hyperthread_hack; >+ > while ((pw = getpwent()) != NULL) { > if (strlen(pw->pw_name) > namelength) > namelength = strlen(pw->pw_name); >*************** >*** 330,335 **** >--- 340,360 ---- > GETSYSCTL("kern.cp_time", cp_time); > GETSYSCTL("vm.loadavg", sysload); > GETSYSCTL("kern.lastpid", lastpid); >+ >+ /* >+ * If hyperthreading is supported but disabled, at most 1/2 >+ * of the total ticks can be non-idle. To avoid having idle >+ * always displayed as at least 50%, subtract out the phantom >+ * idle ticks out. >+ */ >+ if (hyperthread_hack) { >+ total = 0; >+ for (i = 0; i < CPUSTATES; ++i) >+ total += cp_time[i]; >+ cp_time[CP_IDLE] -= total / 2; >+ if (cp_time[CP_IDLE] < 0) >+ cp_time[CP_IDLE] = 0; >+ } > > /* convert load averages to doubles */ > for (i = 0; i < 3; i++)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 109413
: 75803