* Licensed under GPLv2, see file LICENSE in this source tree.
*/
-//applet:IF_MPSTAT(APPLET(mpstat, _BB_DIR_BIN, _BB_SUID_DROP))
+//applet:IF_MPSTAT(APPLET(mpstat, BB_DIR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_MPSTAT) += mpstat.o
//config: Per-processor statistics
#include "libbb.h"
-#include <sys/utsname.h> /* struct utsname */
+#include <sys/utsname.h> /* struct utsname */
//#define debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
#define debug(fmt, ...) ((void)0)
* We are printing headers in the " IRQNAME/s" form, experimentally
* anything smaller than 10 chars looks ugly for /proc/softirqs stats.
*/
-#define INTRATE_SCRWIDTH 10
+#define INTRATE_SCRWIDTH 10
#define INTRATE_SCRWIDTH_STR "10"
/* System files */
-#define SYSFS_DEVCPU "/sys/devices/system/cpu"
#define PROCFS_STAT "/proc/stat"
#define PROCFS_INTERRUPTS "/proc/interrupts"
#define PROCFS_SOFTIRQS "/proc/softirqs"
while (irq < irqs_per_cpu) {
/* Number of interrupts per CPU has changed */
ic = &per_cpu_stats[current][irq];
- ic->irq_name[0] = '\0'; /* False interrupt */
+ ic->irq_name[0] = '\0'; /* False interrupt */
irq++;
}
}
/* Initialization */
-/* Get number of clock ticks per sec */
-static ALWAYS_INLINE unsigned get_hz(void)
-{
- return sysconf(_SC_CLK_TCK);
-}
-
static void alloc_struct(int cpus)
{
int i;
unsigned irq;
fp = fopen_for_read(f);
- if (!fp) /* No interrupts file */
+ if (!fp) /* No interrupts file */
return 0;
linelen = INTERRUPTS_LINE + 16 * G.cpu_nr;
//usage: "[-A] [-I SUM|CPU|ALL|SCPU] [-u] [-P num|ALL] [INTERVAL [COUNT]]"
//usage:#define mpstat_full_usage "\n\n"
//usage: "Per-processor statistics\n"
-//usage: "\nOptions:"
//usage: "\n -A Same as -I ALL -u -P ALL"
//usage: "\n -I SUM|CPU|ALL|SCPU Report interrupt statistics"
//usage: "\n -P num|ALL Processor to monitor"
char *opt_set_cpu;
int i, opt;
enum {
- OPT_ALL = 1 << 0, /* -A */
- OPT_INTS = 1 << 1, /* -I */
- OPT_SETCPU = 1 << 2, /* -P */
- OPT_UTIL = 1 << 3, /* -u */
+ OPT_ALL = 1 << 0, /* -A */
+ OPT_INTS = 1 << 1, /* -I */
+ OPT_SETCPU = 1 << 2, /* -P */
+ OPT_UTIL = 1 << 3, /* -u */
};
/* Dont buffer data if redirected to a pipe */
G.cpu_nr = get_cpu_count();
/* Get number of clock ticks per sec */
- G.hz = get_hz();
+ G.hz = bb_clk_tck();
/* Calculate number of interrupts per processor */
G.irqcpu_nr = get_irqcpu_nr(PROCFS_INTERRUPTS, NR_IRQS) + NR_IRQCPU_PREALLOC;