From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757936AbbIVOs4 (ORCPT ); Tue, 22 Sep 2015 10:48:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32971 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751863AbbIVOsy (ORCPT ); Tue, 22 Sep 2015 10:48:54 -0400 Date: Tue, 22 Sep 2015 16:45:51 +0200 From: Oleg Nesterov To: Tetsuo Handa Cc: mhocko@kernel.org, torvalds@linux-foundation.org, kwalker@redhat.com, cl@linux.com, akpm@linux-foundation.org, rientjes@google.com, hannes@cmpxchg.org, vdavydov@parallels.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, skozina@redhat.com Subject: Re: can't oom-kill zap the victim's memory? Message-ID: <20150922144551.GA31154@redhat.com> References: <20150921134414.GA15974@redhat.com> <20150921142423.GC19811@dhcp22.suse.cz> <20150921153252.GA21988@redhat.com> <201509220151.CHF17629.LFFJSHQVOMtOFO@I-love.SAKURA.ne.jp> <20150922124303.GA24570@redhat.com> <201509222330.JDI64510.FOLOFQStMVFJOH@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201509222330.JDI64510.FOLOFQStMVFJOH@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/22, Tetsuo Handa wrote: > > Oleg Nesterov wrote: > > On 09/22, Tetsuo Handa wrote: > > > rcu_read_lock(); > > > for_each_process_thread(g, p) { > > > if (likely(!fatal_signal_pending(p))) > > > continue; > > > task_lock(p); > > > mm = p->mm; > > > if (mm && mm->mmap && !mm->mmap_zapped && down_read_trylock(&mm->mmap_sem)) { > > ^^^^^^^^^^^^^^^ > > > > We do not want mm->mmap_zapped, it can't work. We need mm->needs_zap > > set by oom_kill_process() and cleared after zap_page_range(). > > > > Because otherwise we can not handle CLONE_VM correctly. Suppose that > > an innocent process P does vfork() and the child is killed but not > > exited yet. mm_zapper() can find the child, do zap_page_range(), and > > surprise its alive parent P which uses the same ->mm. > > kill(P's-child, SIGKILL) does not kill P sharing the same ->mm. > Thus, mm_zapper() can be used for only OOM-kill case Yes, and only if we know for sure that all tasks which can use this ->mm were killed. > and > test_tsk_thread_flag(p, TIF_MEMDIE) should be used than > fatal_signal_pending(p). No. For example, just look at mark_oom_victim() at the start of out_of_memory(). > > Tetsuo, can't we do something simple which "obviously can't hurt at > > least" and then discuss the potential improvements? > > No problem. I can wait for your version. All I wanted to say is that this all is a bit more complicated than it looks at first glance. Oleg.