Re: full/empty terminology in _malloc.h

Matthew Dillon <[email protected]> Tue, 18 May 2021 16:50:36 -0900
Newsgroups gmane.os.dragonfly-bsd.kernel
Message-ID <CAOZ7CpCtqEZv+W7o2ODYVQ80orJYi2Rx9YDDnZbHPavgLRC=0A@mail.gmail.com>
--000000000000384a2305c2a50e71
Content-Type: text/plain; charset="UTF-8"

Now onto malloc_mgt_poll_empty_locked().  This code should strictly keep
only empty magazines on the empty list and full magazines on the full
list.  Any partial magazines will be moved to the partial list.  The order
on the empty and full lists shouldn't matter at all.

The partial list is more problematic.  For that we dive into _kmalloc_obj()
itself.  It will allocate out of mgt->active first, then mgt->alternate.
If both are empty (have no objects available to allocate), then it pulls a
slab off of the (per-zone) global ggm->partial list, then ggm->full list,
then checks a few ggm->empty elements to see if any happen to have any
objects in them (the poller might not have moved them to the appropriate
list).

This is the part where we still have a fragmentation issue.  The
ggm->partial list is not sorted in any way and it would probably be best if
we took the 'most empty' of the slabs from the partial list to make the new
active instead of just taking the first one.  Scanning the whole partial
list would be expensive, but scanning a couple of slabs off of the partial
list might be beneficial.
-Matt

--000000000000384a2305c2a50e71
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Now onto malloc_mgt_poll_empty_locked().=C2=A0 This code s=
hould strictly keep only empty magazines on the empty list and full magazin=
es on the full list.=C2=A0 Any partial magazines will be moved to the parti=
al list.=C2=A0 The order on the empty and full lists shouldn&#39;t matter a=
t all.<div><br></div><div>The partial list is more problematic.=C2=A0 For t=
hat we dive into _kmalloc_obj() itself.=C2=A0 It will allocate out of mgt-&=
gt;active first, then mgt-&gt;alternate.=C2=A0 If both are empty (have no o=
bjects available to allocate), then it pulls a slab off of the (per-zone) g=
lobal ggm-&gt;partial list, then ggm-&gt;full list, then checks a few ggm-&=
gt;empty elements to see if any happen to have any objects in them (the pol=
ler might not have moved them to the appropriate list).</div><div><br></div=
><div>This is the part where we still have a fragmentation issue.=C2=A0 The=
 ggm-&gt;partial list is not sorted in any way and it would probably be bes=
t if we took the &#39;most empty&#39; of the slabs from the partial list to=
 make the new active instead of just taking the first one.=C2=A0 Scanning t=
he whole partial list would be expensive, but scanning a couple of slabs of=
f of the partial list might be beneficial.<br></div><div>-Matt</div></div>

--000000000000384a2305c2a50e71--