summaryrefslogtreecommitdiffstats
path: root/exec.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-07-07 12:28:43 -0400
committerTavian Barnes <tavianator@tavianator.com>2018-07-07 12:28:43 -0400
commit30b48746565be758f7014dce9448d8e91febab60 (patch)
treed5b590b482bf76ec60cd972fe5ea0794f052899f /exec.c
parent4e9a4cd67d050cfa997d66067f0a08c702e0c8d7 (diff)
downloadbfs-30b48746565be758f7014dce9448d8e91febab60.tar.xz
exec: Make ARG_MAX accounting a bit less restrictive with large pages
For Linux-style accounting, we really only need to handle a single page of wasted space due to rounding. Subtracting two pages for extra headroom was reasonable on systems with 4K pages, but overkill on systems like ppc64le with 64K pages. Worse yet was the fact that Alpine Linux only gives us 128K for arguments. Instead, only subtract a single page, plus the POSIX-recommended 2048 bytes. Credit to Mike Sullivan for the initial patch and testing on Alpine ppc64le. Fixes: http://build.alpinelinux.org/buildlogs/build-edge-ppc64le/testing/bfs/bfs-1.2.2-r0.log Co-authored-by: Mike Sullivan <mksully22@gmail.com>
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/exec.c b/exec.c
index 2b18ce8..d383935 100644
--- a/exec.c
+++ b/exec.c
@@ -90,13 +90,16 @@ static size_t bfs_exec_arg_max(const struct bfs_exec *execbuf) {
bfs_exec_debug(execbuf, "ARG_MAX: %ld remaining after fixed arguments\n", arg_max);
// Assume arguments are counted with the granularity of a single page,
- // and allow two pages of headroom to account for rounding as well as
- // any other data we may not be counting
+ // so allow a one page cushion to account for rounding up
long page_size = sysconf(_SC_PAGESIZE);
if (page_size < 4096) {
page_size = 4096;
}
- arg_max -= 2*page_size;
+ arg_max -= page_size;
+ bfs_exec_debug(execbuf, "ARG_MAX: %ld remaining after page cushion\n", arg_max);
+
+ // POSIX recommends an additional 2048 bytes of headroom
+ arg_max -= 2048;
bfs_exec_debug(execbuf, "ARG_MAX: %ld remaining after headroom\n", arg_max);
if (arg_max < 0) {