Created attachment 191527 [details]
Patches to fix and improve mbuffer behavior on FreeBSD.
With no explicit counts set, mbuffer 2017.10.11 fails immediately on FreeBSD if the physical memory on the system > ~ 6GB and kern.ipc.semvmx is its default (32767 * 50 * 4096).
Steps to reproduce:
$ mbuffer -q < /dev/zero > /dev/null
mbuffer: fatal: cannot allocate more than 32767 blocks.
This is a system dependent limit, depending on the maximum semaphore value.
Please choose a bigger block size.
Attached is a patch to fix/improve this behavior. Will also submit upstream.
Fixed (settings.c): reads the wrong parameter (checked SysV, but wants posix semaphore limits), and into an uninitialized and wrong-sized variable with sysctlbyname. Completely remove that part and just use 'mxnrsem = sysconf(_SC_SEM_VALUE_MAX)' which returns the desired value (such that sem_init(,,<=mxnrsem) will not fail EINVAL). Tested on 11.1; I don't have a <= 10.x around to test. Removes almost all __FreeBSD__ switches from settings.c.
Fixed (mbuffer.c): Don't allow default setting to be invalid. Clamp Numblocks to mxnrsem.
Enhancement (mbuffer.c): Actually get free memory (similar value to the check of _SC_AVPHYS_PAGES used where available) rather than total system memory when calculating NumP/50 memory to use.
Now fixed upstream with revision 20180318.
Please update port version.
A commit references this bug:
Date: Mon Mar 19 06:11:49 UTC 2018
New revision: 464984
misc/mbuffer: Update to 20180318
- Fixes a bug where mbuffer would immediatly fail with no explicit
- Add TEST_TARGET
- Take maintainership after the last 6 months maintainer timeout from
Submitted by: eborisch+FreeBSD@gmail.com