The patch titled mm: compaction: minimise the time IRQs are disabled while isolating free pages has been added to the -mm tree. Its filename is mm-compaction-minimise-the-time-irqs-are-disabled-while-isolating-free-pages.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 *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: mm: compaction: minimise the time IRQs are disabled while isolating free pages From: Mel Gorman <mel@xxxxxxxxx> compaction_alloc() isolates free pages to be used as migration targets. While its scanning, IRQs are disabled on the mistaken assumption the scanning should be short. Analysis showed that IRQs were in fact being disabled for substantial time. A simple test was run using large anonymous mappings with transparent hugepage support enabled to trigger frequent compactions. A monitor sampled what the worst IRQ-off latencies were and a post-processing tool found the following; Total sampled time IRQs off (not real total time): 22355 Event compaction_alloc..compaction_alloc 8409 us count 1 Event compaction_alloc..compaction_alloc 7341 us count 1 Event compaction_alloc..compaction_alloc 2463 us count 1 Event compaction_alloc..compaction_alloc 2054 us count 1 Event shrink_inactive_list..shrink_zone 1864 us count 1 Event shrink_inactive_list..shrink_zone 88 us count 1 Event save_args..call_softirq 36 us count 1 Event save_args..call_softirq 35 us count 2 Event __make_request..__blk_run_queue 24 us count 1 Event __alloc_pages_nodemask..__alloc_pages_nodemask 6 us count 1 i.e. compaction is disabled IRQs for a prolonged period of time - 8ms in one instance. The full report generated by the tool can be found at http://www.csn.ul.ie/~mel/postings/minfree-20110225/irqsoff-vanilla-micro.report . This patch reduces the time IRQs are disabled by simply disabling IRQs at the last possible minute. An updated IRQs-off summary report then looks like; Total sampled time IRQs off (not real total time): 5493 Event shrink_inactive_list..shrink_zone 1596 us count 1 Event shrink_inactive_list..shrink_zone 1530 us count 1 Event shrink_inactive_list..shrink_zone 956 us count 1 Event shrink_inactive_list..shrink_zone 541 us count 1 Event shrink_inactive_list..shrink_zone 531 us count 1 Event split_huge_page..add_to_swap 232 us count 1 Event save_args..call_softirq 36 us count 1 Event save_args..call_softirq 35 us count 2 Event __wake_up..__wake_up 1 us count 1 A full report is again available at http://www.csn.ul.ie/~mel/postings/minfree-20110225/irqsoff-minimiseirq-free-v1r4-micro.report . . As should be obvious, IRQ disabled latencies due to compaction are almost elimimnated for this particular test. [aarcange@xxxxxxxxxx: Fix initialisation of isolated] Signed-off-by: Mel Gorman <mel@xxxxxxxxx> Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxx> Reviewed-by: Minchan Kim <minchan.kim@xxxxxxxxx> Acked-by: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: Arthur Marsh <arthur.marsh@xxxxxxxxxxxxxxxx> Cc: Clemens Ladisch <cladisch@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/compaction.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff -puN mm/compaction.c~mm-compaction-minimise-the-time-irqs-are-disabled-while-isolating-free-pages mm/compaction.c --- a/mm/compaction.c~mm-compaction-minimise-the-time-irqs-are-disabled-while-isolating-free-pages +++ a/mm/compaction.c @@ -155,7 +155,6 @@ static void isolate_freepages(struct zon * pages on cc->migratepages. We stop searching if the migrate * and free page scanners meet or enough free pages are isolated. */ - spin_lock_irqsave(&zone->lock, flags); for (; pfn > low_pfn && cc->nr_migratepages > nr_freepages; pfn -= pageblock_nr_pages) { unsigned long isolated; @@ -178,9 +177,19 @@ static void isolate_freepages(struct zon if (!suitable_migration_target(page)) continue; - /* Found a block suitable for isolating free pages from */ - isolated = isolate_freepages_block(zone, pfn, freelist); - nr_freepages += isolated; + /* + * Found a block suitable for isolating free pages from. Now + * we disabled interrupts, double check things are ok and + * isolate the pages. This is to minimise the time IRQs + * are disabled + */ + isolated = 0; + spin_lock_irqsave(&zone->lock, flags); + if (suitable_migration_target(page)) { + isolated = isolate_freepages_block(zone, pfn, freelist); + nr_freepages += isolated; + } + spin_unlock_irqrestore(&zone->lock, flags); /* * Record the highest PFN we isolated pages from. When next @@ -190,7 +199,6 @@ static void isolate_freepages(struct zon if (isolated) high_pfn = max(high_pfn, pfn); } - spin_unlock_irqrestore(&zone->lock, flags); /* split_free_page does not map the pages */ list_for_each_entry(page, freelist, lru) { _ Patches currently in -mm which might be from mel@xxxxxxxxx are origin.patch linux-next.patch mm-compaction-check-migrate_pagess-return-value-instead-of-list_empty.patch oom-suppress-nodes-that-are-not-allowed-from-meminfo-on-oom-kill.patch oom-suppress-show_mem-for-many-nodes-in-irq-context-on-page-alloc-failure.patch oom-suppress-nodes-that-are-not-allowed-from-meminfo-on-page-alloc-failure.patch mm-add-replace_page_cache_page-function.patch mm-add-replace_page_cache_page-function-add-freepage-hook.patch mm-introduce-delete_from_page_cache.patch mm-hugetlbfs-change-remove_from_page_cache.patch mm-shmem-change-remove_from_page_cache.patch mm-truncate-change-remove_from_page_cache.patch mm-good-bye-remove_from_page_cache.patch mm-change-__remove_from_page_cache.patch mm-batch-free-pcp-list-if-possible.patch mm-batch-free-pcp-list-if-possible-fix.patch mm-rename-drop_anon_vma-to-put_anon_vma.patch mm-move-anon_vma-ref-out-from-under-config_foo.patch mm-simplify-anon_vma-refcounts.patch mm-deactivate-invalidated-pages.patch mm-reclaim-invalidated-page-asap.patch pagewalk-only-split-huge-pages-when-necessary.patch smaps-break-out-smaps_pte_entry-from-smaps_pte_range.patch smaps-pass-pte-size-argument-in-to-smaps_pte_entry.patch smaps-teach-smaps_pte_range-about-thp-pmds.patch smaps-have-smaps-show-transparent-huge-pages.patch mm-vmscan-kswapd-should-not-free-an-excessive-number-of-pages-when-balancing-small-zones.patch hugetlbfs-correct-handling-of-negative-input-to-proc-sys-vm-nr_hugepages.patch mm-compaction-minimise-the-time-irqs-are-disabled-while-isolating-free-pages.patch mm-compaction-minimise-the-time-irqs-are-disabled-while-isolating-pages-for-migration.patch add-debugging-aid-for-memory-initialisation-problems.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