Commit 4978db5b authored by David S. Miller's avatar David S. Miller

lmb: Fix inconsistent alignment of size argument.

When allocating, if we will align up the size when making
the reservation, we should also align the size for the
check that the space is actually available.

The simplest thing is to just aling the size up from
the beginning, then we can use plain 'size' throughout.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 94d149c3
...@@ -286,8 +286,7 @@ static u64 __init lmb_alloc_nid_unreserved(u64 start, u64 end, ...@@ -286,8 +286,7 @@ static u64 __init lmb_alloc_nid_unreserved(u64 start, u64 end,
j = lmb_overlaps_region(&lmb.reserved, base, size); j = lmb_overlaps_region(&lmb.reserved, base, size);
if (j < 0) { if (j < 0) {
/* this area isn't reserved, take it */ /* this area isn't reserved, take it */
if (lmb_add_region(&lmb.reserved, base, if (lmb_add_region(&lmb.reserved, base, size) < 0)
lmb_align_up(size, align)) < 0)
base = ~(u64)0; base = ~(u64)0;
return base; return base;
} }
...@@ -333,6 +332,10 @@ u64 __init lmb_alloc_nid(u64 size, u64 align, int nid, ...@@ -333,6 +332,10 @@ u64 __init lmb_alloc_nid(u64 size, u64 align, int nid,
struct lmb_region *mem = &lmb.memory; struct lmb_region *mem = &lmb.memory;
int i; int i;
BUG_ON(0 == size);
size = lmb_align_up(size, align);
for (i = 0; i < mem->cnt; i++) { for (i = 0; i < mem->cnt; i++) {
u64 ret = lmb_alloc_nid_region(&mem->region[i], u64 ret = lmb_alloc_nid_region(&mem->region[i],
nid_range, nid_range,
...@@ -370,6 +373,8 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr) ...@@ -370,6 +373,8 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
BUG_ON(0 == size); BUG_ON(0 == size);
size = lmb_align_up(size, align);
/* On some platforms, make sure we allocate lowmem */ /* On some platforms, make sure we allocate lowmem */
/* Note that LMB_REAL_LIMIT may be LMB_ALLOC_ANYWHERE */ /* Note that LMB_REAL_LIMIT may be LMB_ALLOC_ANYWHERE */
if (max_addr == LMB_ALLOC_ANYWHERE) if (max_addr == LMB_ALLOC_ANYWHERE)
...@@ -393,8 +398,7 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr) ...@@ -393,8 +398,7 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
j = lmb_overlaps_region(&lmb.reserved, base, size); j = lmb_overlaps_region(&lmb.reserved, base, size);
if (j < 0) { if (j < 0) {
/* this area isn't reserved, take it */ /* this area isn't reserved, take it */
if (lmb_add_region(&lmb.reserved, base, if (lmb_add_region(&lmb.reserved, base, size) < 0)
lmb_align_up(size, align)) < 0)
return 0; return 0;
return base; return base;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment