The patch titled hugetlb reservations: move region tracking earlier has been removed from the -mm tree. Its filename was hugetlb-move-reservation-region-support-earlier-fix.patch This patch was dropped because it was folded into hugetlb-move-reservation-region-support-earlier.patch The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: hugetlb reservations: move region tracking earlier From: Andy Whitcroft <apw@xxxxxxxxxxxx> Move the region tracking code much earlier so we can use it for page presence tracking later on. No code is changed, just its location. Signed-off-by: Andy Whitcroft <apw@xxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/hugetlb.c | 246 ++++++++++++++++++++++++------------------------- 1 file changed, 125 insertions(+), 121 deletions(-) diff -puN mm/hugetlb.c~hugetlb-move-reservation-region-support-earlier-fix mm/hugetlb.c --- a/mm/hugetlb.c~hugetlb-move-reservation-region-support-earlier-fix +++ a/mm/hugetlb.c @@ -41,6 +41,131 @@ static int hugetlb_next_nid; static DEFINE_SPINLOCK(hugetlb_lock); /* + * Region tracking -- allows tracking of reservations and instantiated pages + * across the pages in a mapping. + */ +struct file_region { + struct list_head link; + long from; + long to; +}; + +static long region_add(struct list_head *head, long f, long t) +{ + struct file_region *rg, *nrg, *trg; + + /* Locate the region we are either in or before. */ + list_for_each_entry(rg, head, link) + if (f <= rg->to) + break; + + /* Round our left edge to the current segment if it encloses us. */ + if (f > rg->from) + f = rg->from; + + /* Check for and consume any regions we now overlap with. */ + nrg = rg; + list_for_each_entry_safe(rg, trg, rg->link.prev, link) { + if (&rg->link == head) + break; + if (rg->from > t) + break; + + /* If this area reaches higher then extend our area to + * include it completely. If this is not the first area + * which we intend to reuse, free it. */ + if (rg->to > t) + t = rg->to; + if (rg != nrg) { + list_del(&rg->link); + kfree(rg); + } + } + nrg->from = f; + nrg->to = t; + return 0; +} + +static long region_chg(struct list_head *head, long f, long t) +{ + struct file_region *rg, *nrg; + long chg = 0; + + /* Locate the region we are before or in. */ + list_for_each_entry(rg, head, link) + if (f <= rg->to) + break; + + /* If we are below the current region then a new region is required. + * Subtle, allocate a new region at the position but make it zero + * size such that we can guarantee to record the reservation. */ + if (&rg->link == head || t < rg->from) { + nrg = kmalloc(sizeof(*nrg), GFP_KERNEL); + if (!nrg) + return -ENOMEM; + nrg->from = f; + nrg->to = f; + INIT_LIST_HEAD(&nrg->link); + list_add(&nrg->link, rg->link.prev); + + return t - f; + } + + /* Round our left edge to the current segment if it encloses us. */ + if (f > rg->from) + f = rg->from; + chg = t - f; + + /* Check for and consume any regions we now overlap with. */ + list_for_each_entry(rg, rg->link.prev, link) { + if (&rg->link == head) + break; + if (rg->from > t) + return chg; + + /* We overlap with this area, if it extends futher than + * us then we must extend ourselves. Account for its + * existing reservation. */ + if (rg->to > t) { + chg += rg->to - t; + t = rg->to; + } + chg -= rg->to - rg->from; + } + return chg; +} + +static long region_truncate(struct list_head *head, long end) +{ + struct file_region *rg, *trg; + long chg = 0; + + /* Locate the region we are either in or before. */ + list_for_each_entry(rg, head, link) + if (end <= rg->to) + break; + if (&rg->link == head) + return 0; + + /* If we are in the middle of a region then adjust it. */ + if (end > rg->from) { + chg = rg->to - end; + rg->to = end; + rg = list_entry(rg->link.next, typeof(*rg), link); + } + + /* Drop any remaining regions. */ + list_for_each_entry_safe(rg, trg, rg->link.prev, link) { + if (&rg->link == head) + break; + chg += rg->to - rg->from; + list_del(&rg->link); + kfree(rg); + } + return chg; +} + +/* * Convert the address within this vma to the page offset within * the mapping, in base page units. */ @@ -595,127 +720,6 @@ static void return_unused_surplus_pages( } } -struct file_region { - struct list_head link; - long from; - long to; -}; - -static long region_add(struct list_head *head, long f, long t) -{ - struct file_region *rg, *nrg, *trg; - - /* Locate the region we are either in or before. */ - list_for_each_entry(rg, head, link) - if (f <= rg->to) - break; - - /* Round our left edge to the current segment if it encloses us. */ - if (f > rg->from) - f = rg->from; - - /* Check for and consume any regions we now overlap with. */ - nrg = rg; - list_for_each_entry_safe(rg, trg, rg->link.prev, link) { - if (&rg->link == head) - break; - if (rg->from > t) - break; - - /* If this area reaches higher then extend our area to - * include it completely. If this is not the first area - * which we intend to reuse, free it. */ - if (rg->to > t) - t = rg->to; - if (rg != nrg) { - list_del(&rg->link); - kfree(rg); - } - } - nrg->from = f; - nrg->to = t; - return 0; -} - -static long region_chg(struct list_head *head, long f, long t) -{ - struct file_region *rg, *nrg; - long chg = 0; - - /* Locate the region we are before or in. */ - list_for_each_entry(rg, head, link) - if (f <= rg->to) - break; - - /* If we are below the current region then a new region is required. - * Subtle, allocate a new region at the position but make it zero - * size such that we can guarantee to record the reservation. */ - if (&rg->link == head || t < rg->from) { - nrg = kmalloc(sizeof(*nrg), GFP_KERNEL); - if (!nrg) - return -ENOMEM; - nrg->from = f; - nrg->to = f; - INIT_LIST_HEAD(&nrg->link); - list_add(&nrg->link, rg->link.prev); - - return t - f; - } - - /* Round our left edge to the current segment if it encloses us. */ - if (f > rg->from) - f = rg->from; - chg = t - f; - - /* Check for and consume any regions we now overlap with. */ - list_for_each_entry(rg, rg->link.prev, link) { - if (&rg->link == head) - break; - if (rg->from > t) - return chg; - - /* We overlap with this area, if it extends futher than - * us then we must extend ourselves. Account for its - * existing reservation. */ - if (rg->to > t) { - chg += rg->to - t; - t = rg->to; - } - chg -= rg->to - rg->from; - } - return chg; -} - -static long region_truncate(struct list_head *head, long end) -{ - struct file_region *rg, *trg; - long chg = 0; - - /* Locate the region we are either in or before. */ - list_for_each_entry(rg, head, link) - if (end <= rg->to) - break; - if (&rg->link == head) - return 0; - - /* If we are in the middle of a region then adjust it. */ - if (end > rg->from) { - chg = rg->to - end; - rg->to = end; - rg = list_entry(rg->link.next, typeof(*rg), link); - } - - /* Drop any remaining regions. */ - list_for_each_entry_safe(rg, trg, rg->link.prev, link) { - if (&rg->link == head) - break; - chg += rg->to - rg->from; - list_del(&rg->link); - kfree(rg); - } - return chg; -} - static struct page *alloc_huge_page(struct vm_area_struct *vma, unsigned long addr, int avoid_reserve) { _ Patches currently in -mm which might be from apw@xxxxxxxxxxxx are origin.patch mm-add-a-basic-debugging-framework-for-memory-initialisation.patch mm-verify-the-page-links-and-memory-model.patch mm-make-defensive-checks-around-pfn-values-registered-for-memory-usage.patch mm-print-out-the-zonelists-on-request-for-manual-verification.patch add-a-helper-function-to-test-if-an-object-is-on-the-stack.patch mm-move-bootmem-descriptors-definition-to-a-single-place.patch mm-fix-free_all_bootmem_core-alignment-check.patch mm-normalize-internal-argument-passing-of-bootmem-data.patch mm-unexport-__alloc_bootmem_core.patch buddy-clarify-comments-describing-buddy-merge.patch page-flags-record-page-flag-overlays-explicitly.patch slub-record-page-flag-overlays-explicitly.patch slob-record-page-flag-overlays-explicitly.patch hugetlb-move-hugetlb_acct_memory.patch hugetlb-reserve-huge-pages-for-reliable-map_private-hugetlbfs-mappings-until-fork.patch hugetlb-guarantee-that-cow-faults-for-a-process-that-called-mmapmap_private-on-hugetlbfs-will-succeed.patch huge-page-private-reservation-review-cleanups.patch mm-record-map_noreserve-status-on-vmas-and-fix-small-page-mprotect-reservations.patch hugetlb-move-reservation-region-support-earlier.patch hugetlb-move-reservation-region-support-earlier-fix.patch hugetlb-allow-huge-page-mappings-to-be-created-without-reservations.patch hugetlb-allow-huge-page-mappings-to-be-created-without-reservations-cleanups.patch hugetlb-reservations-fix-hugetlb-map_private-reservations-across-vma-splits-v2.patch vma-page-offset-has-no-callees-drop-it.patch hugetlb-fix-race-when-reading-proc-meminfo.patch hugetlb-fix-a-hugepage-reservation-check-for-map_shared.patch hugetlb-quota-is-not-freed-for-unused-reserved-private-huge-pages.patch memory-hotplugallocate-usemap-on-the-section-with-pgdat-take-4.patch memory-hotplug-small-fixes-to-bootmem-freeing-for-memory-hotremove.patch memory-hotplug-dont-calculate-vm_total_pages-twice-when-rebuilding-zonelists-in-online_pages.patch checkpatch-version-020.patch checkpatch-return-is-not-a-function-parentheses-for-casts-are-ok-too.patch checkpatch-types-some-types-may-also-be-identifiers.patch checkpatch-add-a-checkpatch-warning-for-new-uses-of-__initcall.patch checkpatch-possible-types-__asm__-is-never-a-type.patch checkpatch-comment-detection-ignore-macro-continuation-when-detecting-associated-comments.patch checkpatch-types-unary-goto-introduces-unary-context.patch checkpatch-macros-fix-statement-counting-block-end-detection.patch checkpatch-trailing-statement-indent-fix-end-of-statement-location.patch checkpatch-allow-printk-strings-to-exceed-80-characters-to-maintain-their-searchability.patch checkpatch-switch-report-trailing-statements-on-case-and-default.patch checkpatch-check-spacing-for-square-brackets.patch checkpatch-toughen-trailing-if-statement-checks-and-extend-them-to-while-and-for.patch checkpatch-condition-loop-indent-checks.patch checkpatch-usb_free_urb-can-take-null.patch checkpatch-correct-spelling-in-kfree-checks.patch checkpatch-allow-for-type-modifiers-on-multiple-declarations.patch checkpatch-improve-type-matcher-debug.patch checkpatch-possible-modifiers-are-not-being-correctly-matched.patch checkpatch-macro-complexity-checks-are-meaningless-in-linker-scripts.patch checkpatch-handle-return-types-of-pointers-to-functions.patch checkpatch-possible-types-known-modifiers-cannot-be-types.patch checkpatch-possible-modifiers-handle-multiple-modifiers-and-trailing.patch checkpatch-add-checks-for-question-mark-and-colon-spacing.patch checkpatch-variants-move-the-main-unary-binary-operators-to-use-variants.patch checkpatch-complex-macros-need-to-ignore-comments.patch checkpatch-types-cannot-start-mid-word-for-pointer-tests.patch checkpatch-version-021.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html