full/empty terminology in _malloc.h

James Cook falsifian at falsifian.org
Tue May 18 16:19:48 PDT 2021


I'm confused about the meaning of "full" vs. "empty" slabs in
sys/sys/_malloc.h.


- The "full" field of kmalloc_mgt has fully free slabs.

- The "empty" field of kmalloc_mgt is for slabs with nothing free
  (though slots might open up later).


But then the comment above kmalloc_mgt seems to use the opposite sense:

- "we want to allocate from the most-full magazine to best reduce
  fragmentation"

That makes more sense (and matches whot _kmalloc_obj actually does) if
"full" means a slab has no more slots free.

And similarly:

- "The curmag list ... is loosely sorted ... the least-full magazine at
  the tail".

It looks like malloc_mgt_poll_empty_locked tries to keep the magazines
with the fewest empty slots toward the tail of ggm->empty. (I don't see
anything called curmag).


Are those opposite meanings or am I just confused?

(FWIW, I'd usually assume "full" means "no space available".)

-- 
James



More information about the Kernel mailing list