From 30b48746565be758f7014dce9448d8e91febab60 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 7 Jul 2018 12:28:43 -0400 Subject: 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 --- exec.c | 9 ++++++--- 1 file 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) { -- cgit v1.2.3