Subject: + mm-improve-documentation-of-page_order-v2.patch added to -mm tree To: mgorman@xxxxxxx,aquini@xxxxxxxxxx,lauraa@xxxxxxxxxxxxxx,minchan@xxxxxxxxxx From: akpm@xxxxxxxxxxxxxxxxxxxx Date: Tue, 21 Jan 2014 11:56:28 -0800 The patch titled Subject: mm: improve documentation of page_order has been added to the -mm tree. Its filename is mm-improve-documentation-of-page_order-v2.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-improve-documentation-of-page_order-v2.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-improve-documentation-of-page_order-v2.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Mel Gorman <mgorman@xxxxxxx> Subject: mm: improve documentation of page_order Developers occasionally try and optimise PFN scanners by using page_order but miss that in general it requires zone->lock. This has happened twice for compaction.c and rejected both times. This patch clarifies the documentation of page_order and adds a note to compaction.c why page_order is not used. [lauraa@xxxxxxxxxxxxxx: Corrected a page_zone(page)->lock reference] Signed-off-by: Mel Gorman <mgorman@xxxxxxx> Acked-by: Rafael Aquini <aquini@xxxxxxxxxx> Acked-by: Minchan Kim <minchan@xxxxxxxxxx> Cc: Laura Abbott <lauraa@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/compaction.c | 5 ++++- mm/internal.h | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff -puN mm/compaction.c~mm-improve-documentation-of-page_order-v2 mm/compaction.c --- a/mm/compaction.c~mm-improve-documentation-of-page_order-v2 +++ a/mm/compaction.c @@ -523,7 +523,10 @@ isolate_migratepages_range(struct zone * if (!isolation_suitable(cc, page)) goto next_pageblock; - /* Skip if free */ + /* + * Skip if free. page_order cannot be used without zone->lock + * as nothing prevents parallel allocations or buddy merging. + */ if (PageBuddy(page)) continue; diff -puN mm/internal.h~mm-improve-documentation-of-page_order-v2 mm/internal.h --- a/mm/internal.h~mm-improve-documentation-of-page_order-v2 +++ a/mm/internal.h @@ -143,9 +143,11 @@ isolate_migratepages_range(struct zone * #endif /* - * function for dealing with page's order in buddy system. - * zone->lock is already acquired when we use these. - * So, we don't need atomic page->flags operations here. + * This functions returns the order of a free page in the buddy system. In + * general, page_zone(page)->lock must be held by the caller to prevent the + * page being allocated in parallel and returning garbage as the order. If the + * caller does not hold page_zone(page)->lock, they must guarantee that the + * page cannot be allocated or merged in parallel. */ static inline unsigned long page_order(struct page *page) { _ Patches currently in -mm which might be from mgorman@xxxxxxx are origin.patch mm-remove-bug_on-from-mlock_vma_page.patch x86-mm-account-for-tlb-flushes-only-when-debugging.patch x86-mm-account-for-tlb-flushes-only-when-debugging-fix.patch x86-mm-clean-up-inconsistencies-when-flushing-tlb-ranges.patch x86-mm-eliminate-redundant-page-table-walk-during-tlb-range-flushing.patch x86-mm-change-tlb_flushall_shift-for-ivybridge.patch mm-x86-revisit-tlb_flushall_shift-tuning-for-page-flushes-except-on-ivybridge.patch mm-hugetlbfs-add-some-vm_bug_ons-to-catch-non-hugetlbfs-pages.patch mm-hugetlb-use-get_page_foll-in-follow_hugetlb_page.patch mm-hugetlbfs-move-the-put-get_page-slab-and-hugetlbfs-optimization-in-a-faster-path.patch mm-thp-optimize-compound_trans_huge.patch mm-tail-page-refcounting-optimization-for-slab-and-hugetlbfs.patch mm-hugetlbfs-use-__compound_tail_refcounted-in-__get_page_tail-too.patch mm-hugetlbc-simplify-pageheadhuge-and-pagehuge.patch mm-swapc-reorganize-put_compound_page.patch mm-hugetlbc-defer-pageheadhuge-symbol-export.patch mm-thp-__get_page_tail_foll-can-use-get_huge_page_tail.patch mm-thp-turn-compound_head-into-bug_onpagetail-in-get_huge_page_tail.patch mm-get-rid-of-unnecessary-pageblock-scanning-in-setup_zone_migrate_reserve.patch mm-get-rid-of-unnecessary-pageblock-scanning-in-setup_zone_migrate_reserve-fix.patch mm-call-mmu-notifiers-when-copying-a-hugetlb-page-range.patch mm-show_mem-remove-show_mem_filter_page_count.patch mm-show_mem-remove-show_mem_filter_page_count-fix.patch memblock-numa-introduce-flags-field-into-memblock.patch memblock-mem_hotplug-introduce-memblock_hotplug-flag-to-mark-hotpluggable-regions.patch memblock-make-memblock_set_node-support-different-memblock_type.patch acpi-numa-mem_hotplug-mark-hotpluggable-memory-in-memblock.patch acpi-numa-mem_hotplug-mark-all-nodes-the-kernel-resides-un-hotpluggable.patch memblock-mem_hotplug-make-memblock-skip-hotpluggable-regions-if-needed.patch x86-numa-acpi-memory-hotplug-make-movable_node-have-higher-priority.patch mm-rmap-recompute-pgoff-for-huge-page.patch mm-rmap-factor-nonlinear-handling-out-of-try_to_unmap_file.patch mm-rmap-factor-lock-function-out-of-rmap_walk_anon.patch mm-rmap-make-rmap_walk-to-get-the-rmap_walk_control-argument.patch mm-rmap-extend-rmap_walk_xxx-to-cope-with-different-cases.patch mm-rmap-use-rmap_walk-in-try_to_unmap.patch mm-rmap-use-rmap_walk-in-try_to_munlock.patch mm-rmap-use-rmap_walk-in-page_referenced.patch mm-rmap-use-rmap_walk-in-page_referenced-fix.patch mm-rmap-use-rmap_walk-in-page_mkclean.patch mm-page_alloc-allow-__gfp_nofail-to-allocate-below-watermarks-after-reclaim.patch mm-numa-make-numa-migrate-related-functions-static.patch mm-numa-limit-scope-of-lock-for-numa-migrate-rate-limiting.patch mm-numa-trace-tasks-that-fail-migration-due-to-rate-limiting.patch mm-numa-do-not-automatically-migrate-ksm-pages.patch sched-add-tracepoints-related-to-numa-task-migration.patch sched-add-tracepoints-related-to-numa-task-migration-fix.patch mm-compaction-trace-compaction-begin-and-end.patch mm-compaction-encapsulate-defer-reset-logic.patch mm-compaction-reset-cached-scanner-pfns-before-reading-them.patch mm-compaction-detect-when-scanners-meet-in-isolate_freepages.patch mm-compaction-do-not-mark-unmovable-pageblocks-as-skipped-in-async-compaction.patch mm-compaction-reset-scanner-positions-immediately-when-they-meet.patch mm-page_alloc-warn-for-non-blockable-__gfp_nofail-allocation-failure.patch mm-migrate-add-comment-about-permanent-failure-path.patch mm-migrate-correct-failure-handling-if-hugepage_migration_support.patch mm-migrate-remove-putback_lru_pages-fix-comment-on-putback_movable_pages.patch mm-migrate-remove-unused-function-fail_migrate_page.patch mm-munlock-fix-potential-race-with-thp-page-split.patch numa-add-a-sysctl-for-numa_balancing.patch numa-add-a-sysctl-for-numa_balancing-fix.patch mm-vmscan-shrink-all-slab-objects-if-tight-on-memory.patch mm-vmscan-call-numa-unaware-shrinkers-irrespective-of-nodemask.patch mm-vmscan-respect-numa-policy-mask-when-shrinking-slab-on-direct-reclaim.patch mm-vmscan-move-call-to-shrink_slab-to-shrink_zones.patch mm-vmscan-remove-shrink_control-arg-from-do_try_to_free_pages.patch mm-show-message-when-updating-min_free_kbytes-in-thp.patch mm-improve-documentation-of-page_order-v2.patch mm-improve-documentation-of-page_order-v2-fix.patch linux-next.patch mm-migratec-fix-setting-of-cpupid-on-page-migration-twice-against-normal-page.patch zsmalloc-move-it-under-mm.patch zram-promote-zram-from-staging.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