6351771b7c
BT_MAXALLOC (4) is the number of boundary tags required to complete an allocation in the worst case: two to clip a free segment, and two to import from a parent arena. vmem_xalloc() preallocates four boundary tags before attempting a search to simplify the segment allocation code. It implements a loop that: 1) ensures that BT_MAXALLOC boundary tags are available, 2) attempts to find and clip a free segment satisfying the allocation constraints, and failing that, 3) attempts to import a segment. On !UMA_MD_SMALL_ALLOC platforms the btag zone has to handle recusion: it needs boundary tags to allocate boundary tags. Thus we reserve 2 * BT_MAXALLOC * mp_ncpus tags for use when recursing: the factor of 2 is because there are two layers of vmem arenas, the per-domain arena and global arena. For a single thread, 2 * BT_MAXALLOC tags should be sufficient. Because of the way the loop is structured, BT_MAXALLOC tags are not sufficient. The first bt_fill() call may allocate BT_MAXALLOC tags, then import a segment (consuming two tags), then attempt to top up the preallocation before carving into the imported free segment, thus requiring up to six tags in the worst case. Because we don't preallocate that many, this bug can cause deadlocks in rare scenarios. Fix the problem by moving the preallocation out the loop. This assumes that only a single import is ever required to satisfy an allocation request. Thanks to manu, emaste and lwhsu for helping test debug patches. Reported by: Jenkins (hardware CI lab) Reviewed by: alc, kib, rlibby MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26770 |
||
---|---|---|
.. | ||
amd64 | ||
arm | ||
arm64 | ||
bsm | ||
cam | ||
cddl | ||
compat | ||
conf | ||
contrib | ||
crypto | ||
ddb | ||
dev | ||
dts | ||
fs | ||
gdb | ||
geom | ||
gnu | ||
i386 | ||
isa | ||
kern | ||
kgssapi | ||
libkern | ||
mips | ||
modules | ||
net | ||
net80211 | ||
netgraph | ||
netinet | ||
netinet6 | ||
netipsec | ||
netpfil | ||
netsmb | ||
nfs | ||
nfsclient | ||
nfsserver | ||
nlm | ||
ofed | ||
opencrypto | ||
powerpc | ||
riscv | ||
rpc | ||
security | ||
sys | ||
teken | ||
tests | ||
tools | ||
ufs | ||
vm | ||
x86 | ||
xdr | ||
xen | ||
Makefile |