From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76E24C433E6 for ; Tue, 14 Jul 2020 04:07:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 433D721883 for ; Tue, 14 Jul 2020 04:07:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 433D721883 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=i-love.sakura.ne.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B4D938D0003; Tue, 14 Jul 2020 00:07:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AFE3A8D0001; Tue, 14 Jul 2020 00:07:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A13F28D0003; Tue, 14 Jul 2020 00:07:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id 8B39F8D0001 for ; Tue, 14 Jul 2020 00:07:00 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EBA3C181AC9C6 for ; Tue, 14 Jul 2020 04:06:59 +0000 (UTC) X-FDA: 77035345758.28.earth74_080b59f26eed Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id C5D066C33 for ; Tue, 14 Jul 2020 04:06:59 +0000 (UTC) X-HE-Tag: earth74_080b59f26eed X-Filterd-Recvd-Size: 3500 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Jul 2020 04:06:58 +0000 (UTC) Received: from fsav109.sakura.ne.jp (fsav109.sakura.ne.jp [27.133.134.236]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 06E46mt0095098; Tue, 14 Jul 2020 13:06:48 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav109.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav109.sakura.ne.jp); Tue, 14 Jul 2020 13:06:48 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav109.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 06E46msG095095 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 14 Jul 2020 13:06:48 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [PATCH] mm, oom: don't invoke oom killer if current has been reapered To: Yafang Shao Cc: Michal Hocko , David Rientjes , Andrew Morton , Linux MM References: <1594437481-11144-1-git-send-email-laoar.shao@gmail.com> <06806cf0-a122-e002-191f-348298358882@i-love.sakura.ne.jp> <61feb0d9-d443-c9b8-7058-e9597af405c5@i-love.sakura.ne.jp> From: Tetsuo Handa Message-ID: <9b9c8510-1a1d-86b0-59ce-29992a53d52c@i-love.sakura.ne.jp> Date: Tue, 14 Jul 2020 13:06:48 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: C5D066C33 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2020/07/14 11:58, Yafang Shao wrote: > On Tue, Jul 14, 2020 at 10:42 AM Tetsuo Handa > wrote: >> >> On 2020/07/14 11:13, Yafang Shao wrote: >>> But it seems the proposal that using trylock in >>> mem_cgroup_out_of_memory() should be better? >>> The trylock could also solve the problem that different processes are >>> doing oom at the same time. >> >> I think trylock is worse. The trylock needlessly wastes CPU time which could >> have been utilized by the OOM killer/reaper for reclaiming memory. > > If it may wastes the CPU time, we can shed it out for 1 second like > what it does in __alloc_pages_may_oom(): > > __alloc_pages_may_oom > if (!mutex_trylock(&oom_lock)) { > schedule_timeout_uninterruptible(1); // to avoid wasting CPU time 1 second is HZ. 1 means 1 millisecond if CONFIG_HZ=1000. :-) > return; > } > > But I find that we doesn't sched it out in pagefault path, > > pagefault_out_of_memory > if (!mutex_trylock(&oom_lock)) > return; > > I haven't thought deeply what the difference is ... David Rientjes is proposing it for avoiding soft lockup, and Michal Hocko is refusing it. How to give the OOM killer/reaper enough CPU time for reclaiming memory is a dogfight. :-( https://lkml.kernel.org/r/alpine.DEB.2.21.2003181458100.70237@chino.kir.corp.google.com