The patch titled Subject: mm, oom: cleanup pagefault oom handler has been added to the -mm tree. Its filename is mm-oom-cleanup-pagefault-oom-handler.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: David Rientjes <rientjes@xxxxxxxxxx> Subject: mm, oom: cleanup pagefault oom handler To lock the entire system from parallel oom killing, it's possible to pass in a zonelist with all zones rather than using for_each_populated_zone() for the iteration. This obsoletes try_set_system_oom() and clear_system_oom() so that they can be removed. Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> Cc: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> Reviewed-by: Michal Hocko <mhocko@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/oom_kill.c | 49 ++++++------------------------------------------ 1 file changed, 7 insertions(+), 42 deletions(-) diff -puN mm/oom_kill.c~mm-oom-cleanup-pagefault-oom-handler mm/oom_kill.c --- a/mm/oom_kill.c~mm-oom-cleanup-pagefault-oom-handler +++ a/mm/oom_kill.c @@ -591,43 +591,6 @@ void clear_zonelist_oom(struct zonelist spin_unlock(&zone_scan_lock); } -/* - * Try to acquire the oom killer lock for all system zones. Returns zero if a - * parallel oom killing is taking place, otherwise locks all zones and returns - * non-zero. - */ -static int try_set_system_oom(void) -{ - struct zone *zone; - int ret = 1; - - spin_lock(&zone_scan_lock); - for_each_populated_zone(zone) - if (zone_is_oom_locked(zone)) { - ret = 0; - goto out; - } - for_each_populated_zone(zone) - zone_set_flag(zone, ZONE_OOM_LOCKED); -out: - spin_unlock(&zone_scan_lock); - return ret; -} - -/* - * Clears ZONE_OOM_LOCKED for all system zones so that failed allocation - * attempts or page faults may now recall the oom killer, if necessary. - */ -static void clear_system_oom(void) -{ - struct zone *zone; - - spin_lock(&zone_scan_lock); - for_each_populated_zone(zone) - zone_clear_flag(zone, ZONE_OOM_LOCKED); - spin_unlock(&zone_scan_lock); -} - /** * out_of_memory - kill the "best" process when we run out of memory * @zonelist: zonelist pointer @@ -708,15 +671,17 @@ out: /* * The pagefault handler calls here because it is out of memory, so kill a - * memory-hogging task. If a populated zone has ZONE_OOM_LOCKED set, a parallel - * oom killing is already in progress so do nothing. If a task is found with - * TIF_MEMDIE set, it has been killed so do nothing and allow it to exit. + * memory-hogging task. If any populated zone has ZONE_OOM_LOCKED set, a + * parallel oom killing is already in progress so do nothing. */ void pagefault_out_of_memory(void) { - if (try_set_system_oom()) { + struct zonelist *zonelist = node_zonelist(first_online_node, + GFP_KERNEL); + + if (try_set_zonelist_oom(zonelist, GFP_KERNEL)) { out_of_memory(NULL, 0, 0, NULL, false); - clear_system_oom(); + clear_zonelist_oom(zonelist, GFP_KERNEL); } schedule_timeout_killable(1); } _ Patches currently in -mm which might be from rientjes@xxxxxxxxxx are linux-next.patch mm-export-a-function-to-get-vm-committed-memory.patch x86-convert-update_mmu_cache-and-update_mmu_cache_pmd-to-functions.patch irq-tsk-comm-is-an-array.patch mm-memcg-make-mem_cgroup_out_of_memory-static.patch mm-use-is_enabledconfig_numa-instead-of-numa_build.patch mm-use-is_enabledconfig_compaction-instead-of-compaction_build.patch thp-clean-up-__collapse_huge_page_isolate.patch memory-hotplug-suppress-device-memoryx-does-not-have-a-release-function-warning.patch memory-hotplug-skip-hwpoisoned-page-when-offlining-pages.patch memory-hotplug-update-mce_bad_pages-when-removing-the-memory.patch memory-hotplug-update-mce_bad_pages-when-removing-the-memory-fix.patch memory-hotplug-auto-offline-page_cgroup-when-onlining-memory-block-failed.patch memory-hotplug-fix-nr_free_pages-mismatch.patch numa-convert-static-memory-to-dynamically-allocated-memory-for-per-node-device.patch memory-hotplug-suppress-device-nodex-does-not-have-a-release-function-warning.patch memory-hotplug-mm-sparsec-clear-the-memory-to-store-struct-page.patch memory-hotplug-allocate-zones-pcp-before-onlining-pages.patch memory-hotplug-allocate-zones-pcp-before-onlining-pages-fix.patch memory-hotplug-allocate-zones-pcp-before-onlining-pages-fix-2.patch memory_hotplug-fix-possible-incorrect-node_states.patch slub-hotplug-ignore-unrelated-nodes-hot-adding-and-hot-removing.patch mm-oom-allow-exiting-threads-to-have-access-to-memory-reserves.patch memcg-make-it-possible-to-use-the-stock-for-more-than-one-page.patch memcg-reclaim-when-more-than-one-page-needed.patch memcg-change-defines-to-an-enum.patch memcg-kmem-accounting-basic-infrastructure.patch mm-add-a-__gfp_kmemcg-flag.patch memcg-kmem-controller-infrastructure.patch memcg-kmem-controller-infrastructure-replace-__always_inline-with-plain-inline.patch mm-allocate-kernel-pages-to-the-right-memcg.patch res_counter-return-amount-of-charges-after-res_counter_uncharge.patch memcg-kmem-accounting-lifecycle-management.patch memcg-use-static-branches-when-code-not-in-use.patch memcg-allow-a-memcg-with-kmem-charges-to-be-destructed.patch memcg-execute-the-whole-memcg-freeing-in-free_worker.patch fork-protect-architectures-where-thread_size-=-page_size-against-fork-bombs.patch memcg-add-documentation-about-the-kmem-controller.patch slab-slub-struct-memcg_params.patch slab-annotate-on-slab-caches-nodelist-locks.patch slab-slub-consider-a-memcg-parameter-in-kmem_create_cache.patch memcg-allocate-memory-for-memcg-caches-whenever-a-new-memcg-appears.patch memcg-allocate-memory-for-memcg-caches-whenever-a-new-memcg-appears-simplify-ida-initialization.patch memcg-infrastructure-to-match-an-allocation-to-the-right-cache.patch memcg-skip-memcg-kmem-allocations-in-specified-code-regions.patch memcg-skip-memcg-kmem-allocations-in-specified-code-regions-remove-test-for-current-mm-in-memcg_stop-resume_kmem_account.patch slb-always-get-the-cache-from-its-page-in-kmem_cache_free.patch slb-allocate-objects-from-memcg-cache.patch memcg-destroy-memcg-caches.patch memcg-destroy-memcg-caches-move-include-of-workqueueh-to-top-of-slabh-file.patch memcg-slb-track-all-the-memcg-children-of-a-kmem_cache.patch memcg-slb-shrink-dead-caches.patch memcg-slb-shrink-dead-caches-get-rid-of-once-per-second-cache-shrinking-for-dead-memcgs.patch memcg-aggregate-memcg-cache-values-in-slabinfo.patch slab-propagate-tunable-values.patch slub-slub-specific-propagation-changes.patch slub-slub-specific-propagation-changes-fix.patch kmem-add-slab-specific-documentation-about-the-kmem-controller.patch memcg-add-comments-clarifying-aspects-of-cache-attribute-propagation.patch slub-drop-mutex-before-deleting-sysfs-entry.patch mm-support-more-pagesizes-for-map_hugetlb-shm_hugetlb-v7-fix-fix-fix.patch mm-support-more-pagesizes-for-map_hugetlb-shm_hugetlb-v7-fix-fix-fix-fix.patch mm-support-more-pagesizes-for-map_hugetlb-shm_hugetlb-v7-fix-fix-fix-fix-checkpatch-fixes.patch mm-mempolicy-remove-duplicate-code.patch mm-cleanup-register_node.patch mm-oom-change-type-of-oom_score_adj-to-short.patch mm-oom-fix-race-when-specifying-a-thread-as-the-oom-origin.patch drivers-base-nodec-cleanup-node_state_attr.patch mm-memory-hotplug-dynamic-configure-movable-memory-and-portion-memory.patch memory_hotplug-handle-empty-zone-when-online_movable-online_kernel.patch memory_hotplug-ensure-every-online-node-has-normal-memory.patch thp-huge-zero-page-basic-preparation.patch thp-huge-zero-page-basic-preparation-v6.patch thp-zap_huge_pmd-zap-huge-zero-pmd.patch thp-copy_huge_pmd-copy-huge-zero-page.patch thp-copy_huge_pmd-copy-huge-zero-page-v6.patch thp-copy_huge_pmd-copy-huge-zero-page-v6-fix.patch thp-do_huge_pmd_wp_page-handle-huge-zero-page.patch thp-do_huge_pmd_wp_page-handle-huge-zero-page-v6.patch thp-change_huge_pmd-keep-huge-zero-page-write-protected.patch thp-change-split_huge_page_pmd-interface.patch thp-change-split_huge_page_pmd-interface-v6.patch thp-implement-splitting-pmd-for-huge-zero-page.patch thp-implement-splitting-pmd-for-huge-zero-page-v6.patch thp-setup-huge-zero-page-on-non-write-page-fault.patch thp-setup-huge-zero-page-on-non-write-page-fault-fix.patch thp-lazy-huge-zero-page-allocation.patch thp-implement-refcounting-for-huge-zero-page.patch thp-vmstat-implement-hzp_alloc-and-hzp_alloc_failed-events.patch thp-vmstat-implement-hzp_alloc-and-hzp_alloc_failed-events-v6.patch thp-introduce-sysfs-knob-to-disable-huge-zero-page.patch node_states-introduce-n_memory.patch cpuset-use-n_memory-instead-n_high_memory.patch procfs-use-n_memory-instead-n_high_memory.patch memcontrol-use-n_memory-instead-n_high_memory.patch oom-use-n_memory-instead-n_high_memory.patch mmmigrate-use-n_memory-instead-n_high_memory.patch mempolicy-use-n_memory-instead-n_high_memory.patch hugetlb-use-n_memory-instead-n_high_memory.patch vmstat-use-n_memory-instead-n_high_memory.patch kthread-use-n_memory-instead-n_high_memory.patch init-use-n_memory-instead-n_high_memory.patch vmscan-use-n_memory-instead-n_high_memory.patch page_alloc-use-n_memory-instead-n_high_memory-change-the-node_states-initialization.patch hotplug-update-nodemasks-management.patch mm-memcg-avoid-unnecessary-function-call-when-memcg-is-disabled.patch numa-add-config_movable_node-for-movable-dedicated-node.patch numa-add-config_movable_node-for-movable-dedicated-node-fix.patch memory_hotplug-allow-online-offline-memory-to-result-movable-node.patch mm-oom-ensure-sysrqf-always-passes-valid-zonelist.patch mm-oom-cleanup-pagefault-oom-handler.patch mm-oom-remove-redundant-sleep-in-pagefault-oom-handler.patch mm-oom-remove-statically-defined-arch-functions-of-same-name.patch mm-dmapoolc-fix-null-dev-in-dma_pool_create.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