Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168408547
D18658.id52316.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D18658.id52316.diff
View Options
Index: usr.bin/top/machine.c
===================================================================
--- usr.bin/top/machine.c
+++ usr.bin/top/machine.c
@@ -196,7 +196,7 @@
static const char *ordernames[] = {
"cpu", "size", "res", "time", "pri", "threads",
"total", "read", "write", "fault", "vcsw", "ivcsw",
- "jid", "swap", "pid", NULL
+ "jid", "swap", "pid", "pbt", NULL
};
/* Per-cpu time states */
@@ -1276,6 +1276,21 @@
return (diff > 0 ? 1 : -1); \
} while (0)
+#define ORDERKEY_PID(a, b) do { \
+ int diff = (int)b->ki_pid - (int)a->ki_pid; \
+ if (diff != 0) \
+ return (diff > 0 ? 1 : -1); \
+} while (0)
+
+#define ORDERKEY_PBT(a, b) do { \
+ time_t tdiff = b->ki_start.tv_sec - a->ki_start.tv_sec; \
+ suseconds_t udiff = b->ki_start.tv_usec - a->ki_start.tv_usec; \
+ if (tdiff != 0) \
+ return (tdiff > 0 ? 1 : -1); \
+ if (udiff != 0) \
+ return (udiff > 0 ? 1 : -1); \
+} while (0)
+
/* compare_cpu - the comparison function for sorting by cpu percentage */
static int
@@ -1420,6 +1435,42 @@
return (0);
}
+/* compare_processid - the comparison function for sorting by pid */
+static int
+compare_processid(const void *arg1, const void *arg2)
+{
+ const struct kinfo_proc *p1 = *(const struct kinfo_proc * const *)arg1;
+ const struct kinfo_proc *p2 = *(const struct kinfo_proc * const *)arg2;
+
+ ORDERKEY_PID(p1, p2);
+ ORDERKEY_PCTCPU(p1, p2);
+ ORDERKEY_CPTICKS(p1, p2);
+ ORDERKEY_STATE(p1, p2);
+ ORDERKEY_PRIO(p1, p2);
+ ORDERKEY_RSSIZE(p1, p2);
+ ORDERKEY_MEM(p1, p2);
+
+ return (0);
+}
+
+/* compare_processbt - the comparison function for sorting by birthtime */
+static int
+compare_processbt(const void *arg1, const void *arg2)
+{
+ const struct kinfo_proc *p1 = *(const struct kinfo_proc * const *)arg1;
+ const struct kinfo_proc *p2 = *(const struct kinfo_proc * const *)arg2;
+
+ ORDERKEY_PBT(p1, p2);
+ ORDERKEY_PCTCPU(p1, p2);
+ ORDERKEY_CPTICKS(p1, p2);
+ ORDERKEY_STATE(p1, p2);
+ ORDERKEY_PRIO(p1, p2);
+ ORDERKEY_RSSIZE(p1, p2);
+ ORDERKEY_MEM(p1, p2);
+
+ return (0);
+}
+
/* assorted comparison functions for sorting by i/o */
static int
@@ -1511,7 +1562,8 @@
compare_ivcsw,
compare_jid,
compare_swap,
- NULL
+ compare_processid,
+ compare_processbt
};
Index: usr.bin/top/top.1
===================================================================
--- usr.bin/top/top.1
+++ usr.bin/top/top.1
@@ -1,5 +1,5 @@
.\" $FreeBSD$
-.Dd October 2, 2018
+.Dd December 25, 2018
.Dt TOP 1
.Os
.Sh NAME
@@ -148,12 +148,16 @@
The default delay between updates is 1 second.
.It Fl o Ar field
Sort the process display area on the specified field.
-The field name
-is the name of the column as seen in the output, but in lower case:
-\*(lqcpu\*(lq, \*(rqsize\*(lq, \*(rqres\*(lq, \*(rqtime\*(lq,
-\*(rqpri\*(lq, \*(rqthreads\*(lq, \*(lqtotal\*(lq, \*(rqread\*(lq,
-\*(rqwrite\*(lq, \*(rqfault\*(lq, \*(rqvcsw\*(lq, \*(rqivcsw\*(lq,
-\*(lqjid\*(lq, \*(rqswap\*(lq or \*(rqpid\*(lq.
+The field name is the name of the column as seen in the output
+.Po except for
+.Cm pbt
+which defines the process birth time
+.Pc ,
+but in lower case:
+.Cm cpu , size , res , time , pri , threads , total , read , write , fault ,
+.Cm vcsw , ivcsw , jid , swap, pid ,
+or
+.Cm pbt .
.It Fl p Ar pid
Show only the process
.Ar pid .
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Aug 29, 2:53 AM (8 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37493427
Default Alt Text
D18658.id52316.diff (3 KB)
Attached To
Mode
D18658: top: fix PID sorting after r340742; add process birth time sorting
Attached
Detach File
Event Timeline
Log In to Comment