From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760017AbcLPKqX (ORCPT ); Fri, 16 Dec 2016 05:46:23 -0500 Received: from mail-wj0-f196.google.com ([209.85.210.196]:35409 "EHLO mail-wj0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753907AbcLPKqO (ORCPT ); Fri, 16 Dec 2016 05:46:14 -0500 Date: Fri, 16 Dec 2016 13:44:38 +0300 From: "Kirill A. Shutemov" To: Michal Hocko Cc: Vegard Nossum , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Rik van Riel , Matthew Wilcox , Peter Zijlstra , Andrew Morton , Al Viro , Ingo Molnar , Linus Torvalds Subject: Re: crash during oom reaper (was: Re: [PATCH 4/4] [RFC!] mm: 'struct mm_struct' reference counting debugging) Message-ID: <20161216104438.GD27758@node> References: <20161216082202.21044-1-vegard.nossum@oracle.com> <20161216082202.21044-4-vegard.nossum@oracle.com> <20161216090157.GA13940@dhcp22.suse.cz> <20161216101113.GE13940@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161216101113.GE13940@dhcp22.suse.cz> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 16, 2016 at 11:11:13AM +0100, Michal Hocko wrote: > On Fri 16-12-16 10:43:52, Vegard Nossum wrote: > [...] > > I don't think it's a bug in the OOM reaper itself, but either of the > > following two patches will fix the problem (without my understand how or > > why): > > > > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > > index ec9f11d4f094..37b14b2e2af4 100644 > > --- a/mm/oom_kill.c > > +++ b/mm/oom_kill.c > > @@ -485,7 +485,7 @@ static bool __oom_reap_task_mm(struct task_struct *tsk, > > struct mm_struct *mm) > > */ > > mutex_lock(&oom_lock); > > > > - if (!down_read_trylock(&mm->mmap_sem)) { > > + if (!down_write_trylock(&mm->mmap_sem)) { > > __oom_reap_task_mm is basically the same thing as MADV_DONTNEED and that > doesn't require the exlusive mmap_sem. So this looks correct to me. BTW, shouldn't we filter out all VM_SPECIAL VMAs there? Or VM_PFNMAP at least. MADV_DONTNEED doesn't touch VM_PFNMAP, but I don't see anything matching on __oom_reap_task_mm() side. Other difference is that you use unmap_page_range() witch doesn't touch mmu_notifiers. MADV_DONTNEED goes via zap_page_range(), which invalidates the range. Not sure if it can make any difference here. -- Kirill A. Shutemov