Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277144
b: refs/heads/master
c: e649804
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and H. Peter Anvin committed Jul 14, 2011
1 parent f3aa094 commit 2ebc60e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 26 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: 34e1845548418e5cecee0568ba721e1f089c092c
refs/heads/master: e64980405cc6aa74ef178d8d9aa4018c867ceed1
4 changes: 4 additions & 0 deletions trunk/include/linux/memblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ extern long memblock_reserve(phys_addr_t base, phys_addr_t size);
/* The numa aware allocator is only available if
* CONFIG_ARCH_POPULATES_NODE_MAP is set
*/
extern phys_addr_t memblock_find_in_range_node(phys_addr_t start,
phys_addr_t end,
phys_addr_t size,
phys_addr_t align, int nid);
extern phys_addr_t memblock_alloc_nid(phys_addr_t size, phys_addr_t align,
int nid);
extern phys_addr_t memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align,
Expand Down
57 changes: 32 additions & 25 deletions trunk/mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,49 +521,56 @@ static phys_addr_t __init memblock_nid_range_rev(phys_addr_t start,
return start;
}

static phys_addr_t __init memblock_alloc_nid_region(struct memblock_region *mp,
phys_addr_t __init memblock_find_in_range_node(phys_addr_t start,
phys_addr_t end,
phys_addr_t size,
phys_addr_t align, int nid)
{
phys_addr_t start, end;
struct memblock_type *mem = &memblock.memory;
int i;

start = mp->base;
end = start + mp->size;
BUG_ON(0 == size);

while (start < end) {
phys_addr_t this_start;
int this_nid;
/* Pump up max_addr */
if (end == MEMBLOCK_ALLOC_ACCESSIBLE)
end = memblock.current_limit;

this_start = memblock_nid_range_rev(start, end, &this_nid);
if (this_nid == nid) {
phys_addr_t ret = memblock_find_region(this_start, end, size, align);
if (ret &&
!memblock_add_region(&memblock.reserved, ret, size))
return ret;
for (i = mem->cnt - 1; i >= 0; i--) {
struct memblock_region *r = &mem->regions[i];
phys_addr_t base = max(start, r->base);
phys_addr_t top = min(end, r->base + r->size);

while (base < top) {
phys_addr_t tbase, ret;
int tnid;

tbase = memblock_nid_range_rev(base, top, &tnid);
if (nid == MAX_NUMNODES || tnid == nid) {
ret = memblock_find_region(tbase, top, size, align);
if (ret)
return ret;
}
top = tbase;
}
end = this_start;
}

return 0;
}

phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid)
{
struct memblock_type *mem = &memblock.memory;
int i;

BUG_ON(0 == size);
phys_addr_t found;

/* We align the size to limit fragmentation. Without this, a lot of
/*
* We align the size to limit fragmentation. Without this, a lot of
* small allocs quickly eat up the whole reserve array on sparc
*/
size = round_up(size, align);

for (i = mem->cnt - 1; i >= 0; i--) {
phys_addr_t ret = memblock_alloc_nid_region(&mem->regions[i],
size, align, nid);
if (ret)
return ret;
}
found = memblock_find_in_range_node(0, MEMBLOCK_ALLOC_ACCESSIBLE,
size, align, nid);
if (found && !memblock_add_region(&memblock.reserved, found, size))
return found;

return 0;
}
Expand Down

0 comments on commit 2ebc60e

Please sign in to comment.