From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933070AbbJHOB6 (ORCPT ); Thu, 8 Oct 2015 10:01:58 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:35585 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932550AbbJHOB5 (ORCPT ); Thu, 8 Oct 2015 10:01:57 -0400 Date: Thu, 8 Oct 2015 16:01:55 +0200 From: Michal Hocko To: Oleg Nesterov Cc: Linus Torvalds , Kyle Walker , Christoph Lameter , Andrew Morton , David Rientjes , Johannes Weiner , Vladimir Davydov , linux-mm , Linux Kernel Mailing List , Stanislav Kozina , Tetsuo Handa Subject: Re: can't oom-kill zap the victim's memory? Message-ID: <20151008140155.GB426@dhcp22.suse.cz> References: <20150920125642.GA2104@redhat.com> <20150921134414.GA15974@redhat.com> <20150921142423.GC19811@dhcp22.suse.cz> <20150921153252.GA21988@redhat.com> <20150921161203.GD19811@dhcp22.suse.cz> <20150922160608.GA2716@redhat.com> <20150923205923.GB19054@dhcp22.suse.cz> <20151006184502.GA15787@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151006184502.GA15787@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 06-10-15 20:45:02, Oleg Nesterov wrote: [...] > And I was going to make V1 which avoids queue_work/kthread and zaps the > memory in oom_kill_process() context. > > But this can't work because we need to increment ->mm_users to avoid > the race with exit_mmap/etc. And this means that we need mmput() after > that, and as we recently discussed it can deadlock if mm_users goes > to zero, we can't do exit_mmap/etc in oom_kill_process(). Right. I hoped we could rely on mm_count just to pin mm but that is not sufficient because exit_mmap doesn't rely on mmap_sem so we do not have any synchronization there. Unfortunate. This means that we indeed have to do it asynchronously. Maybe we can come up with some trickery but let's do it later. I do agree that going with a kernel thread for now would be easier. Sorry about misleading you, I should have realized that mmput from the oom killing path is dangerous. -- Michal Hocko SUSE Labs