diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-21 20:53:50 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-21 20:53:50 +0000 |
commit | f6bad5ef766b0447158e3de2f55c35f1f6cecb58 (patch) | |
tree | f5ec7ac45234c25794c97f87e9a6daa8a551e57c /procps | |
parent | 72394258b6509b40e0fa08594ac86215a558dfd8 (diff) | |
parent | 8d0e0cdadf726beab28ccdc7d69738c1534e1f74 (diff) | |
download | busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.tar.gz busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.tar.bz2 busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.zip |
Merge commit '8d0e0cdadf726beab28ccdc7d69738c1534e1f74' into merge
Conflicts:
include/platform.h
libbb/Kbuild.src
libbb/messages.c
Diffstat (limited to 'procps')
-rw-r--r-- | procps/free.c | 2 | ||||
-rw-r--r-- | procps/fuser.c | 2 | ||||
-rw-r--r-- | procps/iostat.c | 2 | ||||
-rw-r--r-- | procps/mpstat.c | 2 | ||||
-rw-r--r-- | procps/nmeter.c | 2 | ||||
-rw-r--r-- | procps/pmap.c | 2 | ||||
-rw-r--r-- | procps/powertop.c | 2 | ||||
-rw-r--r-- | procps/pstree.c | 2 | ||||
-rw-r--r-- | procps/smemcap.c | 2 | ||||
-rw-r--r-- | procps/top.c | 62 |
10 files changed, 64 insertions, 16 deletions
diff --git a/procps/free.c b/procps/free.c index efbac5ba6..ad8711f8a 100644 --- a/procps/free.c +++ b/procps/free.c | |||
@@ -19,7 +19,7 @@ struct globals { | |||
19 | #else | 19 | #else |
20 | # define G_unit_steps 10 | 20 | # define G_unit_steps 10 |
21 | #endif | 21 | #endif |
22 | }; | 22 | } FIX_ALIASING; |
23 | #define G (*(struct globals*)&bb_common_bufsiz1) | 23 | #define G (*(struct globals*)&bb_common_bufsiz1) |
24 | #define INIT_G() do { } while (0) | 24 | #define INIT_G() do { } while (0) |
25 | 25 | ||
diff --git a/procps/fuser.c b/procps/fuser.c index addf1a7d8..a1b93d77f 100644 --- a/procps/fuser.c +++ b/procps/fuser.c | |||
@@ -35,7 +35,7 @@ typedef struct pid_list { | |||
35 | struct globals { | 35 | struct globals { |
36 | pid_list *pid_list_head; | 36 | pid_list *pid_list_head; |
37 | inode_list *inode_list_head; | 37 | inode_list *inode_list_head; |
38 | }; | 38 | } FIX_ALIASING; |
39 | #define G (*(struct globals*)&bb_common_bufsiz1) | 39 | #define G (*(struct globals*)&bb_common_bufsiz1) |
40 | #define INIT_G() do { } while (0) | 40 | #define INIT_G() do { } while (0) |
41 | 41 | ||
diff --git a/procps/iostat.c b/procps/iostat.c index a9ff13a05..06a33eb1d 100644 --- a/procps/iostat.c +++ b/procps/iostat.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //applet:IF_IOSTAT(APPLET(iostat, _BB_DIR_BIN, _BB_SUID_DROP)) | 10 | //applet:IF_IOSTAT(APPLET(iostat, BB_DIR_BIN, BB_SUID_DROP)) |
11 | 11 | ||
12 | //kbuild:lib-$(CONFIG_IOSTAT) += iostat.o | 12 | //kbuild:lib-$(CONFIG_IOSTAT) += iostat.o |
13 | 13 | ||
diff --git a/procps/mpstat.c b/procps/mpstat.c index 25efedf62..d643c999f 100644 --- a/procps/mpstat.c +++ b/procps/mpstat.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //applet:IF_MPSTAT(APPLET(mpstat, _BB_DIR_BIN, _BB_SUID_DROP)) | 10 | //applet:IF_MPSTAT(APPLET(mpstat, BB_DIR_BIN, BB_SUID_DROP)) |
11 | 11 | ||
12 | //kbuild:lib-$(CONFIG_MPSTAT) += mpstat.o | 12 | //kbuild:lib-$(CONFIG_MPSTAT) += mpstat.o |
13 | 13 | ||
diff --git a/procps/nmeter.c b/procps/nmeter.c index ac019eb53..48b56a399 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c | |||
@@ -12,7 +12,7 @@ | |||
12 | //config: help | 12 | //config: help |
13 | //config: Prints selected system stats continuously, one line per update. | 13 | //config: Prints selected system stats continuously, one line per update. |
14 | 14 | ||
15 | //applet:IF_NMETER(APPLET(nmeter, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 15 | //applet:IF_NMETER(APPLET(nmeter, BB_DIR_USR_BIN, BB_SUID_DROP)) |
16 | 16 | ||
17 | //kbuild:lib-$(CONFIG_NMETER) += nmeter.o | 17 | //kbuild:lib-$(CONFIG_NMETER) += nmeter.o |
18 | 18 | ||
diff --git a/procps/pmap.c b/procps/pmap.c index bb5f9e7c2..7f7f391b9 100644 --- a/procps/pmap.c +++ b/procps/pmap.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * for details. | 8 | * for details. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | //applet:IF_PMAP(APPLET(pmap, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 11 | //applet:IF_PMAP(APPLET(pmap, BB_DIR_USR_BIN, BB_SUID_DROP)) |
12 | //kbuild:lib-$(CONFIG_PMAP) += pmap.o | 12 | //kbuild:lib-$(CONFIG_PMAP) += pmap.o |
13 | 13 | ||
14 | //config:config PMAP | 14 | //config:config PMAP |
diff --git a/procps/powertop.c b/procps/powertop.c index 2f977a03b..bfe5a9568 100644 --- a/procps/powertop.c +++ b/procps/powertop.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * Licensed under GPLv2, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2, see file LICENSE in this source tree. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | //applet:IF_POWERTOP(APPLET(powertop, _BB_DIR_BIN, _BB_SUID_DROP)) | 12 | //applet:IF_POWERTOP(APPLET(powertop, BB_DIR_BIN, BB_SUID_DROP)) |
13 | 13 | ||
14 | //kbuild:lib-$(CONFIG_POWERTOP) += powertop.o | 14 | //kbuild:lib-$(CONFIG_POWERTOP) += powertop.o |
15 | 15 | ||
diff --git a/procps/pstree.c b/procps/pstree.c index 180d0939a..ddf5dba59 100644 --- a/procps/pstree.c +++ b/procps/pstree.c | |||
@@ -16,7 +16,7 @@ | |||
16 | //config: help | 16 | //config: help |
17 | //config: Display a tree of processes. | 17 | //config: Display a tree of processes. |
18 | 18 | ||
19 | //applet:IF_PSTREE(APPLET(pstree, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 19 | //applet:IF_PSTREE(APPLET(pstree, BB_DIR_USR_BIN, BB_SUID_DROP)) |
20 | 20 | ||
21 | //kbuild:lib-$(CONFIG_PSTREE) += pstree.o | 21 | //kbuild:lib-$(CONFIG_PSTREE) += pstree.o |
22 | 22 | ||
diff --git a/procps/smemcap.c b/procps/smemcap.c index 200df6795..e108d88ad 100644 --- a/procps/smemcap.c +++ b/procps/smemcap.c | |||
@@ -8,7 +8,7 @@ | |||
8 | herein by reference. | 8 | herein by reference. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | //applet:IF_SMEMCAP(APPLET(smemcap, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 11 | //applet:IF_SMEMCAP(APPLET(smemcap, BB_DIR_USR_BIN, BB_SUID_DROP)) |
12 | 12 | ||
13 | //kbuild:lib-$(CONFIG_SMEMCAP) += smemcap.o | 13 | //kbuild:lib-$(CONFIG_SMEMCAP) += smemcap.o |
14 | 14 | ||
diff --git a/procps/top.c b/procps/top.c index f9106fac7..ee6555188 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -19,9 +19,9 @@ | |||
19 | * | 19 | * |
20 | * Sept 2008: Vineet Gupta <vineet.gupta@arc.com> | 20 | * Sept 2008: Vineet Gupta <vineet.gupta@arc.com> |
21 | * Added Support for reporting SMP Information | 21 | * Added Support for reporting SMP Information |
22 | * - CPU where Process was last seen running | 22 | * - CPU where process was last seen running |
23 | * (to see effect of sched_setaffinity() etc) | 23 | * (to see effect of sched_setaffinity() etc) |
24 | * - CPU Time Split (idle/IO/wait etc) PER CPU | 24 | * - CPU time split (idle/IO/wait etc) per CPU |
25 | * | 25 | * |
26 | * Copyright (c) 1992 Branko Lankester | 26 | * Copyright (c) 1992 Branko Lankester |
27 | * Copyright (c) 1992 Roger Binns | 27 | * Copyright (c) 1992 Roger Binns |
@@ -30,6 +30,25 @@ | |||
30 | * | 30 | * |
31 | * Licensed under GPLv2, see file LICENSE in this source tree. | 31 | * Licensed under GPLv2, see file LICENSE in this source tree. |
32 | */ | 32 | */ |
33 | /* How to snapshot /proc for debugging top problems: | ||
34 | * for f in /proc/[0-9]*""/stat; do | ||
35 | * n=${f#/proc/} | ||
36 | * n=${n%/stat}_stat | ||
37 | * cp $f $n | ||
38 | * done | ||
39 | * cp /proc/stat /proc/meminfo /proc/loadavg . | ||
40 | * top -bn1 >top.out | ||
41 | * | ||
42 | * ...and how to run top on it on another machine: | ||
43 | * rm -rf proc; mkdir proc | ||
44 | * for f in [0-9]*_stat; do | ||
45 | * p=${f%_stat} | ||
46 | * mkdir -p proc/$p | ||
47 | * cp $f proc/$p/stat | ||
48 | * done | ||
49 | * cp stat meminfo loadavg proc | ||
50 | * chroot . ./top -bn1 >top1.out | ||
51 | */ | ||
33 | 52 | ||
34 | #include "libbb.h" | 53 | #include "libbb.h" |
35 | 54 | ||
@@ -519,7 +538,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
519 | 538 | ||
520 | /* what info of the processes is shown */ | 539 | /* what info of the processes is shown */ |
521 | printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width, | 540 | printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width, |
522 | " PID PPID USER STAT VSZ %MEM" | 541 | " PID PPID USER STAT VSZ %VSZ" |
523 | IF_FEATURE_TOP_SMP_PROCESS(" CPU") | 542 | IF_FEATURE_TOP_SMP_PROCESS(" CPU") |
524 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") | 543 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") |
525 | " COMMAND"); | 544 | " COMMAND"); |
@@ -537,7 +556,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
537 | # define FMT "%4u%%" | 556 | # define FMT "%4u%%" |
538 | #endif | 557 | #endif |
539 | /* | 558 | /* |
540 | * MEM% = s->vsz/MemTotal | 559 | * %VSZ = s->vsz/MemTotal |
541 | */ | 560 | */ |
542 | pmem_shift = BITS_PER_INT-11; | 561 | pmem_shift = BITS_PER_INT-11; |
543 | pmem_scale = UPSCALE*(1U<<(BITS_PER_INT-11)) / total_memory; | 562 | pmem_scale = UPSCALE*(1U<<(BITS_PER_INT-11)) / total_memory; |
@@ -546,7 +565,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
546 | pmem_scale /= 4; | 565 | pmem_scale /= 4; |
547 | pmem_shift -= 2; | 566 | pmem_shift -= 2; |
548 | } | 567 | } |
549 | pmem_half = (1U << pmem_shift) / (ENABLE_FEATURE_TOP_DECIMALS? 20 : 2); | 568 | pmem_half = (1U << pmem_shift) / (ENABLE_FEATURE_TOP_DECIMALS ? 20 : 2); |
550 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 569 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
551 | busy_jifs = cur_jif.busy - prev_jif.busy; | 570 | busy_jifs = cur_jif.busy - prev_jif.busy; |
552 | /* This happens if there were lots of short-lived processes | 571 | /* This happens if there were lots of short-lived processes |
@@ -577,7 +596,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
577 | pcpu_scale /= 4; | 596 | pcpu_scale /= 4; |
578 | pcpu_shift -= 2; | 597 | pcpu_shift -= 2; |
579 | } | 598 | } |
580 | pcpu_half = (1U << pcpu_shift) / (ENABLE_FEATURE_TOP_DECIMALS? 20 : 2); | 599 | pcpu_half = (1U << pcpu_shift) / (ENABLE_FEATURE_TOP_DECIMALS ? 20 : 2); |
581 | /* printf(" pmem_scale=%u pcpu_scale=%u ", pmem_scale, pcpu_scale); */ | 600 | /* printf(" pmem_scale=%u pcpu_scale=%u ", pmem_scale, pcpu_scale); */ |
582 | #endif | 601 | #endif |
583 | 602 | ||
@@ -597,7 +616,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
597 | sprintf(vsz_str_buf, "%6ldm", s->vsz/1024); | 616 | sprintf(vsz_str_buf, "%6ldm", s->vsz/1024); |
598 | else | 617 | else |
599 | sprintf(vsz_str_buf, "%7ld", s->vsz); | 618 | sprintf(vsz_str_buf, "%7ld", s->vsz); |
600 | /* PID PPID USER STAT VSZ %MEM [%CPU] COMMAND */ | 619 | /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */ |
601 | col = snprintf(line_buf, scr_width, | 620 | col = snprintf(line_buf, scr_width, |
602 | "\n" "%5u%6u %-8.8s %s%s" FMT | 621 | "\n" "%5u%6u %-8.8s %s%s" FMT |
603 | IF_FEATURE_TOP_SMP_PROCESS(" %3d") | 622 | IF_FEATURE_TOP_SMP_PROCESS(" %3d") |
@@ -833,6 +852,35 @@ enum { | |||
833 | | PSSCAN_COMM, | 852 | | PSSCAN_COMM, |
834 | }; | 853 | }; |
835 | 854 | ||
855 | //usage:#if ENABLE_FEATURE_SHOW_THREADS || ENABLE_FEATURE_TOP_SMP_CPU | ||
856 | //usage:# define IF_SHOW_THREADS_OR_TOP_SMP(...) __VA_ARGS__ | ||
857 | //usage:#else | ||
858 | //usage:# define IF_SHOW_THREADS_OR_TOP_SMP(...) | ||
859 | //usage:#endif | ||
860 | //usage:#define top_trivial_usage | ||
861 | //usage: "[-b] [-nCOUNT] [-dSECONDS]" IF_FEATURE_TOPMEM(" [-m]") | ||
862 | //usage:#define top_full_usage "\n\n" | ||
863 | //usage: "Provide a view of process activity in real time." | ||
864 | //usage: "\n""Read the status of all processes from /proc each SECONDS" | ||
865 | //usage: "\n""and display a screenful of them." | ||
866 | //usage: "\n""Keys:" | ||
867 | //usage: "\n"" N/M" | ||
868 | //usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/P") | ||
869 | //usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/T") | ||
870 | //usage: ": " IF_FEATURE_TOPMEM("show CPU usage, ") "sort by pid/mem" | ||
871 | //usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/cpu") | ||
872 | //usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/time") | ||
873 | //usage: IF_FEATURE_TOPMEM( | ||
874 | //usage: "\n"" S: show memory, R: reverse memory sort" | ||
875 | //usage: ) | ||
876 | //usage: IF_SHOW_THREADS_OR_TOP_SMP( | ||
877 | //usage: "\n"" " | ||
878 | //usage: IF_FEATURE_SHOW_THREADS("H: toggle threads") | ||
879 | //usage: IF_FEATURE_SHOW_THREADS(IF_FEATURE_TOP_SMP_CPU(", ")) | ||
880 | //usage: IF_FEATURE_TOP_SMP_CPU("1: toggle SMP") | ||
881 | //usage: ) | ||
882 | //usage: "\n"" Q,^C: exit" | ||
883 | |||
836 | int top_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 884 | int top_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
837 | int top_main(int argc UNUSED_PARAM, char **argv) | 885 | int top_main(int argc UNUSED_PARAM, char **argv) |
838 | { | 886 | { |