Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2498116imm; Thu, 9 Aug 2018 14:07:22 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzCkgDRCJSutsQIv/mXRUSE1XLrcKrsPY0l1hf7XpC09lw4hlM1EKPoIPeLWDvsRGjLp+3t X-Received: by 2002:a17:902:654b:: with SMTP id d11-v6mr3423394pln.8.1533848842584; Thu, 09 Aug 2018 14:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533848842; cv=none; d=google.com; s=arc-20160816; b=biiPhqsqgJaxxgZTOBcxuJXc6qFQBFQk++azuyzvpXb5gAxNGn/vBVk8CfdUFAnQvW XqHr/bnjtcN53YcqlDscEp9QY1og3xYYenuRu8uo75jxEu7JbACqOobyroKWOrgQ3BTk q5pB/njAi5A4mmvCNfzrCZ+mBdqngSaG6KGRPOLtIrpfcomZLVewL6DgK2/mBB07BjkB HS6uoeQLzHsag+MATq0wHl/E+NIoaGj2gKD/KwTSLHbzXRmYNx7hBj9y3ouXQ/n6mCfx +fEQGQJHw8uRYoeKmzsDr57dVZuAc0IxuJw/soDTRboY9XWqvTKArAOljoQUJAtSiemi DhFA== 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:arc-authentication-results; bh=bpAf/cyTYmfRf7F6mJVqEkiCTggiWGiJiO42T22PpnQ=; b=b7CZKuT9bBsnMoF294o+hH/ooejY8Z95M8DqtGh2ZOvpx40cfSM50ROXSMpV7MckLf zc2N0Zil5ur7+SVx27xmDkguL1lDGBQEwWWvDwLzsUkGbg6/iEtRm0eaCNW9mKp41D8w MOTSWZfY0y1irXEHaDh1U6c+geEntKTa8ayBJLY+E8ofRsuWocJcJaJOhxgtAYo8t22w p2B8jm9oxMf0IHCdgQOEnja3SdAZVG1xnRx94s5mlQX1GN4/eHwcJwTWdP84DY2m3L/0 SowyKb2nKFVNWiQToYvzWJFFVHeygJ48kdeUahRXnMHBZ6ZyxJgurZtNY/KszBG+T6sR eKjw== 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 l6-v6si8021405pfc.298.2018.08.09.14.07.07; Thu, 09 Aug 2018 14:07:22 -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 S1727358AbeHIXcE (ORCPT + 99 others); Thu, 9 Aug 2018 19:32:04 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:43790 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727336AbeHIXcE (ORCPT ); Thu, 9 Aug 2018 19:32:04 -0400 Received: from fsav403.sakura.ne.jp (fsav403.sakura.ne.jp [133.242.250.102]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w79L5PsO037944; Fri, 10 Aug 2018 06:05:25 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav403.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav403.sakura.ne.jp); Fri, 10 Aug 2018 06:05:25 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav403.sakura.ne.jp) Received: from [192.168.1.8] (softbank126074194044.bbtec.net [126.74.194.44]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w79L5I0G037934 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 10 Aug 2018 06:05:25 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: WARNING in try_charge To: Michal Hocko Cc: Vladimir Davydov , Oleg Nesterov , David Rientjes , syzbot , cgroups@vger.kernel.org, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com, Andrew Morton References: <0000000000005e979605729c1564@google.com> <20180809150735.GA15611@dhcp22.suse.cz> From: Tetsuo Handa Message-ID: <56c95100-d7f9-b715-bdec-e8bb112e2630@i-love.sakura.ne.jp> Date: Fri, 10 Aug 2018 06:05:19 +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: <20180809150735.GA15611@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/08/10 0:07, Michal Hocko wrote: > On Thu 09-08-18 22:57:43, Tetsuo Handa wrote: >> >From b1f38168f14397c7af9c122cd8207663d96e02ec Mon Sep 17 00:00:00 2001 >> From: Tetsuo Handa >> Date: Thu, 9 Aug 2018 22:49:40 +0900 >> Subject: [PATCH] mm, oom: task_will_free_mem(current) should retry until >> memory reserve fails >> >> Commit 696453e66630ad45 ("mm, oom: task_will_free_mem should skip >> oom_reaped tasks") changed to select next OOM victim as soon as >> MMF_OOM_SKIP is set. But we don't need to select next OOM victim as >> long as ALLOC_OOM allocation can succeed. And syzbot is hitting WARN(1) >> caused by this race window [1]. > > It is not because the syzbot was exercising a completely different code > path (memcg charge rather than the page allocator). I know syzbot is hitting memcg charge path. > >> Since memcg OOM case uses forced charge if current thread is killed, >> out_of_memory() can return true without selecting next OOM victim. >> Therefore, this patch changes task_will_free_mem(current) to ignore >> MMF_OOM_SKIP unless ALLOC_OOM allocation failed. > > And the patch is simply wrong for memcg. > Why? I think I should have done -+ page = __alloc_pages_may_oom(gfp_mask, order, alloc_flags == ALLOC_OOM -+ || (gfp_mask & __GFP_NOMEMALLOC), ac, -+ &did_some_progress); ++ page = __alloc_pages_may_oom(gfp_mask, order, alloc_flags == ALLOC_OOM, ++ ac, &did_some_progress); because nobody will use __GFP_NOMEMALLOC | __GFP_NOFAIL. But for memcg charge path, task_will_free_mem(current, false) == true and out_of_memory() will return true, which avoids unnecessary OOM killing. Of course, this patch cannot avoid unnecessary OOM killing if out_of_memory() is called by not yet killed process. But to mitigate it, what can we do other than defer setting MMF_OOM_SKIP using a timeout based mechanism? Making the OOM reaper unconditionally reclaim all memory is not a valid answer.