[git commit] libbb: reduce the overhead of single parameter bb_error_msg() calls

Denys Vlasenko vda.linux at googlemail.com
Tue Jul 2 09:35:03 UTC 2019


commit: https://git.busybox.net/busybox/commit/?id=6937487be73cd4563b876413277a295a5fe2f32c
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().

This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.

Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.

This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.

The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):

Arm:     -92 bytes
MIPS:    -52 bytes
PPC:   -1836 bytes
x86_64: -938 bytes

Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.

Signed-off-by: James Byrne <james.byrne at origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 Config.in                                   | 13 ++++++++
 archival/bbunzip.c                          |  2 +-
 archival/bzip2.c                            |  4 +--
 archival/dpkg.c                             | 14 ++++----
 archival/gzip.c                             |  4 +--
 archival/libarchive/data_extract_all.c      |  4 +--
 archival/libarchive/decompress_bunzip2.c    |  2 +-
 archival/libarchive/decompress_gunzip.c     | 14 ++++----
 archival/libarchive/decompress_uncompress.c | 10 +++---
 archival/libarchive/decompress_unlzma.c     |  6 ++--
 archival/libarchive/decompress_unxz.c       |  4 +--
 archival/libarchive/get_header_ar.c         |  8 ++---
 archival/libarchive/get_header_cpio.c       |  6 ++--
 archival/libarchive/get_header_tar.c        | 14 ++++----
 archival/libarchive/open_transformer.c      |  6 ++--
 archival/libarchive/seek_by_jump.c          |  2 +-
 archival/libarchive/unpack_ar_archive.c     |  2 +-
 archival/lzop.c                             | 14 ++++----
 archival/rpm.c                              |  2 +-
 archival/tar.c                              | 10 +++---
 archival/unzip.c                            | 18 +++++------
 console-tools/loadfont.c                    | 20 ++++++------
 console-tools/loadkmap.c                    |  2 +-
 console-tools/openvt.c                      |  4 +--
 console-tools/showkey.c                     |  2 +-
 coreutils/cp.c                              |  4 +--
 coreutils/cut.c                             |  6 ++--
 coreutils/date.c                            |  2 +-
 coreutils/df.c                              |  2 +-
 coreutils/echo.c                            |  2 +-
 coreutils/env.c                             |  2 +-
 coreutils/expand.c                          |  2 +-
 coreutils/expr.c                            | 16 ++++-----
 coreutils/id.c                              |  2 +-
 coreutils/install.c                         |  2 +-
 coreutils/ln.c                              |  2 +-
 coreutils/logname.c                         |  2 +-
 coreutils/md5_sha1_sum.c                    |  2 +-
 coreutils/od_bloaty.c                       | 12 +++----
 coreutils/paste.c                           |  2 +-
 coreutils/printf.c                          |  2 +-
 coreutils/rm.c                              |  2 +-
 coreutils/sort.c                            | 12 +++----
 coreutils/split.c                           |  4 +--
 coreutils/stty.c                            |  6 ++--
 coreutils/tail.c                            |  4 +--
 coreutils/test.c                            |  4 +--
 coreutils/tr.c                              |  4 +--
 coreutils/uudecode.c                        |  8 ++---
 coreutils/uuencode.c                        |  2 +-
 debianutils/start_stop_daemon.c             |  4 +--
 e2fsprogs/chattr.c                          |  6 ++--
 e2fsprogs/fsck.c                            |  6 ++--
 editors/awk.c                               |  4 +--
 editors/diff.c                              |  4 +--
 editors/ed.c                                | 34 ++++++++++----------
 editors/patch_bbox.c                        |  6 ++--
 editors/patch_toybox.c                      |  2 +-
 editors/sed.c                               | 18 +++++------
 editors/vi.c                                |  2 +-
 findutils/find.c                            |  4 +--
 findutils/xargs.c                           |  4 +--
 include/libbb.h                             | 45 +++++++++++++++++++++++++-
 init/bootchartd.c                           |  2 +-
 init/init.c                                 |  2 +-
 libbb/appletlib.c                           | 10 +++---
 libbb/bb_getgroups.c                        |  2 +-
 libbb/bbunit.c                              |  2 +-
 libbb/capability.c                          |  2 +-
 libbb/change_identity.c                     |  2 +-
 libbb/copy_file.c                           |  2 +-
 libbb/copyfd.c                              |  6 ++--
 libbb/die_if_bad_username.c                 |  2 +-
 libbb/dump.c                                |  4 +--
 libbb/fflush_stdout_and_exit.c              |  2 +-
 libbb/get_console.c                         |  2 +-
 libbb/get_volsize.c                         |  4 +--
 libbb/getpty.c                              |  6 ++--
 libbb/herror_msg.c                          | 10 ++++++
 libbb/mtab.c                                |  4 +--
 libbb/perror_nomsg.c                        |  4 +--
 libbb/perror_nomsg_and_die.c                |  4 +--
 libbb/read_printf.c                         |  2 +-
 libbb/safe_poll.c                           |  2 +-
 libbb/selinux_common.c                      |  2 +-
 libbb/time.c                                |  2 +-
 libbb/update_passwd.c                       |  4 +--
 libbb/uuencode.c                            |  2 +-
 libbb/verror_msg.c                          | 15 +++++++++
 libbb/warn_ignoring_args.c                  |  2 +-
 libbb/xconnect.c                            |  4 +--
 libbb/xfuncs.c                              |  2 +-
 libbb/xfuncs_printf.c                       | 44 ++++++++++++-------------
 libbb/xgetcwd.c                             |  2 +-
 libbb/xgethostbyname.c                      |  2 +-
 loginutils/addgroup.c                       |  2 +-
 loginutils/adduser.c                        |  4 +--
 loginutils/chpasswd.c                       |  4 +--
 loginutils/deluser.c                        |  2 +-
 loginutils/getty.c                          | 16 ++++-----
 loginutils/login.c                          |  4 +--
 loginutils/su.c                             |  4 +--
 loginutils/sulogin.c                        |  8 ++---
 mailutils/mail.c                            |  6 ++--
 mailutils/popmaildir.c                      |  2 +-
 mailutils/sendmail.c                        |  2 +-
 miscutils/bc.c                              | 12 +++----
 miscutils/chat.c                            |  2 +-
 miscutils/crond.c                           |  4 +--
 miscutils/crontab.c                         |  2 +-
 miscutils/dc.c                              |  4 +--
 miscutils/devfsd.c                          | 15 ++++++---
 miscutils/devmem.c                          |  8 ++---
 miscutils/fbsplash.c                        |  2 +-
 miscutils/flash_eraseall.c                  |  6 ++--
 miscutils/hdparm.c                          | 12 +++----
 miscutils/hexedit.c                         |  2 +-
 miscutils/i2c_tools.c                       | 44 ++++++++++++-------------
 miscutils/inotifyd.c                        |  2 +-
 miscutils/nandwrite.c                       | 10 +++---
 miscutils/rfkill.c                          |  2 +-
 miscutils/rx.c                              |  6 ++--
 miscutils/time.c                            |  2 +-
 miscutils/ubi_tools.c                       | 10 +++---
 miscutils/ubirename.c                       |  2 +-
 modutils/modutils-24.c                      | 26 +++++++--------
 modutils/rmmod.c                            |  2 +-
 networking/arp.c                            | 36 ++++++++++-----------
 networking/arping.c                         |  4 +--
 networking/dnsd.c                           |  8 ++---
 networking/ether-wake.c                     |  4 +--
 networking/ftpgetput.c                      |  2 +-
 networking/hostname.c                       |  2 +-
 networking/httpd.c                          | 10 +++---
 networking/ifconfig.c                       |  2 +-
 networking/ifplugd.c                        | 16 ++++-----
 networking/ifupdown.c                       |  4 +--
 networking/inetd.c                          | 20 ++++++------
 networking/ipcalc.c                         |  2 +-
 networking/isrv.c                           |  4 +--
 networking/libiproute/ipaddress.c           | 10 +++---
 networking/libiproute/ipneigh.c             |  8 ++---
 networking/libiproute/iproute.c             | 12 +++----
 networking/libiproute/iptunnel.c            | 10 +++---
 networking/libiproute/libnetlink.c          | 30 ++++++++---------
 networking/libiproute/utils.c               |  2 +-
 networking/nbd-client.c                     | 10 +++---
 networking/nc.c                             |  6 ++--
 networking/nc_bloaty.c                      | 18 +++++------
 networking/netstat.c                        |  4 +--
 networking/nslookup.c                       |  2 +-
 networking/ntpd.c                           | 20 ++++++------
 networking/ping.c                           | 16 ++++-----
 networking/route.c                          |  6 ++--
 networking/slattach.c                       |  4 +--
 networking/tcpudp.c                         |  6 ++--
 networking/telnetd.c                        |  2 +-
 networking/tftp.c                           | 10 +++---
 networking/tls.c                            | 14 ++++----
 networking/tls.h                            |  2 +-
 networking/traceroute.c                     |  6 ++--
 networking/udhcp/arpping.c                  |  4 +--
 networking/udhcp/common.c                   |  2 +-
 networking/udhcp/common.h                   | 19 +++++++++++
 networking/udhcp/d6_dhcpc.c                 | 34 ++++++++++----------
 networking/udhcp/d6_packet.c                |  4 +--
 networking/udhcp/d6_socket.c                |  2 +-
 networking/udhcp/dhcpc.c                    | 50 ++++++++++++++---------------
 networking/udhcp/dhcpd.c                    | 24 +++++++-------
 networking/udhcp/dhcprelay.c                |  4 +--
 networking/udhcp/packet.c                   |  4 +--
 networking/udhcp/signalpipe.c               |  2 +-
 networking/udhcp/socket.c                   |  2 +-
 networking/wget.c                           | 22 ++++++-------
 networking/zcip.c                           |  6 ++--
 printutils/lpr.c                            | 12 +++----
 procps/kill.c                               |  2 +-
 procps/mpstat.c                             |  2 +-
 procps/powertop.c                           |  4 +--
 procps/pstree.c                             |  2 +-
 procps/top.c                                |  2 +-
 runit/chpst.c                               |  6 ++--
 runit/svlogd.c                              |  2 +-
 selinux/chcon.c                             |  4 +--
 selinux/getenforce.c                        |  4 +--
 selinux/getsebool.c                         |  2 +-
 selinux/load_policy.c                       |  2 +-
 selinux/runcon.c                            |  6 ++--
 selinux/sestatus.c                          |  2 +-
 selinux/setenforce.c                        |  2 +-
 selinux/setfiles.c                          |  2 +-
 selinux/setsebool.c                         |  2 +-
 shell/hush.c                                | 32 +++++++++---------
 shell/shell_common.c                        |  2 +-
 sysklogd/klogd.c                            |  2 +-
 sysklogd/logread.c                          |  2 +-
 sysklogd/syslogd.c                          | 10 +++---
 util-linux/acpid.c                          |  2 +-
 util-linux/dmesg.c                          |  4 +--
 util-linux/eject.c                          |  2 +-
 util-linux/fdformat.c                       |  2 +-
 util-linux/fdisk.c                          |  2 +-
 util-linux/flock.c                          |  2 +-
 util-linux/fsck_minix.c                     |  2 +-
 util-linux/getopt.c                         |  6 ++--
 util-linux/hwclock.c                        |  4 +--
 util-linux/ipcs.c                           |  8 ++---
 util-linux/last.c                           |  2 +-
 util-linux/losetup.c                        |  4 +--
 util-linux/mdev.c                           | 10 ++++--
 util-linux/mesg.c                           |  2 +-
 util-linux/mkfs_ext2.c                      |  6 ++--
 util-linux/mkfs_minix.c                     | 22 ++++++-------
 util-linux/mkfs_reiser.c                    |  2 +-
 util-linux/mkfs_vfat.c                      |  6 ++--
 util-linux/mkswap.c                         |  2 +-
 util-linux/mount.c                          | 40 +++++++++++------------
 util-linux/nsenter.c                        |  2 +-
 util-linux/rdate.c                          |  6 ++--
 util-linux/readprofile.c                    |  4 +--
 util-linux/rtcwake.c                        |  2 +-
 util-linux/setpriv.c                        |  8 ++---
 util-linux/switch_root.c                    |  6 ++--
 util-linux/uevent.c                         |  4 +--
 util-linux/unshare.c                        |  2 +-
 225 files changed, 845 insertions(+), 736 deletions(-)

Patch is too large, so refusing to show it


More information about the busybox-cvs mailing list