本來想看完pagefault的處理的,不過實驗室有事情了,只能先把這一半放上來了。
頁面的分配與回收使用了一個叫做buddy allocator的機制,kernelnewbies上的解釋The memory allocation scheme used in the kernel. A vector of lists of free pages is kept, ordered by the size of the chunk (in powers of two). When a chunk is allocated, it is removed from the relevant list. When a chunk is freed back to the free pages pool, it is placed in the relevant list, starting from the top. If it is physically contiguous with a present chunk, they are merged and placed in the list above (i.e. where the chunks are twice the size), and this operation percolates up the vector. As regions are merged whenever possible, this design helps to reduce memory fragmentation.首先在zone_struct{} 中保存了一個free_area_t數組,這個數組記錄了各種大小的空閑內存塊的信息。include/linux/mmzone.h:
Powered by: BlogJava Copyright © ZelluX