You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
During my recent work, I need to build an allocatorto manage a certain device's on-board DRAM (couple of GBs).Since everything in our system is page-sized, we used a buddy allocator for that purpose.
Due to time limitation, I directly ported a simplified version from linux kernel (mm/page_allo.c) into userspace.Algorithm-wise, a buddy allocator is simple. But a practical implementation adds some complications,as is the case for the kernel one.
I did some modificatons, e.g., remove a lot zone and accounting code, but kept its core.I decided to make it public, its linux's code anyway.
Why?
This port is generic/small, can beembedded into other designs.
Good start if you want to learn how Linux manages physical memory.
Tuning
Managed Physical Memory Range (without holes now):
/* * The managed physical memory range. * We do not allow any holes at this point. */unsigned longbuddy_mem_start=PAGE_SIZE;unsigned longbuddy_mem_end=1024*1024*1024;