Hi Juan, Here is the patch cleaned up to apply to your current tree. I omitted the #ifdef notyet parts because they're already fixed by the patch I sent yesterday. https://www.redhat.com/archives/fedora-xen/2006-August/msg00019.html Regards, Aron # HG changeset patch # User agriffis@xxxxxxxxxxxxxxx # Node ID 8040a45ec900fda375346157f4028da57bb62e20 # Parent 33a2d3fb09120f3c9342ddeba2c20200571de75b 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 33a2d3fb0912 -r 8040a45ec900 arch/ia64/kernel/setup.c --- a/arch/ia64/kernel/setup.c Wed Aug 02 22:25:15 2006 -0400 +++ b/arch/ia64/kernel/setup.c Thu Aug 03 17:17:14 2006 -0400 @@ -196,21 +196,75 @@ 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]; rsvd_region[j + 1] = tmp; } } + } + + for (j = 0; j < num; j++) { + printk("rsvd_region[%d]: [0x%016lx, 0x%06lx)\n", + j, rsvd_region[j].start, rsvd_region[j].end); + } + + 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; + for (k = j + 1; k < j + 1 + collapsed; k++) { + rsvd_region[k] = rsvd_region[k + collapsed]; + } + num -= collapsed; + } + + num_rsvd_regions = num; + for (j = 0; j < num; j++) { + printk("rsvd_region[%d]: [0x%016lx, 0x%06lx)\n", + j, rsvd_region[j].start, rsvd_region[j].end); } } -- Fedora-xen@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-xen