Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 212703
b: refs/heads/master
c: 7f219c7
h: refs/heads/master
i:
  212701: 8de01b2
  212699: fcf1609
  212695: e5d3eb4
  212687: 193a178
  212671: 68e64af
v: v3
  • Loading branch information
Benjamin Herrenschmidt committed Aug 5, 2010
1 parent 2c2541c commit eb13386
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 21 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: 7590abe891c85fbc65dc906516d0bf89e070c19a
refs/heads/master: 7f219c736f9439acb1c50d264fbee93c353773ca
58 changes: 38 additions & 20 deletions trunk/mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,15 @@ phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int n

BUG_ON(0 == size);

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

/* We do a bottom-up search for a region with the right
* nid since that's easier considering how memblock_nid_range()
* works
*/
size = memblock_align_up(size, align);

for (i = 0; i < mem->cnt; i++) {
phys_addr_t ret = memblock_alloc_nid_region(&mem->regions[i],
size, align, nid);
Expand All @@ -366,29 +369,14 @@ phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align)
return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE);
}

phys_addr_t __init memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
{
phys_addr_t alloc;

alloc = __memblock_alloc_base(size, align, max_addr);

if (alloc == 0)
panic("ERROR: Failed to allocate 0x%llx bytes below 0x%llx.\n",
(unsigned long long) size, (unsigned long long) max_addr);

return alloc;
}

phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
static phys_addr_t __init memblock_find_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
{
long i;
phys_addr_t base = 0;
phys_addr_t res_base;

BUG_ON(0 == size);

size = memblock_align_up(size, align);

/* Pump up max_addr */
if (max_addr == MEMBLOCK_ALLOC_ACCESSIBLE)
max_addr = memblock.current_limit;
Expand All @@ -405,13 +393,43 @@ phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, ph
continue;
base = min(memblockbase + memblocksize, max_addr);
res_base = memblock_find_region(memblockbase, base, size, align);
if (res_base != MEMBLOCK_ERROR &&
memblock_add_region(&memblock.reserved, res_base, size) >= 0)
if (res_base != MEMBLOCK_ERROR)
return res_base;
}
return MEMBLOCK_ERROR;
}

phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
{
phys_addr_t found;

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

found = memblock_find_base(size, align, max_addr);
if (found != MEMBLOCK_ERROR &&
memblock_add_region(&memblock.reserved, found, size) >= 0)
return found;

return 0;
}

phys_addr_t __init memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
{
phys_addr_t alloc;

alloc = __memblock_alloc_base(size, align, max_addr);

if (alloc == 0)
panic("ERROR: Failed to allocate 0x%llx bytes below 0x%llx.\n",
(unsigned long long) size, (unsigned long long) max_addr);

return alloc;
}


/* You must call memblock_analyze() before this. */
phys_addr_t __init memblock_phys_mem_size(void)
{
Expand Down

0 comments on commit eb13386

Please sign in to comment.