diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/Kconfig | 2 | ||||
-rw-r--r-- | mm/filemap.c | 11 | ||||
-rw-r--r-- | mm/huge_memory.c | 10 | ||||
-rw-r--r-- | mm/hugetlb.c | 17 | ||||
-rw-r--r-- | mm/memcontrol.c | 143 | ||||
-rw-r--r-- | mm/memory.c | 20 | ||||
-rw-r--r-- | mm/migrate.c | 2 | ||||
-rw-r--r-- | mm/mprotect.c | 7 | ||||
-rw-r--r-- | mm/mremap.c | 5 | ||||
-rw-r--r-- | mm/oom_kill.c | 2 | ||||
-rw-r--r-- | mm/page-writeback.c | 10 | ||||
-rw-r--r-- | mm/slab_common.c | 2 | ||||
-rw-r--r-- | mm/swapfile.c | 4 | ||||
-rw-r--r-- | mm/vmscan.c | 1 | ||||
-rw-r--r-- | mm/zswap.c | 4 |
15 files changed, 120 insertions, 120 deletions
diff --git a/mm/Kconfig b/mm/Kconfig index 026771a9b097..394838f489eb 100644 --- a/mm/Kconfig +++ b/mm/Kconfig | |||
@@ -183,7 +183,7 @@ config MEMORY_HOTPLUG_SPARSE | |||
183 | config MEMORY_HOTREMOVE | 183 | config MEMORY_HOTREMOVE |
184 | bool "Allow for memory hot remove" | 184 | bool "Allow for memory hot remove" |
185 | select MEMORY_ISOLATION | 185 | select MEMORY_ISOLATION |
186 | select HAVE_BOOTMEM_INFO_NODE if X86_64 | 186 | select HAVE_BOOTMEM_INFO_NODE if (X86_64 || PPC64) |
187 | depends on MEMORY_HOTPLUG && ARCH_ENABLE_MEMORY_HOTREMOVE | 187 | depends on MEMORY_HOTPLUG && ARCH_ENABLE_MEMORY_HOTREMOVE |
188 | depends on MIGRATION | 188 | depends on MIGRATION |
189 | 189 | ||
diff --git a/mm/filemap.c b/mm/filemap.c index 1e6aec4a2d2e..ae4846ff4849 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -1616,7 +1616,6 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1616 | struct inode *inode = mapping->host; | 1616 | struct inode *inode = mapping->host; |
1617 | pgoff_t offset = vmf->pgoff; | 1617 | pgoff_t offset = vmf->pgoff; |
1618 | struct page *page; | 1618 | struct page *page; |
1619 | bool memcg_oom; | ||
1620 | pgoff_t size; | 1619 | pgoff_t size; |
1621 | int ret = 0; | 1620 | int ret = 0; |
1622 | 1621 | ||
@@ -1625,11 +1624,7 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1625 | return VM_FAULT_SIGBUS; | 1624 | return VM_FAULT_SIGBUS; |
1626 | 1625 | ||
1627 | /* | 1626 | /* |
1628 | * Do we have something in the page cache already? Either | 1627 | * Do we have something in the page cache already? |
1629 | * way, try readahead, but disable the memcg OOM killer for it | ||
1630 | * as readahead is optional and no errors are propagated up | ||
1631 | * the fault stack. The OOM killer is enabled while trying to | ||
1632 | * instantiate the faulting page individually below. | ||
1633 | */ | 1628 | */ |
1634 | page = find_get_page(mapping, offset); | 1629 | page = find_get_page(mapping, offset); |
1635 | if (likely(page) && !(vmf->flags & FAULT_FLAG_TRIED)) { | 1630 | if (likely(page) && !(vmf->flags & FAULT_FLAG_TRIED)) { |
@@ -1637,14 +1632,10 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1637 | * We found the page, so try async readahead before | 1632 | * We found the page, so try async readahead before |
1638 | * waiting for the lock. | 1633 | * waiting for the lock. |
1639 | */ | 1634 | */ |
1640 | memcg_oom = mem_cgroup_toggle_oom(false); | ||
1641 | do_async_mmap_readahead(vma, ra, file, page, offset); | 1635 | do_async_mmap_readahead(vma, ra, file, page, offset); |
1642 | mem_cgroup_toggle_oom(memcg_oom); | ||
1643 | } else if (!page) { | 1636 | } else if (!page) { |
1644 | /* No page in the page cache at all */ | 1637 | /* No page in the page cache at all */ |
1645 | memcg_oom = mem_cgroup_toggle_oom(false); | ||
1646 | do_sync_mmap_readahead(vma, ra, file, offset); | 1638 | do_sync_mmap_readahead(vma, ra, file, offset); |
1647 | mem_cgroup_toggle_oom(memcg_oom); | ||
1648 | count_vm_event(PGMAJFAULT); | 1639 | count_vm_event(PGMAJFAULT); |
1649 | mem_cgroup_count_vm_event(vma->vm_mm, PGMAJFAULT); | 1640 | mem_cgroup_count_vm_event(vma->vm_mm, PGMAJFAULT); |
1650 | ret = VM_FAULT_MAJOR; | 1641 | ret = VM_FAULT_MAJOR; |
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 7489884682d8..610e3df2768a 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -2697,6 +2697,7 @@ void __split_huge_page_pmd(struct vm_area_struct *vma, unsigned long address, | |||
2697 | 2697 | ||
2698 | mmun_start = haddr; | 2698 | mmun_start = haddr; |
2699 | mmun_end = haddr + HPAGE_PMD_SIZE; | 2699 | mmun_end = haddr + HPAGE_PMD_SIZE; |
2700 | again: | ||
2700 | mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); | 2701 | mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); |
2701 | spin_lock(&mm->page_table_lock); | 2702 | spin_lock(&mm->page_table_lock); |
2702 | if (unlikely(!pmd_trans_huge(*pmd))) { | 2703 | if (unlikely(!pmd_trans_huge(*pmd))) { |
@@ -2719,7 +2720,14 @@ void __split_huge_page_pmd(struct vm_area_struct *vma, unsigned long address, | |||
2719 | split_huge_page(page); | 2720 | split_huge_page(page); |
2720 | 2721 | ||
2721 | put_page(page); | 2722 | put_page(page); |
2722 | BUG_ON(pmd_trans_huge(*pmd)); | 2723 | |
2724 | /* | ||
2725 | * We don't always have down_write of mmap_sem here: a racing | ||
2726 | * do_huge_pmd_wp_page() might have copied-on-write to another | ||
2727 | * huge page before our split_huge_page() got the anon_vma lock. | ||
2728 | */ | ||
2729 | if (unlikely(pmd_trans_huge(*pmd))) | ||
2730 | goto again; | ||
2723 | } | 2731 | } |
2724 | 2732 | ||
2725 | void split_huge_page_pmd_mm(struct mm_struct *mm, unsigned long address, | 2733 | void split_huge_page_pmd_mm(struct mm_struct *mm, unsigned long address, |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index b49579c7f2a5..0b7656e804d1 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -653,6 +653,7 @@ static void free_huge_page(struct page *page) | |||
653 | BUG_ON(page_count(page)); | 653 | BUG_ON(page_count(page)); |
654 | BUG_ON(page_mapcount(page)); | 654 | BUG_ON(page_mapcount(page)); |
655 | restore_reserve = PagePrivate(page); | 655 | restore_reserve = PagePrivate(page); |
656 | ClearPagePrivate(page); | ||
656 | 657 | ||
657 | spin_lock(&hugetlb_lock); | 658 | spin_lock(&hugetlb_lock); |
658 | hugetlb_cgroup_uncharge_page(hstate_index(h), | 659 | hugetlb_cgroup_uncharge_page(hstate_index(h), |
@@ -695,8 +696,22 @@ static void prep_compound_gigantic_page(struct page *page, unsigned long order) | |||
695 | /* we rely on prep_new_huge_page to set the destructor */ | 696 | /* we rely on prep_new_huge_page to set the destructor */ |
696 | set_compound_order(page, order); | 697 | set_compound_order(page, order); |
697 | __SetPageHead(page); | 698 | __SetPageHead(page); |
699 | __ClearPageReserved(page); | ||
698 | for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { | 700 | for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { |
699 | __SetPageTail(p); | 701 | __SetPageTail(p); |
702 | /* | ||
703 | * For gigantic hugepages allocated through bootmem at | ||
704 | * boot, it's safer to be consistent with the not-gigantic | ||
705 | * hugepages and clear the PG_reserved bit from all tail pages | ||
706 | * too. Otherwse drivers using get_user_pages() to access tail | ||
707 | * pages may get the reference counting wrong if they see | ||
708 | * PG_reserved set on a tail page (despite the head page not | ||
709 | * having PG_reserved set). Enforcing this consistency between | ||
710 | * head and tail pages allows drivers to optimize away a check | ||
711 | * on the head page when they need know if put_page() is needed | ||
712 | * after get_user_pages(). | ||
713 | */ | ||
714 | __ClearPageReserved(p); | ||
700 | set_page_count(p, 0); | 715 | set_page_count(p, 0); |
701 | p->first_page = page; | 716 | p->first_page = page; |
702 | } | 717 | } |
@@ -1329,9 +1344,9 @@ static void __init gather_bootmem_prealloc(void) | |||
1329 | #else | 1344 | #else |
1330 | page = virt_to_page(m); | 1345 | page = virt_to_page(m); |
1331 | #endif | 1346 | #endif |
1332 | __ClearPageReserved(page); | ||
1333 | WARN_ON(page_count(page) != 1); | 1347 | WARN_ON(page_count(page) != 1); |
1334 | prep_compound_huge_page(page, h->order); | 1348 | prep_compound_huge_page(page, h->order); |
1349 | WARN_ON(PageReserved(page)); | ||
1335 | prep_new_huge_page(h, page, page_to_nid(page)); | 1350 | prep_new_huge_page(h, page, page_to_nid(page)); |
1336 | /* | 1351 | /* |
1337 | * If we had gigantic hugepages allocated at boot time, we need | 1352 | * If we had gigantic hugepages allocated at boot time, we need |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 28243f7d9c23..9c9c685e4ddc 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -866,6 +866,7 @@ static unsigned long mem_cgroup_read_events(struct mem_cgroup *memcg, | |||
866 | unsigned long val = 0; | 866 | unsigned long val = 0; |
867 | int cpu; | 867 | int cpu; |
868 | 868 | ||
869 | get_online_cpus(); | ||
869 | for_each_online_cpu(cpu) | 870 | for_each_online_cpu(cpu) |
870 | val += per_cpu(memcg->stat->events[idx], cpu); | 871 | val += per_cpu(memcg->stat->events[idx], cpu); |
871 | #ifdef CONFIG_HOTPLUG_CPU | 872 | #ifdef CONFIG_HOTPLUG_CPU |
@@ -873,6 +874,7 @@ static unsigned long mem_cgroup_read_events(struct mem_cgroup *memcg, | |||
873 | val += memcg->nocpu_base.events[idx]; | 874 | val += memcg->nocpu_base.events[idx]; |
874 | spin_unlock(&memcg->pcp_counter_lock); | 875 | spin_unlock(&memcg->pcp_counter_lock); |
875 | #endif | 876 | #endif |
877 | put_online_cpus(); | ||
876 | return val; | 878 | return val; |
877 | } | 879 | } |
878 | 880 | ||
@@ -2159,110 +2161,59 @@ static void memcg_oom_recover(struct mem_cgroup *memcg) | |||
2159 | memcg_wakeup_oom(memcg); | 2161 | memcg_wakeup_oom(memcg); |
2160 | } | 2162 | } |
2161 | 2163 | ||
2162 | /* | ||
2163 | * try to call OOM killer | ||
2164 | */ | ||
2165 | static void mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int order) | 2164 | static void mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int order) |
2166 | { | 2165 | { |
2167 | bool locked; | ||
2168 | int wakeups; | ||
2169 | |||
2170 | if (!current->memcg_oom.may_oom) | 2166 | if (!current->memcg_oom.may_oom) |
2171 | return; | 2167 | return; |
2172 | |||
2173 | current->memcg_oom.in_memcg_oom = 1; | ||
2174 | |||
2175 | /* | 2168 | /* |
2176 | * As with any blocking lock, a contender needs to start | 2169 | * We are in the middle of the charge context here, so we |
2177 | * listening for wakeups before attempting the trylock, | 2170 | * don't want to block when potentially sitting on a callstack |
2178 | * otherwise it can miss the wakeup from the unlock and sleep | 2171 | * that holds all kinds of filesystem and mm locks. |
2179 | * indefinitely. This is just open-coded because our locking | 2172 | * |
2180 | * is so particular to memcg hierarchies. | 2173 | * Also, the caller may handle a failed allocation gracefully |
2174 | * (like optional page cache readahead) and so an OOM killer | ||
2175 | * invocation might not even be necessary. | ||
2176 | * | ||
2177 | * That's why we don't do anything here except remember the | ||
2178 | * OOM context and then deal with it at the end of the page | ||
2179 | * fault when the stack is unwound, the locks are released, | ||
2180 | * and when we know whether the fault was overall successful. | ||
2181 | */ | 2181 | */ |
2182 | wakeups = atomic_read(&memcg->oom_wakeups); | 2182 | css_get(&memcg->css); |
2183 | mem_cgroup_mark_under_oom(memcg); | 2183 | current->memcg_oom.memcg = memcg; |
2184 | 2184 | current->memcg_oom.gfp_mask = mask; | |
2185 | locked = mem_cgroup_oom_trylock(memcg); | 2185 | current->memcg_oom.order = order; |
2186 | |||
2187 | if (locked) | ||
2188 | mem_cgroup_oom_notify(memcg); | ||
2189 | |||
2190 | if (locked && !memcg->oom_kill_disable) { | ||
2191 | mem_cgroup_unmark_under_oom(memcg); | ||
2192 | mem_cgroup_out_of_memory(memcg, mask, order); | ||
2193 | mem_cgroup_oom_unlock(memcg); | ||
2194 | /* | ||
2195 | * There is no guarantee that an OOM-lock contender | ||
2196 | * sees the wakeups triggered by the OOM kill | ||
2197 | * uncharges. Wake any sleepers explicitely. | ||
2198 | */ | ||
2199 | memcg_oom_recover(memcg); | ||
2200 | } else { | ||
2201 | /* | ||
2202 | * A system call can just return -ENOMEM, but if this | ||
2203 | * is a page fault and somebody else is handling the | ||
2204 | * OOM already, we need to sleep on the OOM waitqueue | ||
2205 | * for this memcg until the situation is resolved. | ||
2206 | * Which can take some time because it might be | ||
2207 | * handled by a userspace task. | ||
2208 | * | ||
2209 | * However, this is the charge context, which means | ||
2210 | * that we may sit on a large call stack and hold | ||
2211 | * various filesystem locks, the mmap_sem etc. and we | ||
2212 | * don't want the OOM handler to deadlock on them | ||
2213 | * while we sit here and wait. Store the current OOM | ||
2214 | * context in the task_struct, then return -ENOMEM. | ||
2215 | * At the end of the page fault handler, with the | ||
2216 | * stack unwound, pagefault_out_of_memory() will check | ||
2217 | * back with us by calling | ||
2218 | * mem_cgroup_oom_synchronize(), possibly putting the | ||
2219 | * task to sleep. | ||
2220 | */ | ||
2221 | current->memcg_oom.oom_locked = locked; | ||
2222 | current->memcg_oom.wakeups = wakeups; | ||
2223 | css_get(&memcg->css); | ||
2224 | current->memcg_oom.wait_on_memcg = memcg; | ||
2225 | } | ||
2226 | } | 2186 | } |
2227 | 2187 | ||
2228 | /** | 2188 | /** |
2229 | * mem_cgroup_oom_synchronize - complete memcg OOM handling | 2189 | * mem_cgroup_oom_synchronize - complete memcg OOM handling |
2190 | * @handle: actually kill/wait or just clean up the OOM state | ||
2230 | * | 2191 | * |
2231 | * This has to be called at the end of a page fault if the the memcg | 2192 | * This has to be called at the end of a page fault if the memcg OOM |
2232 | * OOM handler was enabled and the fault is returning %VM_FAULT_OOM. | 2193 | * handler was enabled. |
2233 | * | 2194 | * |
2234 | * Memcg supports userspace OOM handling, so failed allocations must | 2195 | * Memcg supports userspace OOM handling where failed allocations must |
2235 | * sleep on a waitqueue until the userspace task resolves the | 2196 | * sleep on a waitqueue until the userspace task resolves the |
2236 | * situation. Sleeping directly in the charge context with all kinds | 2197 | * situation. Sleeping directly in the charge context with all kinds |
2237 | * of locks held is not a good idea, instead we remember an OOM state | 2198 | * of locks held is not a good idea, instead we remember an OOM state |
2238 | * in the task and mem_cgroup_oom_synchronize() has to be called at | 2199 | * in the task and mem_cgroup_oom_synchronize() has to be called at |
2239 | * the end of the page fault to put the task to sleep and clean up the | 2200 | * the end of the page fault to complete the OOM handling. |
2240 | * OOM state. | ||
2241 | * | 2201 | * |
2242 | * Returns %true if an ongoing memcg OOM situation was detected and | 2202 | * Returns %true if an ongoing memcg OOM situation was detected and |
2243 | * finalized, %false otherwise. | 2203 | * completed, %false otherwise. |
2244 | */ | 2204 | */ |
2245 | bool mem_cgroup_oom_synchronize(void) | 2205 | bool mem_cgroup_oom_synchronize(bool handle) |
2246 | { | 2206 | { |
2207 | struct mem_cgroup *memcg = current->memcg_oom.memcg; | ||
2247 | struct oom_wait_info owait; | 2208 | struct oom_wait_info owait; |
2248 | struct mem_cgroup *memcg; | 2209 | bool locked; |
2249 | 2210 | ||
2250 | /* OOM is global, do not handle */ | 2211 | /* OOM is global, do not handle */ |
2251 | if (!current->memcg_oom.in_memcg_oom) | ||
2252 | return false; | ||
2253 | |||
2254 | /* | ||
2255 | * We invoked the OOM killer but there is a chance that a kill | ||
2256 | * did not free up any charges. Everybody else might already | ||
2257 | * be sleeping, so restart the fault and keep the rampage | ||
2258 | * going until some charges are released. | ||
2259 | */ | ||
2260 | memcg = current->memcg_oom.wait_on_memcg; | ||
2261 | if (!memcg) | 2212 | if (!memcg) |
2262 | goto out; | 2213 | return false; |
2263 | 2214 | ||
2264 | if (test_thread_flag(TIF_MEMDIE) || fatal_signal_pending(current)) | 2215 | if (!handle) |
2265 | goto out_memcg; | 2216 | goto cleanup; |
2266 | 2217 | ||
2267 | owait.memcg = memcg; | 2218 | owait.memcg = memcg; |
2268 | owait.wait.flags = 0; | 2219 | owait.wait.flags = 0; |
@@ -2271,13 +2222,25 @@ bool mem_cgroup_oom_synchronize(void) | |||
2271 | INIT_LIST_HEAD(&owait.wait.task_list); | 2222 | INIT_LIST_HEAD(&owait.wait.task_list); |
2272 | 2223 | ||
2273 | prepare_to_wait(&memcg_oom_waitq, &owait.wait, TASK_KILLABLE); | 2224 | prepare_to_wait(&memcg_oom_waitq, &owait.wait, TASK_KILLABLE); |
2274 | /* Only sleep if we didn't miss any wakeups since OOM */ | 2225 | mem_cgroup_mark_under_oom(memcg); |
2275 | if (atomic_read(&memcg->oom_wakeups) == current->memcg_oom.wakeups) | 2226 | |
2227 | locked = mem_cgroup_oom_trylock(memcg); | ||
2228 | |||
2229 | if (locked) | ||
2230 | mem_cgroup_oom_notify(memcg); | ||
2231 | |||
2232 | if (locked && !memcg->oom_kill_disable) { | ||
2233 | mem_cgroup_unmark_under_oom(memcg); | ||
2234 | finish_wait(&memcg_oom_waitq, &owait.wait); | ||
2235 | mem_cgroup_out_of_memory(memcg, current->memcg_oom.gfp_mask, | ||
2236 | current->memcg_oom.order); | ||
2237 | } else { | ||
2276 | schedule(); | 2238 | schedule(); |
2277 | finish_wait(&memcg_oom_waitq, &owait.wait); | 2239 | mem_cgroup_unmark_under_oom(memcg); |
2278 | out_memcg: | 2240 | finish_wait(&memcg_oom_waitq, &owait.wait); |
2279 | mem_cgroup_unmark_under_oom(memcg); | 2241 | } |
2280 | if (current->memcg_oom.oom_locked) { | 2242 | |
2243 | if (locked) { | ||
2281 | mem_cgroup_oom_unlock(memcg); | 2244 | mem_cgroup_oom_unlock(memcg); |
2282 | /* | 2245 | /* |
2283 | * There is no guarantee that an OOM-lock contender | 2246 | * There is no guarantee that an OOM-lock contender |
@@ -2286,10 +2249,9 @@ out_memcg: | |||
2286 | */ | 2249 | */ |
2287 | memcg_oom_recover(memcg); | 2250 | memcg_oom_recover(memcg); |
2288 | } | 2251 | } |
2252 | cleanup: | ||
2253 | current->memcg_oom.memcg = NULL; | ||
2289 | css_put(&memcg->css); | 2254 | css_put(&memcg->css); |
2290 | current->memcg_oom.wait_on_memcg = NULL; | ||
2291 | out: | ||
2292 | current->memcg_oom.in_memcg_oom = 0; | ||
2293 | return true; | 2255 | return true; |
2294 | } | 2256 | } |
2295 | 2257 | ||
@@ -2703,6 +2665,9 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm, | |||
2703 | || fatal_signal_pending(current))) | 2665 | || fatal_signal_pending(current))) |
2704 | goto bypass; | 2666 | goto bypass; |
2705 | 2667 | ||
2668 | if (unlikely(task_in_memcg_oom(current))) | ||
2669 | goto bypass; | ||
2670 | |||
2706 | /* | 2671 | /* |
2707 | * We always charge the cgroup the mm_struct belongs to. | 2672 | * We always charge the cgroup the mm_struct belongs to. |
2708 | * The mm_struct's mem_cgroup changes on task migration if the | 2673 | * The mm_struct's mem_cgroup changes on task migration if the |
@@ -2801,6 +2766,8 @@ done: | |||
2801 | return 0; | 2766 | return 0; |
2802 | nomem: | 2767 | nomem: |
2803 | *ptr = NULL; | 2768 | *ptr = NULL; |
2769 | if (gfp_mask & __GFP_NOFAIL) | ||
2770 | return 0; | ||
2804 | return -ENOMEM; | 2771 | return -ENOMEM; |
2805 | bypass: | 2772 | bypass: |
2806 | *ptr = root_mem_cgroup; | 2773 | *ptr = root_mem_cgroup; |
diff --git a/mm/memory.c b/mm/memory.c index ca0003947115..1311f26497e6 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -837,6 +837,8 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, | |||
837 | */ | 837 | */ |
838 | make_migration_entry_read(&entry); | 838 | make_migration_entry_read(&entry); |
839 | pte = swp_entry_to_pte(entry); | 839 | pte = swp_entry_to_pte(entry); |
840 | if (pte_swp_soft_dirty(*src_pte)) | ||
841 | pte = pte_swp_mksoft_dirty(pte); | ||
840 | set_pte_at(src_mm, addr, src_pte, pte); | 842 | set_pte_at(src_mm, addr, src_pte, pte); |
841 | } | 843 | } |
842 | } | 844 | } |
@@ -3863,15 +3865,21 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
3863 | * space. Kernel faults are handled more gracefully. | 3865 | * space. Kernel faults are handled more gracefully. |
3864 | */ | 3866 | */ |
3865 | if (flags & FAULT_FLAG_USER) | 3867 | if (flags & FAULT_FLAG_USER) |
3866 | mem_cgroup_enable_oom(); | 3868 | mem_cgroup_oom_enable(); |
3867 | 3869 | ||
3868 | ret = __handle_mm_fault(mm, vma, address, flags); | 3870 | ret = __handle_mm_fault(mm, vma, address, flags); |
3869 | 3871 | ||
3870 | if (flags & FAULT_FLAG_USER) | 3872 | if (flags & FAULT_FLAG_USER) { |
3871 | mem_cgroup_disable_oom(); | 3873 | mem_cgroup_oom_disable(); |
3872 | 3874 | /* | |
3873 | if (WARN_ON(task_in_memcg_oom(current) && !(ret & VM_FAULT_OOM))) | 3875 | * The task may have entered a memcg OOM situation but |
3874 | mem_cgroup_oom_synchronize(); | 3876 | * if the allocation error was handled gracefully (no |
3877 | * VM_FAULT_OOM), there is no need to kill anything. | ||
3878 | * Just clean up the OOM state peacefully. | ||
3879 | */ | ||
3880 | if (task_in_memcg_oom(current) && !(ret & VM_FAULT_OOM)) | ||
3881 | mem_cgroup_oom_synchronize(false); | ||
3882 | } | ||
3875 | 3883 | ||
3876 | return ret; | 3884 | return ret; |
3877 | } | 3885 | } |
diff --git a/mm/migrate.c b/mm/migrate.c index a26bccd44ccb..7a7325ee1d08 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -161,6 +161,8 @@ static int remove_migration_pte(struct page *new, struct vm_area_struct *vma, | |||
161 | 161 | ||
162 | get_page(new); | 162 | get_page(new); |
163 | pte = pte_mkold(mk_pte(new, vma->vm_page_prot)); | 163 | pte = pte_mkold(mk_pte(new, vma->vm_page_prot)); |
164 | if (pte_swp_soft_dirty(*ptep)) | ||
165 | pte = pte_mksoft_dirty(pte); | ||
164 | if (is_write_migration_entry(entry)) | 166 | if (is_write_migration_entry(entry)) |
165 | pte = pte_mkwrite(pte); | 167 | pte = pte_mkwrite(pte); |
166 | #ifdef CONFIG_HUGETLB_PAGE | 168 | #ifdef CONFIG_HUGETLB_PAGE |
diff --git a/mm/mprotect.c b/mm/mprotect.c index 94722a4d6b43..a3af058f68e4 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c | |||
@@ -94,13 +94,16 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd, | |||
94 | swp_entry_t entry = pte_to_swp_entry(oldpte); | 94 | swp_entry_t entry = pte_to_swp_entry(oldpte); |
95 | 95 | ||
96 | if (is_write_migration_entry(entry)) { | 96 | if (is_write_migration_entry(entry)) { |
97 | pte_t newpte; | ||
97 | /* | 98 | /* |
98 | * A protection check is difficult so | 99 | * A protection check is difficult so |
99 | * just be safe and disable write | 100 | * just be safe and disable write |
100 | */ | 101 | */ |
101 | make_migration_entry_read(&entry); | 102 | make_migration_entry_read(&entry); |
102 | set_pte_at(mm, addr, pte, | 103 | newpte = swp_entry_to_pte(entry); |
103 | swp_entry_to_pte(entry)); | 104 | if (pte_swp_soft_dirty(oldpte)) |
105 | newpte = pte_swp_mksoft_dirty(newpte); | ||
106 | set_pte_at(mm, addr, pte, newpte); | ||
104 | } | 107 | } |
105 | pages++; | 108 | pages++; |
106 | } | 109 | } |
diff --git a/mm/mremap.c b/mm/mremap.c index 91b13d6a16d4..0843feb66f3d 100644 --- a/mm/mremap.c +++ b/mm/mremap.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
26 | #include <asm/cacheflush.h> | 26 | #include <asm/cacheflush.h> |
27 | #include <asm/tlbflush.h> | 27 | #include <asm/tlbflush.h> |
28 | #include <asm/pgalloc.h> | ||
29 | 28 | ||
30 | #include "internal.h" | 29 | #include "internal.h" |
31 | 30 | ||
@@ -63,10 +62,8 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma, | |||
63 | return NULL; | 62 | return NULL; |
64 | 63 | ||
65 | pmd = pmd_alloc(mm, pud, addr); | 64 | pmd = pmd_alloc(mm, pud, addr); |
66 | if (!pmd) { | 65 | if (!pmd) |
67 | pud_free(mm, pud); | ||
68 | return NULL; | 66 | return NULL; |
69 | } | ||
70 | 67 | ||
71 | VM_BUG_ON(pmd_trans_huge(*pmd)); | 68 | VM_BUG_ON(pmd_trans_huge(*pmd)); |
72 | 69 | ||
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 314e9d274381..6738c47f1f72 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -680,7 +680,7 @@ void pagefault_out_of_memory(void) | |||
680 | { | 680 | { |
681 | struct zonelist *zonelist; | 681 | struct zonelist *zonelist; |
682 | 682 | ||
683 | if (mem_cgroup_oom_synchronize()) | 683 | if (mem_cgroup_oom_synchronize(true)) |
684 | return; | 684 | return; |
685 | 685 | ||
686 | zonelist = node_zonelist(first_online_node, GFP_KERNEL); | 686 | zonelist = node_zonelist(first_online_node, GFP_KERNEL); |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index f5236f804aa6..63807583d8e8 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -1210,11 +1210,11 @@ static unsigned long dirty_poll_interval(unsigned long dirty, | |||
1210 | return 1; | 1210 | return 1; |
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | static long bdi_max_pause(struct backing_dev_info *bdi, | 1213 | static unsigned long bdi_max_pause(struct backing_dev_info *bdi, |
1214 | unsigned long bdi_dirty) | 1214 | unsigned long bdi_dirty) |
1215 | { | 1215 | { |
1216 | long bw = bdi->avg_write_bandwidth; | 1216 | unsigned long bw = bdi->avg_write_bandwidth; |
1217 | long t; | 1217 | unsigned long t; |
1218 | 1218 | ||
1219 | /* | 1219 | /* |
1220 | * Limit pause time for small memory systems. If sleeping for too long | 1220 | * Limit pause time for small memory systems. If sleeping for too long |
@@ -1226,7 +1226,7 @@ static long bdi_max_pause(struct backing_dev_info *bdi, | |||
1226 | t = bdi_dirty / (1 + bw / roundup_pow_of_two(1 + HZ / 8)); | 1226 | t = bdi_dirty / (1 + bw / roundup_pow_of_two(1 + HZ / 8)); |
1227 | t++; | 1227 | t++; |
1228 | 1228 | ||
1229 | return min_t(long, t, MAX_PAUSE); | 1229 | return min_t(unsigned long, t, MAX_PAUSE); |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | static long bdi_min_pause(struct backing_dev_info *bdi, | 1232 | static long bdi_min_pause(struct backing_dev_info *bdi, |
diff --git a/mm/slab_common.c b/mm/slab_common.c index a3443278ce3a..e2e98af703ea 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c | |||
@@ -56,6 +56,7 @@ static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name, | |||
56 | continue; | 56 | continue; |
57 | } | 57 | } |
58 | 58 | ||
59 | #if !defined(CONFIG_SLUB) || !defined(CONFIG_SLUB_DEBUG_ON) | ||
59 | /* | 60 | /* |
60 | * For simplicity, we won't check this in the list of memcg | 61 | * For simplicity, we won't check this in the list of memcg |
61 | * caches. We have control over memcg naming, and if there | 62 | * caches. We have control over memcg naming, and if there |
@@ -69,6 +70,7 @@ static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name, | |||
69 | s = NULL; | 70 | s = NULL; |
70 | return -EINVAL; | 71 | return -EINVAL; |
71 | } | 72 | } |
73 | #endif | ||
72 | } | 74 | } |
73 | 75 | ||
74 | WARN_ON(strchr(name, ' ')); /* It confuses parsers */ | 76 | WARN_ON(strchr(name, ' ')); /* It confuses parsers */ |
diff --git a/mm/swapfile.c b/mm/swapfile.c index 3963fc24fcc1..de7c904e52e5 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -1824,6 +1824,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
1824 | struct filename *pathname; | 1824 | struct filename *pathname; |
1825 | int i, type, prev; | 1825 | int i, type, prev; |
1826 | int err; | 1826 | int err; |
1827 | unsigned int old_block_size; | ||
1827 | 1828 | ||
1828 | if (!capable(CAP_SYS_ADMIN)) | 1829 | if (!capable(CAP_SYS_ADMIN)) |
1829 | return -EPERM; | 1830 | return -EPERM; |
@@ -1914,6 +1915,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
1914 | } | 1915 | } |
1915 | 1916 | ||
1916 | swap_file = p->swap_file; | 1917 | swap_file = p->swap_file; |
1918 | old_block_size = p->old_block_size; | ||
1917 | p->swap_file = NULL; | 1919 | p->swap_file = NULL; |
1918 | p->max = 0; | 1920 | p->max = 0; |
1919 | swap_map = p->swap_map; | 1921 | swap_map = p->swap_map; |
@@ -1938,7 +1940,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
1938 | inode = mapping->host; | 1940 | inode = mapping->host; |
1939 | if (S_ISBLK(inode->i_mode)) { | 1941 | if (S_ISBLK(inode->i_mode)) { |
1940 | struct block_device *bdev = I_BDEV(inode); | 1942 | struct block_device *bdev = I_BDEV(inode); |
1941 | set_blocksize(bdev, p->old_block_size); | 1943 | set_blocksize(bdev, old_block_size); |
1942 | blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); | 1944 | blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); |
1943 | } else { | 1945 | } else { |
1944 | mutex_lock(&inode->i_mutex); | 1946 | mutex_lock(&inode->i_mutex); |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 53f2f82f83ae..eea668d9cff6 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -211,6 +211,7 @@ void unregister_shrinker(struct shrinker *shrinker) | |||
211 | down_write(&shrinker_rwsem); | 211 | down_write(&shrinker_rwsem); |
212 | list_del(&shrinker->list); | 212 | list_del(&shrinker->list); |
213 | up_write(&shrinker_rwsem); | 213 | up_write(&shrinker_rwsem); |
214 | kfree(shrinker->nr_deferred); | ||
214 | } | 215 | } |
215 | EXPORT_SYMBOL(unregister_shrinker); | 216 | EXPORT_SYMBOL(unregister_shrinker); |
216 | 217 | ||
diff --git a/mm/zswap.c b/mm/zswap.c index 841e35f1db22..d93510c6aa2d 100644 --- a/mm/zswap.c +++ b/mm/zswap.c | |||
@@ -804,6 +804,10 @@ static void zswap_frontswap_invalidate_area(unsigned type) | |||
804 | } | 804 | } |
805 | tree->rbroot = RB_ROOT; | 805 | tree->rbroot = RB_ROOT; |
806 | spin_unlock(&tree->lock); | 806 | spin_unlock(&tree->lock); |
807 | |||
808 | zbud_destroy_pool(tree->pool); | ||
809 | kfree(tree); | ||
810 | zswap_trees[type] = NULL; | ||
807 | } | 811 | } |
808 | 812 | ||
809 | static struct zbud_ops zswap_zbud_ops = { | 813 | static struct zbud_ops zswap_zbud_ops = { |