Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752908AbcCVWpk (ORCPT ); Tue, 22 Mar 2016 18:45:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33342 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752831AbcCVWpf (ORCPT ); Tue, 22 Mar 2016 18:45:35 -0400 Date: Tue, 22 Mar 2016 15:45:33 -0700 From: Andrew Morton To: Michal Hocko Cc: , LKML , Tetsuo Handa , David Rientjes , Michal Hocko Subject: Re: [PATCH 2/9] mm, oom: introduce oom reaper Message-Id: <20160322154533.c269d76a65b81bb1b8f72545@linux-foundation.org> In-Reply-To: <1458644426-22973-3-git-send-email-mhocko@kernel.org> References: <1458644426-22973-1-git-send-email-mhocko@kernel.org> <1458644426-22973-3-git-send-email-mhocko@kernel.org> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2491 Lines: 69 On Tue, 22 Mar 2016 12:00:19 +0100 Michal Hocko wrote: > This is based on the idea from Mel Gorman discussed during LSFMM 2015 and > independently brought up by Oleg Nesterov. What happened to oom-reaper-handle-mlocked-pages.patch? I have it in -mm but I don't see it in this v6. From: Michal Hocko Subject: oom reaper: handle mlocked pages __oom_reap_vmas current skips over all mlocked vmas because they need a special treatment before they are unmapped. This is primarily done for simplicity. There is no reason to skip over them and reduce the amount of reclaimed memory. This is safe from the semantic point of view because try_to_unmap_one during rmap walk would keep tell the reclaim to cull the page back and mlock it again. munlock_vma_pages_all is also safe to be called from the oom reaper context because it doesn't sit on any locks but mmap_sem (for read). Signed-off-by: Michal Hocko Cc: Andrea Argangeli Acked-by: David Rientjes Cc: Hugh Dickins Cc: Johannes Weiner Cc: Mel Gorman Cc: Oleg Nesterov Cc: Rik van Riel Cc: Tetsuo Handa Signed-off-by: Andrew Morton --- mm/oom_kill.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff -puN mm/oom_kill.c~oom-reaper-handle-mlocked-pages mm/oom_kill.c --- a/mm/oom_kill.c~oom-reaper-handle-mlocked-pages +++ a/mm/oom_kill.c @@ -442,13 +442,6 @@ static bool __oom_reap_vmas(struct mm_st continue; /* - * mlocked VMAs require explicit munlocking before unmap. - * Let's keep it simple here and skip such VMAs. - */ - if (vma->vm_flags & VM_LOCKED) - continue; - - /* * Only anonymous pages have a good chance to be dropped * without additional steps which we cannot afford as we * are OOM already. @@ -458,9 +451,12 @@ static bool __oom_reap_vmas(struct mm_st * we do not want to block exit_mmap by keeping mm ref * count elevated without a good reason. */ - if (vma_is_anonymous(vma) || !(vma->vm_flags & VM_SHARED)) + if (vma_is_anonymous(vma) || !(vma->vm_flags & VM_SHARED)) { + if (vma->vm_flags & VM_LOCKED) + munlock_vma_pages_all(vma); unmap_page_range(&tlb, vma, vma->vm_start, vma->vm_end, &details); + } } tlb_finish_mmu(&tlb, 0, -1); up_read(&mm->mmap_sem); _