2011-06-04 22:28:25 +05:30
|
|
|
/*
|
2004-01-25 04:03:56 +05:30
|
|
|
* slabtop.c - utility to display kernel slab information.
|
|
|
|
*
|
|
|
|
* Chris Rivera <cmrivera@ufl.edu>
|
|
|
|
* Robert Love <rml@tech9.net>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Chris Rivera
|
2012-03-02 17:59:36 +05:30
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-01-25 04:03:56 +05:30
|
|
|
*/
|
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <getopt.h>
|
2011-11-03 21:37:47 +05:30
|
|
|
#include <locale.h>
|
2015-07-11 10:30:00 +05:30
|
|
|
#include <ncurses.h>
|
|
|
|
#include <signal.h>
|
2004-01-25 04:03:56 +05:30
|
|
|
#include <stdio.h>
|
2015-07-11 10:30:00 +05:30
|
|
|
#include <stdlib.h>
|
2004-01-25 04:03:56 +05:30
|
|
|
#include <string.h>
|
|
|
|
#include <termios.h>
|
2005-01-06 02:20:54 +05:30
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
#include <sys/ioctl.h>
|
2004-01-25 04:03:56 +05:30
|
|
|
#include <sys/select.h>
|
2005-01-06 02:20:54 +05:30
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
2004-01-25 04:03:56 +05:30
|
|
|
|
2011-10-09 06:19:51 +05:30
|
|
|
#include "c.h"
|
2012-03-23 18:02:24 +05:30
|
|
|
#include "fileutils.h"
|
2011-10-09 06:19:51 +05:30
|
|
|
#include "nls.h"
|
2011-12-18 19:42:06 +05:30
|
|
|
#include "strutils.h"
|
2016-04-16 12:33:57 +05:30
|
|
|
#include <proc/procps.h>
|
2004-01-25 04:03:56 +05:30
|
|
|
|
2016-07-21 10:30:00 +05:30
|
|
|
#define DEFAULT_SORT SLABNODE_OBJS
|
2015-07-11 10:30:00 +05:30
|
|
|
#define CHAINS_ALLOC 150
|
2016-06-05 10:30:00 +05:30
|
|
|
#define MAXTBL(t) (int)( sizeof(t) / sizeof(t[0]) )
|
2015-07-11 10:30:00 +05:30
|
|
|
|
|
|
|
static unsigned short Cols, Rows;
|
|
|
|
static struct termios Saved_tty;
|
|
|
|
static long Delay = 3;
|
|
|
|
static int Run_once = 0;
|
|
|
|
|
2016-07-21 10:30:00 +05:30
|
|
|
static struct slabinfo_info *Slab_info;
|
2015-07-11 10:30:00 +05:30
|
|
|
|
2016-06-05 10:30:00 +05:30
|
|
|
enum slabinfo_item Sort_item = DEFAULT_SORT;
|
2016-07-21 10:30:00 +05:30
|
|
|
enum slabinfo_sort_order Sort_Order = SLABINFO_SORT_DESCEND;
|
2015-07-11 10:30:00 +05:30
|
|
|
|
2016-06-05 10:30:00 +05:30
|
|
|
enum slabinfo_item Node_items[] = {
|
2016-07-21 10:30:00 +05:30
|
|
|
SLABNODE_OBJS, SLABNODE_AOBJS, SLABNODE_USE,
|
|
|
|
SLABNODE_OBJ_SIZE, SLABNODE_SLABS, SLABNODE_OBJS_PER_SLAB,
|
|
|
|
SLABNODE_SIZE, SLABNODE_NAME,
|
2015-07-21 10:30:00 +05:30
|
|
|
/* next 2 are sortable but are not displayable,
|
2015-07-11 10:30:00 +05:30
|
|
|
thus they need not be represented in the Relative_enums */
|
2016-07-21 10:30:00 +05:30
|
|
|
SLABNODE_PAGES_PER_SLAB, SLABNODE_ASLABS };
|
2015-07-11 10:30:00 +05:30
|
|
|
|
2016-08-10 17:38:09 +05:30
|
|
|
enum Relative_node {
|
|
|
|
nod_OBJS, nod_AOBJS, nod_USE, nod_OSIZE,
|
|
|
|
nod_SLABS, nod_OPS, nod_SIZE, nod_NAME };
|
2015-07-11 10:30:00 +05:30
|
|
|
|
|
|
|
#define MAX_ITEMS (int)(sizeof(Node_items) / sizeof(Node_items[0]))
|
|
|
|
|
|
|
|
#define PRINT_line(fmt, ...) if (Run_once) printf(fmt, __VA_ARGS__); else printw(fmt, __VA_ARGS__)
|
2004-01-25 04:03:56 +05:30
|
|
|
|
|
|
|
|
|
|
|
/*
|
2015-07-11 10:30:00 +05:30
|
|
|
* term_resize - set the globals 'Cols' and 'Rows' to the current terminal size
|
2004-01-25 04:03:56 +05:30
|
|
|
*/
|
2015-07-11 10:30:00 +05:30
|
|
|
static void term_resize (int unusused __attribute__ ((__unused__)))
|
2004-01-25 04:03:56 +05:30
|
|
|
{
|
2015-07-04 10:29:59 +05:30
|
|
|
struct winsize ws;
|
|
|
|
|
|
|
|
if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1) && ws.ws_row > 10) {
|
2015-07-11 10:30:00 +05:30
|
|
|
Cols = ws.ws_col;
|
|
|
|
Rows = ws.ws_row;
|
2015-07-04 10:29:59 +05:30
|
|
|
} else {
|
2015-07-11 10:30:00 +05:30
|
|
|
Cols = 80;
|
|
|
|
Rows = 24;
|
2015-07-04 10:29:59 +05:30
|
|
|
}
|
2004-01-25 04:03:56 +05:30
|
|
|
}
|
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
static void sigint_handler (int unused __attribute__ ((__unused__)))
|
2004-01-25 04:03:56 +05:30
|
|
|
{
|
2015-07-11 10:30:00 +05:30
|
|
|
Delay = 0;
|
2004-01-25 04:03:56 +05:30
|
|
|
}
|
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
static void __attribute__((__noreturn__)) usage (FILE *out)
|
2004-01-25 04:03:56 +05:30
|
|
|
{
|
2015-07-04 10:29:59 +05:30
|
|
|
fputs(USAGE_HEADER, out);
|
|
|
|
fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
|
|
|
|
fputs(USAGE_OPTIONS, out);
|
|
|
|
fputs(_(" -d, --delay <secs> delay updates\n"), out);
|
|
|
|
fputs(_(" -o, --once only display once, then exit\n"), out);
|
|
|
|
fputs(_(" -s, --sort <char> specify sort criteria by character (see below)\n"), out);
|
|
|
|
fputs(USAGE_SEPARATOR, out);
|
|
|
|
fputs(USAGE_HELP, out);
|
|
|
|
fputs(USAGE_VERSION, out);
|
|
|
|
|
|
|
|
fputs(_("\nThe following are valid sort criteria:\n"), out);
|
|
|
|
fputs(_(" a: sort by number of active objects\n"), out);
|
|
|
|
fputs(_(" b: sort by objects per slab\n"), out);
|
|
|
|
fputs(_(" c: sort by cache size\n"), out);
|
|
|
|
fputs(_(" l: sort by number of slabs\n"), out);
|
2015-07-11 10:30:00 +05:30
|
|
|
fputs(_(" v: sort by (non display) number of active slabs\n"), out);
|
2015-07-04 10:29:59 +05:30
|
|
|
fputs(_(" n: sort by name\n"), out);
|
|
|
|
fputs(_(" o: sort by number of objects (the default)\n"), out);
|
2015-07-11 10:30:00 +05:30
|
|
|
fputs(_(" p: sort by (non display) pages per slab\n"), out);
|
2015-07-04 10:29:59 +05:30
|
|
|
fputs(_(" s: sort by object size\n"), out);
|
|
|
|
fputs(_(" u: sort by cache utilization\n"), out);
|
|
|
|
fprintf(out, USAGE_MAN_TAIL("slabtop(1)"));
|
|
|
|
|
|
|
|
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
|
2004-01-25 04:03:56 +05:30
|
|
|
}
|
|
|
|
|
2016-06-09 10:30:00 +05:30
|
|
|
static void set_sort_stuff (const char key)
|
2015-07-04 10:29:59 +05:30
|
|
|
{
|
2016-06-09 10:30:00 +05:30
|
|
|
Sort_item = DEFAULT_SORT;
|
2016-07-21 10:30:00 +05:30
|
|
|
Sort_Order = SLABINFO_SORT_DESCEND;
|
2016-06-09 10:30:00 +05:30
|
|
|
|
2015-07-04 10:29:59 +05:30
|
|
|
switch (tolower(key)) {
|
|
|
|
case 'n':
|
2016-07-21 10:30:00 +05:30
|
|
|
Sort_item = SLABNODE_NAME;
|
|
|
|
Sort_Order = SLABINFO_SORT_ASCEND;
|
2016-06-09 10:30:00 +05:30
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
case 'o':
|
2016-07-21 10:30:00 +05:30
|
|
|
Sort_item = SLABNODE_OBJS;
|
2016-06-09 10:30:00 +05:30
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
case 'a':
|
2016-07-21 10:30:00 +05:30
|
|
|
Sort_item = SLABNODE_AOBJS;
|
2016-06-09 10:30:00 +05:30
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
case 's':
|
2016-07-21 10:30:00 +05:30
|
|
|
Sort_item = SLABNODE_OBJ_SIZE;
|
2016-06-09 10:30:00 +05:30
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
case 'b':
|
2016-07-21 10:30:00 +05:30
|
|
|
Sort_item = SLABNODE_OBJS_PER_SLAB;
|
2016-06-09 10:30:00 +05:30
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
case 'p':
|
2016-07-21 10:30:00 +05:30
|
|
|
Sort_item = SLABNODE_PAGES_PER_SLAB;
|
2016-06-09 10:30:00 +05:30
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
case 'l':
|
2016-07-21 10:30:00 +05:30
|
|
|
Sort_item = SLABNODE_SLABS;
|
2016-06-09 10:30:00 +05:30
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
case 'v':
|
2016-07-21 10:30:00 +05:30
|
|
|
Sort_item = SLABNODE_ASLABS;
|
2016-06-09 10:30:00 +05:30
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
case 'c':
|
2016-07-21 10:30:00 +05:30
|
|
|
Sort_item = SLABNODE_SIZE;
|
2016-06-09 10:30:00 +05:30
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
case 'u':
|
2016-07-21 10:30:00 +05:30
|
|
|
Sort_item = SLABNODE_USE;
|
2016-06-09 10:30:00 +05:30
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
default:
|
2016-06-09 10:30:00 +05:30
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
static void parse_opts (int argc, char **argv)
|
|
|
|
{
|
|
|
|
static const struct option longopts[] = {
|
|
|
|
{ "delay", required_argument, NULL, 'd' },
|
|
|
|
{ "sort", required_argument, NULL, 's' },
|
|
|
|
{ "once", no_argument, NULL, 'o' },
|
|
|
|
{ "help", no_argument, NULL, 'h' },
|
|
|
|
{ "version", no_argument, NULL, 'V' },
|
|
|
|
{ NULL, 0, NULL, 0 }};
|
|
|
|
int o;
|
|
|
|
|
|
|
|
while ((o = getopt_long(argc, argv, "d:s:ohV", longopts, NULL)) != -1) {
|
|
|
|
switch (o) {
|
|
|
|
case 'd':
|
|
|
|
errno = 0;
|
|
|
|
Delay = strtol_or_err(optarg, _("illegal delay"));
|
|
|
|
if (Delay < 1)
|
|
|
|
xerrx(EXIT_FAILURE, _("delay must be positive integer"));
|
|
|
|
break;
|
|
|
|
case 's':
|
2016-06-09 10:30:00 +05:30
|
|
|
set_sort_stuff(optarg[0]);
|
2015-07-11 10:30:00 +05:30
|
|
|
break;
|
|
|
|
case 'o':
|
|
|
|
Run_once=1;
|
|
|
|
Delay = 0;
|
|
|
|
break;
|
|
|
|
case 'V':
|
|
|
|
printf(PROCPS_NG_VERSION);
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
case 'h':
|
|
|
|
usage(stdout);
|
|
|
|
default:
|
|
|
|
usage(stderr);
|
|
|
|
}
|
2015-07-04 10:29:59 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
static void print_summary (void)
|
2004-01-25 04:03:56 +05:30
|
|
|
{
|
2016-08-10 17:38:09 +05:30
|
|
|
#define totalVAL(e,t) SLABINFO_VAL(e, t, p, Slab_info)
|
2016-06-05 10:30:00 +05:30
|
|
|
enum slabinfo_item items[] = {
|
2016-07-21 10:30:00 +05:30
|
|
|
SLABS_AOBJS, SLABS_OBJS,
|
|
|
|
SLABS_ASLABS, SLABS_SLABS,
|
|
|
|
SLABS_ACACHES, SLABS_CACHES,
|
|
|
|
SLABS_SIZE_ACTIVE, SLABS_SIZE_TOTAL,
|
|
|
|
SLABS_SIZE_MIN, SLABS_SIZE_AVG,
|
|
|
|
SLABS_SIZE_MAX
|
2016-06-05 10:30:00 +05:30
|
|
|
};
|
2016-08-10 17:38:09 +05:30
|
|
|
enum rel_items {
|
|
|
|
tot_AOBJS, tot_OBJS, tot_ASLABS, tot_SLABS,
|
|
|
|
tot_ACACHES, tot_CACHES, tot_ACTIVE, tot_TOTAL,
|
|
|
|
tot_MIN, tot_AVG, tot_MAX
|
2015-07-04 10:29:59 +05:30
|
|
|
};
|
2016-06-05 10:30:00 +05:30
|
|
|
struct slabinfo_stack *p;
|
|
|
|
struct slabinfo_result *stats;
|
2015-07-04 10:29:59 +05:30
|
|
|
|
2016-06-05 10:30:00 +05:30
|
|
|
if (!(p = procps_slabinfo_select(Slab_info, items, MAXTBL(items))))
|
2015-07-11 10:30:00 +05:30
|
|
|
xerrx(EXIT_FAILURE, _("Error getting slab summary results"));
|
|
|
|
|
2015-07-21 10:30:00 +05:30
|
|
|
PRINT_line(" %-35s: %u / %u (%.1f%%)\n"
|
2015-07-11 10:30:00 +05:30
|
|
|
, /* Translation Hint: Next five strings must not
|
|
|
|
* exceed a length of 35 characters. */
|
|
|
|
/* xgettext:no-c-format */
|
|
|
|
_("Active / Total Objects (% used)")
|
2016-08-10 17:38:09 +05:30
|
|
|
, totalVAL(tot_AOBJS, u_int)
|
|
|
|
, totalVAL(tot_OBJS, u_int)
|
|
|
|
, 100.0 * totalVAL(tot_AOBJS, u_int) / totalVAL(tot_OBJS, u_int));
|
2015-07-21 10:30:00 +05:30
|
|
|
PRINT_line(" %-35s: %u / %u (%.1f%%)\n"
|
2015-07-11 10:30:00 +05:30
|
|
|
, /* xgettext:no-c-format */
|
|
|
|
_("Active / Total Slabs (% used)")
|
2016-08-10 17:38:09 +05:30
|
|
|
, totalVAL(tot_ASLABS, u_int)
|
|
|
|
, totalVAL(tot_SLABS, u_int)
|
|
|
|
, 100.0 * totalVAL(tot_ASLABS, u_int) / totalVAL(tot_SLABS, u_int));
|
2015-07-21 10:30:00 +05:30
|
|
|
PRINT_line(" %-35s: %u / %u (%.1f%%)\n"
|
2015-07-11 10:30:00 +05:30
|
|
|
, /* xgettext:no-c-format */
|
|
|
|
_("Active / Total Caches (% used)")
|
2016-08-10 17:38:09 +05:30
|
|
|
, totalVAL(tot_ACACHES, u_int)
|
|
|
|
, totalVAL(tot_CACHES, u_int)
|
|
|
|
, 100.0 * totalVAL(tot_ACACHES, u_int) / totalVAL(tot_CACHES, u_int));
|
2015-07-11 10:30:00 +05:30
|
|
|
PRINT_line(" %-35s: %.2fK / %.2fK (%.1f%%)\n"
|
|
|
|
, /* xgettext:no-c-format */
|
|
|
|
_("Active / Total Size (% used)")
|
2016-08-10 17:38:09 +05:30
|
|
|
, totalVAL(tot_ACTIVE, ul_int) / 1024.0
|
|
|
|
, totalVAL(tot_TOTAL, ul_int) / 1024.0
|
|
|
|
, 100.0 * totalVAL(tot_ACTIVE, ul_int) / totalVAL(tot_TOTAL, ul_int));
|
2015-07-11 10:30:00 +05:30
|
|
|
PRINT_line(" %-35s: %.2fK / %.2fK / %.2fK\n\n"
|
|
|
|
, _("Minimum / Average / Maximum Object")
|
2016-08-10 17:38:09 +05:30
|
|
|
, totalVAL(tot_MIN, u_int) / 1024.0
|
|
|
|
, totalVAL(tot_AVG, u_int) / 1024.0
|
|
|
|
, totalVAL(tot_MAX, u_int) / 1024.0);
|
|
|
|
#undef totalVAL
|
2004-01-25 04:03:56 +05:30
|
|
|
}
|
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
static void print_headings (void)
|
2004-01-25 04:03:56 +05:30
|
|
|
{
|
2015-07-11 10:30:00 +05:30
|
|
|
/* Translation Hint: Please keep alignment of the
|
|
|
|
* following intact. */
|
|
|
|
PRINT_line("%-78s\n", _(" OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME"));
|
2004-01-25 04:03:56 +05:30
|
|
|
}
|
|
|
|
|
2016-06-05 10:30:00 +05:30
|
|
|
static void print_details (struct slabinfo_stack *stack)
|
2004-01-25 04:03:56 +05:30
|
|
|
{
|
2016-08-10 17:38:09 +05:30
|
|
|
#define nodeVAL(e,t) SLABINFO_VAL(e, t, stack, Slab_info)
|
2015-07-21 10:30:00 +05:30
|
|
|
PRINT_line("%6u %6u %3u%% %7.2fK %6u %8u %9luK %-23s\n"
|
2016-08-10 17:38:09 +05:30
|
|
|
, nodeVAL(nod_OBJS, u_int)
|
|
|
|
, nodeVAL(nod_AOBJS, u_int)
|
|
|
|
, nodeVAL(nod_USE, u_int)
|
|
|
|
, nodeVAL(nod_OSIZE, u_int) / 1024.0
|
|
|
|
, nodeVAL(nod_SLABS, u_int)
|
|
|
|
, nodeVAL(nod_OPS, u_int)
|
|
|
|
, nodeVAL(nod_SIZE, ul_int) / 1024
|
|
|
|
, nodeVAL(nod_NAME, str));
|
2015-07-11 10:30:00 +05:30
|
|
|
|
|
|
|
return;
|
2016-08-10 17:38:09 +05:30
|
|
|
#undef nodeVAL
|
2015-07-11 10:30:00 +05:30
|
|
|
}
|
2015-07-04 10:29:59 +05:30
|
|
|
|
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2016-06-05 10:30:00 +05:30
|
|
|
int is_tty, rc = EXIT_SUCCESS;
|
2015-07-11 10:30:00 +05:30
|
|
|
unsigned short old_rows;
|
2004-01-25 04:03:56 +05:30
|
|
|
|
2013-02-20 23:01:48 +05:30
|
|
|
#ifdef HAVE_PROGRAM_INVOCATION_NAME
|
2015-07-04 10:29:59 +05:30
|
|
|
program_invocation_name = program_invocation_short_name;
|
2013-02-20 23:01:48 +05:30
|
|
|
#endif
|
2015-07-04 10:29:59 +05:30
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
textdomain(PACKAGE);
|
|
|
|
atexit(close_stdout);
|
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
parse_opts(argc, argv);
|
2015-07-04 10:29:59 +05:30
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
if (procps_slabinfo_new(&Slab_info) < 0)
|
2016-06-05 10:30:00 +05:30
|
|
|
xerr(EXIT_FAILURE, _("Unable to create slabinfo structure"));
|
2015-07-04 10:29:59 +05:30
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
if (!Run_once) {
|
|
|
|
is_tty = isatty(STDIN_FILENO);
|
|
|
|
if (is_tty && tcgetattr(STDIN_FILENO, &Saved_tty) == -1)
|
|
|
|
xwarn(_("terminal setting retrieval"));
|
|
|
|
old_rows = Rows;
|
|
|
|
term_resize(0);
|
2015-07-04 10:29:59 +05:30
|
|
|
initscr();
|
2015-07-11 10:30:00 +05:30
|
|
|
resizeterm(Rows, Cols);
|
|
|
|
signal(SIGWINCH, term_resize);
|
|
|
|
signal(SIGINT, sigint_handler);
|
2015-07-04 10:29:59 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
2016-06-05 10:30:00 +05:30
|
|
|
struct slabinfo_reap *reaped;
|
2015-07-04 10:29:59 +05:30
|
|
|
struct timeval tv;
|
|
|
|
fd_set readfds;
|
2015-07-11 10:30:00 +05:30
|
|
|
int i;
|
2015-07-04 10:29:59 +05:30
|
|
|
|
2016-06-05 10:30:00 +05:30
|
|
|
if (!(reaped = procps_slabinfo_reap(Slab_info, Node_items, MAXTBL(Node_items)))) {
|
2015-07-11 10:30:00 +05:30
|
|
|
xwarn(_("Unable to get slabinfo node data"));
|
|
|
|
rc = EXIT_FAILURE;
|
2015-07-04 10:29:59 +05:30
|
|
|
break;
|
|
|
|
}
|
2016-06-05 10:30:00 +05:30
|
|
|
|
2016-06-09 10:30:00 +05:30
|
|
|
if (!(procps_slabinfo_sort(Slab_info, reaped->stacks, reaped->total, Sort_item, Sort_Order))) {
|
2015-07-11 10:30:00 +05:30
|
|
|
xwarn(_("Unable to sort slab nodes"));
|
|
|
|
rc = EXIT_FAILURE;
|
|
|
|
break;
|
2015-07-04 10:29:59 +05:30
|
|
|
}
|
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
if (Run_once) {
|
|
|
|
print_summary();
|
|
|
|
print_headings();
|
2016-06-05 10:30:00 +05:30
|
|
|
for (i = 0; i < reaped->total; i++)
|
|
|
|
print_details(reaped->stacks[i]);
|
2015-07-04 10:29:59 +05:30
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
if (old_rows != Rows) {
|
|
|
|
resizeterm(Rows, Cols);
|
|
|
|
old_rows = Rows;
|
|
|
|
}
|
|
|
|
move(0, 0);
|
|
|
|
print_summary();
|
2015-07-04 10:29:59 +05:30
|
|
|
attron(A_REVERSE);
|
2015-07-11 10:30:00 +05:30
|
|
|
print_headings();
|
2015-07-04 10:29:59 +05:30
|
|
|
attroff(A_REVERSE);
|
|
|
|
|
2016-06-05 10:30:00 +05:30
|
|
|
for (i = 0; i < Rows - 8 && i < reaped->total; i++)
|
|
|
|
print_details(reaped->stacks[i]);
|
2015-07-11 10:30:00 +05:30
|
|
|
|
|
|
|
refresh();
|
|
|
|
FD_ZERO(&readfds);
|
|
|
|
FD_SET(STDIN_FILENO, &readfds);
|
|
|
|
tv.tv_sec = Delay;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
if (select(STDOUT_FILENO, &readfds, NULL, NULL, &tv) > 0) {
|
|
|
|
char c;
|
|
|
|
if (read(STDIN_FILENO, &c, 1) != 1
|
|
|
|
|| (c == 'Q' || c == 'q'))
|
2015-07-04 10:29:59 +05:30
|
|
|
break;
|
2016-06-09 10:30:00 +05:30
|
|
|
set_sort_stuff(c);
|
2015-07-04 10:29:59 +05:30
|
|
|
}
|
2015-07-11 10:30:00 +05:30
|
|
|
// made zero by sigint_handler()
|
|
|
|
} while (Delay);
|
2015-07-04 10:29:59 +05:30
|
|
|
|
2015-07-11 10:30:00 +05:30
|
|
|
if (!Run_once) {
|
|
|
|
if (is_tty)
|
|
|
|
tcsetattr(STDIN_FILENO, TCSAFLUSH, &Saved_tty);
|
|
|
|
endwin();
|
|
|
|
}
|
|
|
|
procps_slabinfo_unref(&Slab_info);
|
|
|
|
return rc;
|
2004-01-25 04:03:56 +05:30
|
|
|
}
|