zalloc project

James Cook falsifian at falsifian.org
Fri May 14 10:00:00 PDT 2021


Hi all,

I'm interested in getting my feet wet with kernel programming, and was
happy to find the projects page at
https://www.dragonflybsd.org/docs/developer/ProjectsPage/

I saw the "remove zalloc" project, and was thinking of trying to remove
zalloc from /sys/vm/swap_pager.c. Is this still considered worth doing?

If so, I will have a bunch of questions. If someone has the patience to
help me through this, it would make me very happy! (Even if the end
result doesn't get committed, I'll still have learned something.) I'd
also be happy to be pointed to a different project.

Questions:

1. I think switching to kmalloc would work, but would waste space,
   since allocations are rounded up to a power of 2. Is that right?

   (kmalloc might also be slower, but swap is super-slow anyway
   compared to main memory access, so I don't know if speed matters.)

2. The projects page says the existing uses can be changed to objcache.
   If that's the case, how exactly should objcache be used? Would it
   need a new allocator?

   I guess objcache_malloc_alloc isn't good because kmalloc wastes
   space.

   The man page suggests objcache_nop_alloc for "allocation policies
   that pre-allocate at initialization time instead of doing run-time
   allocation". I guess this is not good either because we should be
   able to allocate more memory if swap use grows.

   Does this mean a new objcache allocator should be written that
   allocates big chunks like zalloc?

-- 
James



More information about the Kernel mailing list