]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
blst_leaf_alloc updates bighint for a leaf when an allocation is successful
authorAlan Cox <alc@FreeBSD.org>
Sun, 9 Dec 2018 17:55:10 +0000 (17:55 +0000)
committerAlan Cox <alc@FreeBSD.org>
Sun, 9 Dec 2018 17:55:10 +0000 (17:55 +0000)
commit2905d1ceaf7415c3860c99366cf77d68b6ba8276
tree960f02ef1190ebba1e3638afefd58596eeb1e7bf
parentdac6a0d559271be959ba2fbf10693e1fce36a7c6
blst_leaf_alloc updates bighint for a leaf when an allocation is successful
and includes the last block represented by the leaf.  The reasoning is that,
if the last block is included, then there must be no solution before that
one in the leaf, so the leaf cannot provide an allocation that big again;
indeed, the leaf cannot provide a solution bigger than range1.

Which is all correct, except that if the value of blk passed in did not
represent the first block of the leaf, because the cursor was pointing to
the middle of the leaf, then a possible solution before the cursor may have
been ignored, and bighint cannot be updated.

Consider the sequence allocate 63 (returning address 0), free 0,63 (freeing
that same block, and allocate 1 (returning 63).  The result is that one
block is allocated from the first leaf, and the value of bighint is 0, so
that nothing can be allocated from that leaf until the only block allocated
from that leaf is freed.  This change detects that skipped-over solution,
and when there is one it makes sure that the value of bighint is not changed
when the last block is allocated.

Submitted by: Doug Moore <dougm@rice.edu>
Tested by: pho
X-MFC with: r340402
Differential Revision: https://reviews.freebsd.org/D18474
sys/kern/subr_blist.c