Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2076153ima; Mon, 22 Oct 2018 03:58:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV62dNQAwP/vqWRPKk5fee+Idc/v3oFj5CJr3/W9ifHAlsoQR9BLRpLanfrJJTJzF0sUAFWxX X-Received: by 2002:a62:fb04:: with SMTP id x4-v6mr44954743pfm.210.1540205932547; Mon, 22 Oct 2018 03:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540205932; cv=none; d=google.com; s=arc-20160816; b=rKQ++k3QOglygAY5XzLuiLV6Ef0REHsXdjKcERiXs+LNL+iW4kOPHYEDWI9fUuYx7S H912fMF2zBd4T5l5nZPIvHrrzMHyVjRZdbNO5vTlbEnfzJ3bh0sN/BQdwnh41l4ti1E4 Hn/B47vysNlQlkuWJc7S41DEIzwE17v5tnp7S8QK3sqTDAXfTMDfZikKhnRq0VAeinC6 mw6vjIshl9LIS3FgcUSSsINbIAcXCwyEi3n1hmmTWXLTIvIw4mqrucVTlKMLCLQIQs9X 6gRk17SXGFMt8RhAR+1W5btNm7klO7X8wfgH/r6MbFINB/es6vfQh6K65pJuRBV2EZqj eqHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=G6Tz+sAKs1gMOGzH1YZ8a0avAD4lIgZGcuZdSpHsO8E=; b=NiCNvuIeErHZwppeUwc0AcXxCoKMu3v32z1CEV6zOhm46Z4LoDk/RLWKxn0m+H+OTU nm2htuKqUGfhnCAir68M4L38RA9GYZ+Cowlmc9A7SLe3DH8QkalsfDpm2XEgOyHKYFR5 hWDlyPo00nKyK0Yz7CaWGsboRXCt5Sjy5ctMdBAfXnjuMKdMoIbNIgRdk+y6trogT9ZL ZZI2aW8j7+Ax/bga+FThXQaYdOLBmv4zZ+tpnrkTOaWAzm8wnfz85nWMG0bDlXUfWPlo wogPyYz6uHDzOprjn85z1ilBe8X/EUiGk6pAIq68aSRs1PgtXtgr+NUSaZcLeS6FVtOF o7nA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f14-v6si6100211pgr.259.2018.10.22.03.58.36; Mon, 22 Oct 2018 03:58:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728787AbeJVTPN (ORCPT + 99 others); Mon, 22 Oct 2018 15:15:13 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:39954 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727857AbeJVTPN (ORCPT ); Mon, 22 Oct 2018 15:15:13 -0400 Received: from fsav104.sakura.ne.jp (fsav104.sakura.ne.jp [27.133.134.231]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w9MAuqVL046291; Mon, 22 Oct 2018 19:56:52 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav104.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav104.sakura.ne.jp); Mon, 22 Oct 2018 19:56:52 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav104.sakura.ne.jp) Received: from [192.168.1.8] (softbank060157066051.bbtec.net [60.157.66.51]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w9MAupSs046287 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 22 Oct 2018 19:56:52 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [RFC PATCH 1/2] mm, oom: marks all killed tasks as oom victims To: Michal Hocko Cc: linux-mm@kvack.org, Johannes Weiner , David Rientjes , Andrew Morton , LKML References: <20181022071323.9550-1-mhocko@kernel.org> <20181022071323.9550-2-mhocko@kernel.org> <201810220758.w9M7wojE016890@www262.sakura.ne.jp> <20181022084842.GW18839@dhcp22.suse.cz> <20181022104341.GY18839@dhcp22.suse.cz> From: Tetsuo Handa Message-ID: <93f99371-cff8-fc31-a594-eecdff299f16@i-love.sakura.ne.jp> Date: Mon, 22 Oct 2018 19:56:49 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181022104341.GY18839@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/10/22 19:43, Michal Hocko wrote: > On Mon 22-10-18 18:42:30, Tetsuo Handa wrote: >> On 2018/10/22 17:48, Michal Hocko wrote: >>> On Mon 22-10-18 16:58:50, Tetsuo Handa wrote: >>>> Michal Hocko wrote: >>>>> --- a/mm/oom_kill.c >>>>> +++ b/mm/oom_kill.c >>>>> @@ -898,6 +898,7 @@ static void __oom_kill_process(struct task_struct *victim) >>>>> if (unlikely(p->flags & PF_KTHREAD)) >>>>> continue; >>>>> do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, PIDTYPE_TGID); >>>>> + mark_oom_victim(p); >>>>> } >>>>> rcu_read_unlock(); >>>>> >>>>> -- >>>> >>>> Wrong. Either >>> >>> You are right. The mm might go away between process_shares_mm and here. >>> While your find_lock_task_mm would be correct I believe we can do better >>> by using the existing mm that we already have. I will make it a separate >>> patch to clarity. >> >> Still wrong. p->mm == NULL means that we are too late to set TIF_MEMDIE >> on that thread. Passing non-NULL mm to mark_oom_victim() won't help. > > Why would it be too late? Or in other words why would this be harmful? > Setting TIF_MEMDIE after exit_mm() completed is too late. static void exit_mm(void) { (...snipped...) task_lock(current); current->mm = NULL; up_read(&mm->mmap_sem); enter_lazy_tlb(mm, current); task_unlock(current); mm_update_next_owner(mm); mmput(mm); if (test_thread_flag(TIF_MEMDIE)) exit_oom_victim(); }