Commit graph

688 commits

Author SHA1 Message Date
Denys Vlasenko
0b05a4e71e top,pmap: speed up /smaps parsing
function                                             old     new   delta
procps_read_smaps                                    515     529     +14
procps_get_maps                                      685     665     -20
.rodata                                           105847  105820     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 14/-47)            Total: -33 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06 14:42:06 +02:00
Denys Vlasenko
40c2d01da2 libbb: make read_cmdline() replace chars 1..31 with '?', not space
Space was too inconspicuous on output

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06 14:02:05 +02:00
Denys Vlasenko
8bde71eb15 top: simplify command line reading
function                                             old     new   delta
cmdline_to_line_buf_and_print                          -      48     +48
read_cmdline                                         326     327      +1
display_topmem_process_list                          523     505     -18
display_process_list                                1186    1161     -25
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/2 up/down: 49/-43)              Total: 6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06 00:42:05 +02:00
Denys Vlasenko
1bd8d714ca top: disentangle printing logic
function                                             old     new   delta
print_line_buf                                         -      78     +78
print_line_bold                                        -      50     +50
top_main                                            1043    1091     +48
handle_input                                         708     714      +6
do_stats                                             186     192      +6
.rodata                                           115543  115526     -17
display_topmem_process_list                          748     523    -225
display_process_list                                1432    1186    -246
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/3 up/down: 188/-488)         Total: -300 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06 00:05:44 +02:00
Denys Vlasenko
2363938883 top: consistently NOT use the last column of the display
function                                             old     new   delta
.rodata                                           115537  115543      +6
top_main                                            1047    1043      -4
display_process_list                                1459    1432     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 6/-31)             Total: -25 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05 19:37:43 +02:00
Denys Vlasenko
5a8c03039f pmap: increase max handled command line length to 4k
function                                             old     new   delta
procps_get_maps                                      181     779    +598
read_smaps                                           563       -    -563
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 598/-563)           Total: 35 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05 14:35:14 +02:00
Denys Vlasenko
d16bde623c top,pmap: do not use common code for reading /proc/PID/smaps
The logic is in fact quite far from common.

While at it, stop accounting "---p" mappings as mapped (e.g. VSZ in top).
Nothing is mapped there (why would kernel waste RAM to map pages
which can't be accessed?).

function                                             old     new   delta
read_smaps                                             -     562    +562
read_cmdline                                         315     326     +11
print_smaprec                                         97     101      +4
procps_scan                                         1219    1211      -8
.rodata                                           115541  115533      -8
skip_whitespace_if_prefixed_with                      25       -     -25
procps_read_smaps                                    864     577    -287
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/3 up/down: 577/-328)          Total: 249 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05 14:21:51 +02:00
Denys Vlasenko
58b2353baa top: improve response time to keyboard input
function                                             old     new   delta
handle_input                                         674     708     +34
top_main                                            1019    1047     +28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 62/0)               Total: 62 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05 04:30:59 +02:00
Denys Vlasenko
3aa2bee269 top: reduce flicker: redraw screen with "clear to EOL" commands, not one "clear screen"
function                                             old     new   delta
display_topmem_process_list                          680     748     +68
display_process_list                                1403    1459     +56
.rodata                                           115512  115541     +29
top_main                                            1014    1019      +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 158/0)             Total: 158 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05 03:40:36 +02:00
Denys Vlasenko
1044533ea9 top: make uppercase 'S' walk topmem in opposite direction
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05 03:13:01 +02:00
Denys Vlasenko
d647d8aaba top: show RSS instead of VSF, virtual mapped size is often meaningless
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05 03:07:40 +02:00
Denys Vlasenko
c229982b33 top: fix display of very large VSZ
function                                             old     new   delta
display_process_list                                1366    1403     +37
handle_input                                         628     636      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 45/0)               Total: 45 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05 02:57:05 +02:00
Denys Vlasenko
c1b5c35246 top: do not rescan processes on second 's'
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05 01:25:01 +02:00
Denys Vlasenko
b20b3790b4 powertop: code shrink
function                                             old     new   delta
print_intel_cstates                                  477     475      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-13 11:46:15 +02:00
Denys Vlasenko
28f4126093 top: improve large PID display in memory ('s') mode
Display VSZ[RW] fields in more compact form if PID is wider.

function                                             old     new   delta
display_topmem_process_list                          564     614     +50
ulltoa5_and_space                                      -      14     +14
ulltoa6_and_space                                     14       -     -14
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/0 up/down: 64/-14)             Total: 50 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-11-23 01:18:02 +01:00
Denys Vlasenko
5353df91cb Update applet size estimates
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-10 17:25:21 +02:00
Denys Vlasenko
648f506949 libbb: code shrink: introduce and use [_]exit_FAILURE()
function                                             old     new   delta
exit_FAILURE                                           -       7      +7
_exit_FAILURE                                          -       7      +7
run                                                  198     199      +1
restore_state_and_exit                               114     115      +1
xbsd_write_bootstrap                                 399     397      -2
vfork_compressor                                     209     207      -2
sig_handler                                           12      10      -2
serial_ctl                                           154     152      -2
parse_args                                          1169    1167      -2
onintr                                                21      19      -2
make_new_session                                     493     491      -2
login_main                                           988     986      -2
gotsig                                                35      33      -2
do_iplink                                           1315    1313      -2
addgroup_main                                        397     395      -2
inetd_main                                          1911    1908      -3
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/12 up/down: 16/-25)            Total: -9 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-15 11:55:56 +02:00
Denys Vlasenko
c6058d221a nmeter: improve %T fractionals display
function                                             old     new   delta
nmeter_main                                          751     786     +35

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-07 18:35:22 +02:00
Denys Vlasenko
05f2bedaeb ash: sleep builtin with no arguments should not exit
function                                             old     new   delta
sleep_main                                           116     143     +27
.rodata                                           105245  105268     +23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 50/0)               Total: 50 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03 19:54:42 +02:00
Denys Vlasenko
669c40ed8e top: stop using div() from libc, compilers now do it better
function                                             old     new   delta
div                                                   23       -     -23
display_process_list                                1237    1178     -59
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-82)             Total: -82 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-02-13 15:05:19 +01:00
Denys Vlasenko
c2739e11de nmeter: increase maximum /proc file size (needed for large machines)
function                                             old     new   delta
get_file                                             185     201     +16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-24 12:47:32 +01:00
Denys Vlasenko
99476502f9 Remove "select PLATFORM_LINUX"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-11-29 14:14:06 +01:00
Samuel Thibault
77216c368f Fix non-Linux builds
Various tools are Linuxish and should thus only attempted to build on
Linux only. Some features are also Linux-only.

Also, libresolv is used on all GNU platforms, notably GNU/Hurd and
GNU/kfreeBSD.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-11-29 14:10:22 +01:00
Louis Sautier
707a7ef4c7 pkill: add -e to display the name and PID of the process being killed
This mimics the behaviour of pkill -e / --echo from procps.

function                                             old     new   delta
.rodata                                           105179  105200     +21
packed_usage                                       34523   34516      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 21/-7)              Total: 14 bytes

Signed-off-by: Louis Sautier <sautier.louis@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-10-14 14:33:34 +02:00
Denys Vlasenko
fe73c8d557 *: style fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-08-30 16:41:17 +02:00
Denys Vlasenko
8d67007a4d top: improve large PID display in memory ('s') mode
function                                             old     new   delta
display_topmem_process_list                          530     564     +34

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-12 11:44:47 +02:00
Denys Vlasenko
1099a27696 top: code shrink
function                                             old     new   delta
display_process_list                                1186    1168     -18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-10 14:04:34 +02:00
Denys Vlasenko
69f82e305b top: code shrink
function                                             old     new   delta
display_process_list                                1191    1186      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-10 13:51:09 +02:00
Denys Vlasenko
294881d2e9 top: fix display of large PID/PPID
function                                             old     new   delta
display_process_list                                1077    1191    +114
.rodata                                           104803  104807      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 118/0)             Total: 118 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-10 12:56:28 +02:00
Denys Vlasenko
987be932ed *: slap on a few ALIGN_PTR where appropriate
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-02-06 20:07:12 +01:00
Denys Vlasenko
12566e7f9b ash,hush: fix handling of SIGINT while waiting for interactive input
function                                             old     new   delta
lineedit_read_key                                    160     237     +77
__pgetc                                              522     589     +67
fgetc_interactive                                    244     309     +65
safe_read_key                                          -      39     +39
read_key                                             588     607     +19
record_pending_signo                                  23      32      +9
signal_handler                                        75      81      +6
.rodata                                           104312  104309      -3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 6/1 up/down: 282/-3)            Total: 279 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-17 11:46:23 +01:00
Denys Vlasenko
524fecf7c3 nmeter: %[md] %[mw] - dirty file-backed pages, writeback pages
function                                             old     new   delta
collect_mem                                          333     387     +54
.rodata                                           104369  104380     +11
packed_usage                                       34184   34175      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 65/-9)              Total: 56 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-11 19:32:16 +01:00
Denys Vlasenko
89092c61bc powertop: fix cpuid asm: ebx saving/restoring is properly done by gcc
function                                             old     new   delta
print_intel_cstates                                  481     477      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-07 01:33:46 +01:00
Denys Vlasenko
94c78aa0b9 config system: move some options closer to relevalnt tool subdirectories
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-12 13:23:29 +02:00
Denys Vlasenko
eb048a450c ps: fix -o pid=PID,args interpreting entire "PID,args" as header
procps-ng 3.3.15 does not do this.
(It could, allowing commas in headers and requiring
"ps -opid=PID -oargs" form for this case, but it does not).

function                                             old     new   delta
parse_o                                              167     190     +23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-07 21:55:16 +02:00
YU Jincheng
1f925038ab *: generalize "const trick"
While at it, change all "__asm__" to "asm"

Co-authored-by: canyie <31466456+canyie@users.noreply.github.com>
Signed-off-by: YU Jincheng <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-07 15:22:35 +02:00
Denys Vlasenko
62d5a1e56f tar,smemcap: commonalyze checksumming code for tar header
function                                             old     new   delta
chksum_and_xwrite_tar_header                           -      99     +99
writeheader                                          280     199     -81
chksum_and_xwrite                                    102       -    -102
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/1 up/down: 99/-183)           Total: -84 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-20 17:58:49 +02:00
Denys Vlasenko
dc30f3dce2 free: implement -h
function                                             old     new   delta
.rodata                                           103331  103363     +32
packed_usage                                       33652   33654      +2
free_main                                            657     588     -69
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 34/-69)            Total: -35 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-18 12:08:02 +02:00
Denys Vlasenko
57be5daa40 lsof: print fd# too
function                                             old     new   delta
lsof_main                                            179     188      +9
.rodata                                           103194  103187      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-16 12:49:15 +02:00
Denys Vlasenko
1f60d88cf6 *: more --help tweaks
function                                             old     new   delta
packed_usage                                       33552   33541     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-15 10:00:18 +02:00
Denys Vlasenko
e2b9215868 *: --help tweaks
function                                             old     new   delta
packed_usage                                       33589   33552     -37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-14 20:47:20 +02:00
Denys Vlasenko
6f7b10cdab *: more --help tweaking
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-13 03:51:55 +02:00
Denys Vlasenko
1849285a20 *: more --help tweaks, mostly expanding ts --help
function                                             old     new   delta
packed_usage                                       33554   33596     +42

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-13 03:12:09 +02:00
Denys Vlasenko
6b6826f0b8 *: --help tweaks
function                                             old     new   delta
.rodata                                           103190  103189      -1
packed_usage                                       33590   33566     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-25)             Total: -25 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-13 01:08:48 +02:00
Ron Yorston
cad3fc743a libbb: introduce and use fputs_stdout
function                                             old     new   delta
fputs_stdout                                           -      12     +12
zxc_vm_process                                      7237    7230      -7
yes_main                                              85      78      -7
write_block                                          380     373      -7
wrapf                                                305     298      -7
strings_main                                         437     430      -7
show_bridge                                          353     346      -7
rev_main                                             384     377      -7
put_prompt_custom                                     58      51      -7
put_cur_glyph_and_inc_cursor                         168     161      -7
print_numbered_lines                                 152     145      -7
print_named_ascii                                    130     123      -7
print_name                                           135     128      -7
print_login_issue                                    386     379      -7
print_ascii                                          208     201      -7
powertop_main                                       1249    1242      -7
od_main                                             1789    1782      -7
logread_main                                         518     511      -7
head_main                                            804     797      -7
display_process_list                                1319    1312      -7
cut_main                                            1002     995      -7
bb_dump_dump                                        1550    1543      -7
bb_ask_noecho                                        393     386      -7
baseNUM_main                                         702     695      -7
expand_main                                          755     745     -10
dumpleases_main                                      497     487     -10
write1                                                12       -     -12
putcsi                                                37      23     -14
print_login_prompt                                    55      41     -14
paste_main                                           525     511     -14
cat_main                                             440     426     -14
print_it                                             245     230     -15
print_addrinfo                                      1188    1171     -17
print_rule                                           770     750     -20
print_linkinfo                                       842     822     -20
httpd_main                                           791     771     -20
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/34 up/down: 12/-341)         Total: -329 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-03 20:52:40 +01:00
Denys Vlasenko
2266c12a79 pmap: fix column width, closes 13431
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-01-05 19:39:34 +01:00
Denys Vlasenko
3c13da3dab libbb: introduce and use xgettimeofday(), do not truncate 64-bit time_t in shells
function                                             old     new   delta
xgettimeofday                                          -      11     +11
get_local_var_value                                  280     281      +1
svlogd_main                                         1323    1322      -1
change_epoch                                          67      66      -1
timestamp_and_log                                    461     458      -3
hwclock_main                                         301     298      -3
fmt_time_bernstein_25                                135     132      -3
step_time                                            331     326      -5
script_main                                         1207    1202      -5
machtime                                              34      28      -6
curtime                                               61      54      -7
ts_main                                              423     415      -8
nmeter_main                                          761     751     -10
gettime1900d                                          67      46     -21
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/12 up/down: 12/-73)           Total: -61 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-30 23:48:01 +01:00
Denys Vlasenko
84d5eddb25 help text: replace [OPTIONS] with actual options (if not too long)
function                                             old     new   delta
packed_usage                                       33620   33665     +45

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 22:34:05 +01:00
Denys Vlasenko
965b795b87 decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly
text	   data	    bss	    dec	    hex	filename
1021988	    559	   5052	1027599	  fae0f	busybox_old
1021236	    559	   5052	1026847	  fab1f	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-30 13:03:03 +01:00
Denys Vlasenko
fc63549352 free: code shrink
function                                             old     new   delta
free_main                                            664     657      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-27 12:40:31 +01:00