Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24308
b: refs/heads/master
c: 679bc9f
h: refs/heads/master
v: v3
  • Loading branch information
KAMEZAWA Hiroyuki authored and Linus Torvalds committed Mar 27, 2006
1 parent 0f6ae45 commit c51f58c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8357f8695d58b50fbf2bd507b4b0fc2cd1e43bd6
refs/heads/master: 679bc9fbb508a0aac9539b2de747eb5849feb428
1 change: 1 addition & 0 deletions trunk/include/linux/bootmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef struct bootmem_data {
unsigned long last_pos;
unsigned long last_success; /* Previous allocation point. To speed
* up searching */
struct list_head list;
} bootmem_data_t;

extern unsigned long __init bootmem_bootmap_pages (unsigned long);
Expand Down
39 changes: 29 additions & 10 deletions trunk/mm/bootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ EXPORT_SYMBOL(max_pfn); /* This is exported so
* dma_get_required_mask(), which uses
* it, can be an inline function */

static LIST_HEAD(bdata_list);
#ifdef CONFIG_CRASH_DUMP
/*
* If we have booted due to a crash, max_pfn will be a very low value. We need
Expand All @@ -52,6 +53,27 @@ unsigned long __init bootmem_bootmap_pages (unsigned long pages)

return mapsize;
}
/*
* link bdata in order
*/
static void link_bootmem(bootmem_data_t *bdata)
{
bootmem_data_t *ent;
if (list_empty(&bdata_list)) {
list_add(&bdata->list, &bdata_list);
return;
}
/* insert in order */
list_for_each_entry(ent, &bdata_list, list) {
if (bdata->node_boot_start < ent->node_boot_start) {
list_add_tail(&bdata->list, &ent->list);
return;
}
}
list_add_tail(&bdata->list, &bdata_list);
return;
}


/*
* Called once to set up the allocator itself.
Expand All @@ -62,13 +84,11 @@ static unsigned long __init init_bootmem_core (pg_data_t *pgdat,
bootmem_data_t *bdata = pgdat->bdata;
unsigned long mapsize = ((end - start)+7)/8;

pgdat->pgdat_next = pgdat_list;
pgdat_list = pgdat;

mapsize = ALIGN(mapsize, sizeof(long));
bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT);
bdata->node_boot_start = (start << PAGE_SHIFT);
bdata->node_low_pfn = end;
link_bootmem(bdata);

/*
* Initially all pages are reserved - setup_arch() has to
Expand Down Expand Up @@ -383,12 +403,11 @@ unsigned long __init free_all_bootmem (void)

void * __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned long goal)
{
pg_data_t *pgdat = pgdat_list;
bootmem_data_t *bdata;
void *ptr;

for_each_pgdat(pgdat)
if ((ptr = __alloc_bootmem_core(pgdat->bdata, size,
align, goal, 0)))
list_for_each_entry(bdata, &bdata_list, list)
if ((ptr = __alloc_bootmem_core(bdata, size, align, goal, 0)))
return(ptr);

/*
Expand Down Expand Up @@ -416,11 +435,11 @@ void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, unsigne

void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, unsigned long goal)
{
pg_data_t *pgdat = pgdat_list;
bootmem_data_t *bdata;
void *ptr;

for_each_pgdat(pgdat)
if ((ptr = __alloc_bootmem_core(pgdat->bdata, size,
list_for_each_entry(bdata, &bdata_list, list)
if ((ptr = __alloc_bootmem_core(bdata, size,
align, goal, LOW32LIMIT)))
return(ptr);

Expand Down

0 comments on commit c51f58c

Please sign in to comment.