Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 62441
b: refs/heads/master
c: a7e9662
h: refs/heads/master
i:
  62439: 0dbe477
v: v3
  • Loading branch information
David Rientjes authored and Linus Torvalds committed Jul 22, 2007
1 parent 2f83e14 commit 599bd07
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 38 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: bc2cea6a34fdb30f118ec75db39a46a191870607
refs/heads/master: a7e96629efcab1ccea3a376f3f5683c8d9e882c1
54 changes: 23 additions & 31 deletions trunk/arch/x86_64/kernel/e820.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,37 +193,6 @@ unsigned long __init e820_end_of_ram(void)
return end_pfn;
}

/*
* Find the hole size in the range.
*/
unsigned long __init e820_hole_size(unsigned long start, unsigned long end)
{
unsigned long ram = 0;
int i;

for (i = 0; i < e820.nr_map; i++) {
struct e820entry *ei = &e820.map[i];
unsigned long last, addr;

if (ei->type != E820_RAM ||
ei->addr+ei->size <= start ||
ei->addr >= end)
continue;

addr = round_up(ei->addr, PAGE_SIZE);
if (addr < start)
addr = start;

last = round_down(ei->addr + ei->size, PAGE_SIZE);
if (last >= end)
last = end;

if (last > addr)
ram += last - addr;
}
return ((end - start) - ram);
}

/*
* Mark e820 reserved areas as busy for the resource manager.
*/
Expand Down Expand Up @@ -364,6 +333,29 @@ void __init add_memory_region(unsigned long start, unsigned long size, int type)
e820.nr_map++;
}

/*
* Find the hole size (in bytes) in the memory range.
* @start: starting address of the memory range to scan
* @end: ending address of the memory range to scan
*/
unsigned long __init e820_hole_size(unsigned long start, unsigned long end)
{
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long end_pfn = end >> PAGE_SHIFT;
unsigned long ei_startpfn;
unsigned long ei_endpfn;
unsigned long ram = 0;
int i;

for (i = 0; i < e820.nr_map; i++) {
if (e820_find_active_region(&e820.map[i],
start_pfn, end_pfn,
&ei_startpfn, &ei_endpfn))
ram += ei_endpfn - ei_startpfn;
}
return end - start - (ram << PAGE_SHIFT);
}

void __init e820_print_map(char *who)
{
int i;
Expand Down
8 changes: 2 additions & 6 deletions trunk/arch/x86_64/mm/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ void __init numa_init_array(void)

#ifdef CONFIG_NUMA_EMU
/* Numa emulation */
#define E820_ADDR_HOLE_SIZE(start, end) \
(e820_hole_size((start) >> PAGE_SHIFT, (end) >> PAGE_SHIFT) << \
PAGE_SHIFT)
char *cmdline __initdata;

/*
Expand Down Expand Up @@ -319,7 +316,7 @@ static int __init split_nodes_equally(struct bootnode *nodes, u64 *addr,
return -1;
if (num_nodes > MAX_NUMNODES)
num_nodes = MAX_NUMNODES;
size = (max_addr - *addr - E820_ADDR_HOLE_SIZE(*addr, max_addr)) /
size = (max_addr - *addr - e820_hole_size(*addr, max_addr)) /
num_nodes;
/*
* Calculate the number of big nodes that can be allocated as a result
Expand Down Expand Up @@ -347,7 +344,7 @@ static int __init split_nodes_equally(struct bootnode *nodes, u64 *addr,
if (i == num_nodes + node_start - 1)
end = max_addr;
else
while (end - *addr - E820_ADDR_HOLE_SIZE(*addr, end) <
while (end - *addr - e820_hole_size(*addr, end) <
size) {
end += FAKE_NODE_MIN_SIZE;
if (end > max_addr) {
Expand Down Expand Up @@ -488,7 +485,6 @@ static int __init numa_emulation(unsigned long start_pfn, unsigned long end_pfn)
numa_init_array();
return 0;
}
#undef E820_ADDR_HOLE_SIZE
#endif /* CONFIG_NUMA_EMU */

void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
Expand Down

0 comments on commit 599bd07

Please sign in to comment.