Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 108945
b: refs/heads/master
c: 481ebd0
h: refs/heads/master
i:
  108943: a4ae7d2
v: v3
  • Loading branch information
Johannes Weiner authored and Linus Torvalds committed Aug 20, 2008
1 parent b622423 commit f879e10
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 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: a09f48551273ee89d4e9ae37474807dc2da1d757
refs/heads/master: 481ebd0d76b501c5772f702ae31e55350c0858a3
35 changes: 29 additions & 6 deletions trunk/mm/bootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,29 @@ int __init reserve_bootmem(unsigned long addr, unsigned long size,
}
#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */

static unsigned long align_idx(struct bootmem_data *bdata, unsigned long idx,
unsigned long step)
{
unsigned long base = bdata->node_min_pfn;

/*
* Align the index with respect to the node start so that the
* combination of both satisfies the requested alignment.
*/

return ALIGN(base + idx, step) - base;
}

static unsigned long align_off(struct bootmem_data *bdata, unsigned long off,
unsigned long align)
{
unsigned long base = PFN_PHYS(bdata->node_min_pfn);

/* Same as align_idx for byte offsets */

return ALIGN(base + off, align) - base;
}

static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
unsigned long size, unsigned long align,
unsigned long goal, unsigned long limit)
Expand Down Expand Up @@ -441,7 +464,7 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
else
start = ALIGN(min, step);

sidx = start - bdata->node_min_pfn;;
sidx = start - bdata->node_min_pfn;
midx = max - bdata->node_min_pfn;

if (bdata->hint_idx > sidx) {
Expand All @@ -450,7 +473,7 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
* catch the fallback below.
*/
fallback = sidx + 1;
sidx = ALIGN(bdata->hint_idx, step);
sidx = align_idx(bdata, bdata->hint_idx, step);
}

while (1) {
Expand All @@ -459,23 +482,23 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
unsigned long eidx, i, start_off, end_off;
find_block:
sidx = find_next_zero_bit(bdata->node_bootmem_map, midx, sidx);
sidx = ALIGN(sidx, step);
sidx = align_idx(bdata, sidx, step);
eidx = sidx + PFN_UP(size);

if (sidx >= midx || eidx > midx)
break;

for (i = sidx; i < eidx; i++)
if (test_bit(i, bdata->node_bootmem_map)) {
sidx = ALIGN(i, step);
sidx = align_idx(bdata, i, step);
if (sidx == i)
sidx += step;
goto find_block;
}

if (bdata->last_end_off & (PAGE_SIZE - 1) &&
PFN_DOWN(bdata->last_end_off) + 1 == sidx)
start_off = ALIGN(bdata->last_end_off, align);
start_off = align_off(bdata, bdata->last_end_off, align);
else
start_off = PFN_PHYS(sidx);

Expand All @@ -499,7 +522,7 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
}

if (fallback) {
sidx = ALIGN(fallback - 1, step);
sidx = align_idx(bdata, fallback - 1, step);
fallback = 0;
goto find_block;
}
Expand Down

0 comments on commit f879e10

Please sign in to comment.