Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F160691987
D15858.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D15858.diff
View Options
Index: head/sys/compat/linprocfs/linprocfs.c
===================================================================
--- head/sys/compat/linprocfs/linprocfs.c
+++ head/sys/compat/linprocfs/linprocfs.c
@@ -469,9 +469,21 @@
return (0);
}
-
/*
* Filler function for proc/stat
+ *
+ * Output depends on kernel version:
+ *
+ * v2.5.40 <=
+ * user nice system idle
+ * v2.5.41
+ * user nice system idle iowait
+ * v2.6.11
+ * user nice system idle iowait irq softirq steal
+ * v2.6.24
+ * user nice system idle iowait irq softirq steal guest
+ * v2.6.33 >=
+ * user nice system idle iowait irq softirq steal guest guest_nice
*/
static int
linprocfs_dostat(PFS_FILL_ARGS)
@@ -481,22 +493,54 @@
long *cp;
struct timeval boottime;
int i;
+ char *zero_pad;
+ bool has_intr = true;
+ if (linux_kernver(td) >= LINUX_KERNVER(2,6,33)) {
+ zero_pad = " 0 0 0 0\n";
+ } else if (linux_kernver(td) >= LINUX_KERNVER(2,6,24)) {
+ zero_pad = " 0 0 0\n";
+ } else if (linux_kernver(td) >= LINUX_KERNVER(2,6,11)) {
+ zero_pad = " 0 0\n";
+ } else if (linux_kernver(td) >= LINUX_KERNVER(2,5,41)) {
+ has_intr = false;
+ zero_pad = " 0\n";
+ } else {
+ has_intr = false;
+ zero_pad = "\n";
+ }
+
read_cpu_time(cp_time);
getboottime(&boottime);
- sbuf_printf(sb, "cpu %ld %ld %ld %ld\n",
+ /* Parameters common to all versions */
+ sbuf_printf(sb, "cpu %lu %lu %lu %lu",
T2J(cp_time[CP_USER]),
T2J(cp_time[CP_NICE]),
- T2J(cp_time[CP_SYS] /*+ cp_time[CP_INTR]*/),
+ T2J(cp_time[CP_SYS]),
T2J(cp_time[CP_IDLE]));
+
+ /* Print interrupt stats if available */
+ if (has_intr) {
+ sbuf_printf(sb, " 0 %lu", T2J(cp_time[CP_INTR]));
+ }
+
+ /* Pad out remaining fields depending on version */
+ sbuf_printf(sb, "%s", zero_pad);
+
CPU_FOREACH(i) {
pcpu = pcpu_find(i);
cp = pcpu->pc_cp_time;
- sbuf_printf(sb, "cpu%d %ld %ld %ld %ld\n", i,
+ sbuf_printf(sb, "cpu%d %lu %lu %lu %lu", i,
T2J(cp[CP_USER]),
T2J(cp[CP_NICE]),
- T2J(cp[CP_SYS] /*+ cp[CP_INTR]*/),
+ T2J(cp[CP_SYS]),
T2J(cp[CP_IDLE]));
+
+ if (has_intr) {
+ sbuf_printf(sb, " 0 %lu", T2J(cp[CP_INTR]));
+ }
+
+ sbuf_printf(sb, "%s", zero_pad);
}
sbuf_printf(sb,
"disk 0 0 0 0\n"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jun 27, 8:42 PM (12 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34415413
Default Alt Text
D15858.diff (2 KB)
Attached To
Mode
D15858: Fix output of linprocfs stat entry
Attached
Detach File
Event Timeline
Log In to Comment