Bootmem handling means how memory is allocated at boottime prior to paging start. This initial allocator allocates memory in page granular allocations. The bootmem allocator in Linux handles this by maintaining a bitmap large enough for accommodating all the low-memory pages (>896 MB) in the system. Each bit in the bitmap represents one page and its index in the bitmap represents the page frame number. A value of 0 in any bit in the bitmap indicates the corresponding page is free, and 1 indicates that the page is in use. Later in the startup code, the bootmem allocator bitmap is used to determine which memory pages are in use. The corresponding page structures are marked as reserved. After paging is enabled, the bootmem allocator is not needed. So the allocator bitmap is freed.
The important functions here are
Note: The 'prefered' and 'goal' variables are used to specify the position from where __alloc_bootmem() should start searching. This is useful if the caller does not want to get DMA-able memory (first 16MB physical memory).
Actually, Bootmem allocation requests need not be in multiples of PAGE_SIZE, any 'size' argument is valid. But the minimum allocation unit is a page (since only 1 bit is maintained per page). So there is a good chance that memory gets fragmented. To avoid this, the bootmem allocator re-uses fragments of the last allocation whenever possible. It keeps track of the unused portion the last allocated page (using last_offset). For the next allocation, it uses this part first.