[PATCH 08/11] resource: only return range with needed align

From: Yinghai Lu
Date: Wed May 23 2012 - 02:35:08 EST


Compare align between put range in head and tail, pick small one
to leave big one for future user.

Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>
---
kernel/resource.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index b4dae55..8277090 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -506,8 +506,20 @@ out:
}

if (!ret) {
- new->start = avail_start;
+ /* compare which one have max order */
+ new->start = round_down(avail_start + avail_size - size,
+ constraint->align);
+ new->end = avail_start + avail_size - 1;
+ new->start = constraint->alignf(constraint->alignf_data, new,
+ size, constraint->align);
new->end = new->start + size - 1;
+
+ if (new->start < avail_start ||
+ new->end > (avail_start + avail_size - 1) ||
+ __ffs64(new->start) >= __ffs64(avail_start)) {
+ new->start = avail_start;
+ new->end = new->start + size - 1;
+ }
}
return ret;
}
--
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/