內存管理之bootmem管理之標記內存


主要有mark_bootmem_node和mark_bootmem兩個函數


static int __init mark_bootmem_node(bootmem_data_t *bdata,
unsigned long start, unsigned long end,
int reserve, int flags)

{
unsigned long sidx, eidx;

bdebug("nid=%td start=%lx end=%lx reserve=%d flags=%x\n",
bdata - bootmem_node_data, start, end, reserve, flags);

BUG_ON(start < bdata->node_min_pfn);
BUG_ON(end > bdata->node_low_pfn);

sidx = start - bdata->node_min_pfn;
eidx = end - bdata->node_min_pfn;

if (reserve)
return __reserve(bdata, sidx, eidx, flags);
else
__free(bdata, sidx, eidx);
return 0;
}



static int __init mark_bootmem(unsigned long start, unsigned long end,
int reserve, int flags)

{
unsigned long pos;
bootmem_data_t *bdata;

pos = start;
list_for_each_entry(bdata, &bdata_list, list) {
int err;
unsigned long max;

if (pos < bdata->node_min_pfn ||
   pos >= bdata->node_low_pfn) {
BUG_ON(pos != start);
continue;
}

max = min(bdata->node_low_pfn, end);

err = mark_bootmem_node(bdata, pos, max, reserve, flags);
if (reserve && err) {
mark_bootmem(start, pos, 0, 0);
return err;
}

if (max == end)
return 0;
pos = bdata->node_low_pfn;
}
BUG();
}




                                
                                                                
                           
                            

0 個評論

要回覆文章請先登錄註冊