diff options
-rw-r--r-- | usr.bin/systat/pool.c | 43 | ||||
-rw-r--r-- | usr.bin/systat/systat.1 | 10 |
2 files changed, 48 insertions, 5 deletions
diff --git a/usr.bin/systat/pool.c b/usr.bin/systat/pool.c index c8197e3cd7e..0d17a3d13d5 100644 --- a/usr.bin/systat/pool.c +++ b/usr.bin/systat/pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pool.c,v 1.3 2008/11/05 16:03:02 chl Exp $ */ +/* $OpenBSD: pool.c,v 1.4 2008/12/07 07:46:05 canacar Exp $ */ /* * Copyright (c) 2008 Can Erkin Acar <canacar@openbsd.org> * @@ -34,6 +34,8 @@ void showpool(int k); /* qsort callbacks */ int sort_name_callback(const void *s1, const void *s2); int sort_req_callback(const void *s1, const void *s2); +int sort_psize_callback(const void *s1, const void *s2); +int sort_npage_callback(const void *s1, const void *s2); struct pool_info { char name[32]; @@ -86,6 +88,8 @@ field_def *view_pool_0[] = { order_type pool_order_list[] = { {"name", "name", 'N', sort_name_callback}, {"requests", "requests", 'Q', sort_req_callback}, + {"size", "size", 'Z', sort_psize_callback}, + {"npages", "npages", 'P', sort_npage_callback}, {NULL, NULL, 0, NULL} }; @@ -126,6 +130,43 @@ sort_req_callback(const void *s1, const void *s2) return sort_name_callback(s1, s2); } +int +sort_npage_callback(const void *s1, const void *s2) +{ + struct pool_info *p1, *p2; + p1 = (struct pool_info *)s1; + p2 = (struct pool_info *)s2; + + if (p1->pool.pr_npages < p2->pool.pr_npages) + return sortdir; + if (p1->pool.pr_npages > p2->pool.pr_npages) + return -sortdir; + + return sort_name_callback(s1, s2); +} + +int +sort_psize_callback(const void *s1, const void *s2) +{ + struct pool_info *p1, *p2; + size_t ps1, ps2; + + p1 = (struct pool_info *)s1; + p2 = (struct pool_info *)s2; + + ps1 = (size_t)(p1->pool.pr_nget - p1->pool.pr_nput) * + (size_t)p1->pool.pr_size; + ps2 = (size_t)(p2->pool.pr_nget - p2->pool.pr_nput) * + (size_t)p2->pool.pr_size; + + if (ps1 < ps2) + return sortdir; + if (ps1 > ps2) + return -sortdir; + + return sort_npage_callback(s1, s2); +} + void sort_pool(void) { diff --git a/usr.bin/systat/systat.1 b/usr.bin/systat/systat.1 index 424baf124db..da2fde62ed0 100644 --- a/usr.bin/systat/systat.1 +++ b/usr.bin/systat/systat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: systat.1,v 1.74 2008/12/02 08:41:32 jmc Exp $ +.\" $OpenBSD: systat.1,v 1.75 2008/12/07 07:46:05 canacar Exp $ .\" $NetBSD: systat.1,v 1.6 1996/05/10 23:16:39 thorpej Exp $ .\" .\" Copyright (c) 1985, 1990, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)systat.1 8.2 (Berkeley) 12/30/93 .\" -.Dd $Mdocdate: December 2 2008 $ +.Dd $Mdocdate: December 7 2008 $ .Dt SYSTAT 1 .Os .Sh NAME @@ -342,9 +342,11 @@ Display kernel statistics similar to the output of .Cm vmstat Fl m . Available orderings are: -.Ic name +.Ic name , +.Ic requests , +.Ic size and -.Ic requests . +.Ic number of pages . .It Ic queues Display statistics about the active .Xr altq 9 |