library: add final remaining sort function, <STAT> api

With this patch, all of the modules which offer a reap
function (pids, diskstats, slabinfo and stat too) will
now also provide for sorting whatever had been reaped.

It was easy to overlook a sort function for our <STAT>
guy given the paucity of CPUs on your typical personal
desktop or laptop. However, out in the world one might
find boxes with hundreds of CPUs plus many NUMA nodes.

Hey, who are we to disallow sorts on something another
person might see as useful under the above conditions?
And, there's always something to be said for symmetry.

[ of course, several minor tweaks were also included ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner
2016-07-24 00:00:00 -05:00
committed by Craig Small
parent 5c857b865e
commit 6f71a33c1d
3 changed files with 195 additions and 75 deletions

View File

@@ -70,6 +70,12 @@ enum stat_reap_type {
STAT_REAP_CPUS_AND_NODES
};
enum stat_sort_order {
STAT_SORT_ASCEND = +1,
STAT_SORT_DESCEND = -1
};
struct stat_result {
enum stat_item item;
union {
@@ -127,6 +133,13 @@ struct stat_stack *procps_stat_select (
enum stat_item *items,
int numitems);
struct stat_stack **procps_stat_sort (
struct stat_info *info,
struct stat_stack *stacks[],
int numstacked,
enum stat_item sortitem,
enum stat_sort_order order);
__END_DECLS
#endif