From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752702AbbISXAd (ORCPT ); Sat, 19 Sep 2015 19:00:33 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:33636 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752297AbbISXAc (ORCPT ); Sat, 19 Sep 2015 19:00:32 -0400 Subject: Re: can't oom-kill zap the victim's memory? To: Linus Torvalds , Oleg Nesterov References: <1442512783-14719-1-git-send-email-kwalker@redhat.com> <20150919150316.GB31952@redhat.com> Cc: Kyle Walker , Christoph Lameter , Michal Hocko , Andrew Morton , David Rientjes , Johannes Weiner , Vladimir Davydov , linux-mm , Linux Kernel Mailing List , Stanislav Kozina , Tetsuo Handa From: Raymond Jennings Message-ID: <55FDE90D.1070402@gmail.com> Date: Sat, 19 Sep 2015 16:00:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/19/15 15:24, Linus Torvalds wrote: > On Sat, Sep 19, 2015 at 8:03 AM, Oleg Nesterov wrote: >> + >> +static void oom_unmap_func(struct work_struct *work) >> +{ >> + struct mm_struct *mm = xchg(&oom_unmap_mm, NULL); >> + >> + if (!atomic_inc_not_zero(&mm->mm_users)) >> + return; >> + >> + // If this is not safe we can do use_mm() + unuse_mm() >> + down_read(&mm->mmap_sem); > I don't think this is safe. > > What makes you sure that we might not deadlock on the mmap_sem here? > For all we know, the process that is going out of memory is in the > middle of a mmap(), and already holds the mmap_sem for writing. No? Potentially stupid question that others may be asking: Is it legal to return EINTR from mmap() to let a SIGKILL from the OOM handler punch the task out of the kernel and back to userspace? (sorry for the dupe btw, new email client snuck in html and I got bounced) > So at the very least that needs to be a trylock, I think. And I'm not > sure zap_page_range() is ok with the mmap_sem only held for reading. > Normally our rule is that you can *populate* the page tables > concurrently, but you can't tear the down. > > Linus > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org