Hi Aron. Thank you for cleaning up. However a bug was there. Here is the updated one. - removed debug print. - bug fix. Extents at the end can be discarded. - coding style clean up changeset: 34929:7ca328ac2929e1dfc19b298d7656e653a05d709b tag: tip user: yamahata@xxxxxxxxxxxxx date: Fri Aug 04 11:17:17 2006 +0900 files: arch/ia64/kernel/setup.c description: Compare both start and end when sorting rsvd_region list, then collapse overlapping regions. Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx> Signed-off-by: Aron Griffis <aron@xxxxxx> diff -r e677133a59a9c5313e6985e5ba63ff50aecec42c -r 7ca328ac2929e1dfc19b298d7656e653a05d709b arch/ia64/kernel/setup.c --- a/arch/ia64/kernel/setup.c Thu Aug 03 00:43:34 2006 +0200 +++ b/arch/ia64/kernel/setup.c Fri Aug 04 11:17:17 2006 +0900 @@ -194,15 +194,33 @@ filter_rsvd_memory (unsigned long start, return 0; } +static int __init +rsvd_region_cmp(struct rsvd_region *lhs, struct rsvd_region *rhs) +{ + if (lhs->start > rhs->start) + return 1; + if (lhs->start < rhs->start) + return -1; + + if (lhs->end > rhs->end) + return 1; + if (lhs->end < rhs->end) + return -1; + + return 0; +} + static void __init sort_regions (struct rsvd_region *rsvd_region, int max) { + int num = max; int j; /* simple bubble sorting */ while (max--) { for (j = 0; j < max; ++j) { - if (rsvd_region[j].start > rsvd_region[j+1].start) { + if (rsvd_region_cmp(&rsvd_region[j], + &rsvd_region[j + 1]) > 0) { struct rsvd_region tmp; tmp = rsvd_region[j]; rsvd_region[j] = rsvd_region[j + 1]; @@ -210,6 +228,31 @@ sort_regions (struct rsvd_region *rsvd_r } } } + + for (j = 0; j < num - 1; j++) { + int k; + unsigned long start = rsvd_region[j].start; + unsigned long end = rsvd_region[j].end; + int collapsed; + + for (k = j + 1; k < num; k++) { + BUG_ON(start > rsvd_region[k].start); + if (end < rsvd_region[k].start) { + k--; + break; + } + end = max(end, rsvd_region[k].end); + } + if (k == num) + k--; + rsvd_region[j].end = end; + collapsed = k - j; + num -= collapsed; + for (k = j + 1; k < num; k++) + rsvd_region[k] = rsvd_region[k + collapsed]; + } + + num_rsvd_regions = num; } /* -- yamahata -- Fedora-xen@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-xen