Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2174210imm; Mon, 16 Jul 2018 03:39:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf1+mcvXIoxpJ9H0DmVdZWmQQg5iS+xXnKSYA6c9/QJUdo7GOrTwbvapUjDyqwrEJzJKiac X-Received: by 2002:aa7:8645:: with SMTP id a5-v6mr17268987pfo.247.1531737587920; Mon, 16 Jul 2018 03:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531737587; cv=none; d=google.com; s=arc-20160816; b=0/I6CWzQd7833SxDxSSIvjgmM59bczjnZBEUe5bzjZ5YOybyKzMCQrHzO4K+t/tQSV +pdJrmRdMN4xE+opL3ksl7dvvdVuyl/lCp4w+N3/YTzDrvRlDecqNQvVDJRSSV3mxhq/ 9QFZ3AEOlfPGXZ54QzUuV9F0zxUWZBEKOZZJGY9ma3LAVxSIDuRe+y0gPaCL9aO2T720 V0t8j617ChstLJgY7OohKLw4aSX5DU4titIZ/xZQq1KT9hYnUxVzYWACwk8IP4O2/ryC zXjRCTwzRc+MLtV/oLVBvOgAxdjR40xUggNogg1owVAEd0aDvBKMtV7FZtmbj0Z0PhfB mElg== 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=oCPS+i3nMBukyGSYCatOjnRxvLi1UsM1qHYYkMpcT+E=; b=HCUGTHtppjuSnDJUSgRYY4zWtB0H+yGfOPh7CotLSkHzdeclKhtBEXzfrtzeERzBLq xzY6dyh5/URpqgefqw+zN5+ebaGxhdbT4CO2K4rwrnBSArmU9YpZfpEVbY7IoSZ6aF4O Sr1WHc7D4pDERSbAxz/6G+OfFFLYPtA32IcngyDckZTvWeVMSA7zbKFjvs7UPoN4m+Zk +2DyIjJmL/erZs/jBHIge8NmFvzx2bFsSk8ZHZQKXW2XP1nixKZdy5T0qCz3p5VyVqaL eMAg/Nw10XE6d2weSW4wzED1fOIh9ELo/u8Jw7wZnpBeYP9RJrRMVWtvTuFNpTFwVMkH e6ig== 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 z18-v6si32052069pfl.209.2018.07.16.03.39.31; Mon, 16 Jul 2018 03:39:47 -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 S1728742AbeGPLFY (ORCPT + 99 others); Mon, 16 Jul 2018 07:05:24 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:23958 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727163AbeGPLFX (ORCPT ); Mon, 16 Jul 2018 07:05:23 -0400 Received: from fsav301.sakura.ne.jp (fsav301.sakura.ne.jp [153.120.85.132]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w6GAcPbR005887; Mon, 16 Jul 2018 19:38:25 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav301.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav301.sakura.ne.jp); Mon, 16 Jul 2018 19:38:25 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav301.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 w6GAcLIZ005857 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 Jul 2018 19:38:25 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [patch -mm] mm, oom: remove oom_lock from exit_mmap To: Michal Hocko Cc: David Rientjes , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20180713142612.GD19960@dhcp22.suse.cz> <44d26c25-6e09-49de-5e90-3c16115eb337@i-love.sakura.ne.jp> <20180716061317.GA17280@dhcp22.suse.cz> <916d7e1d-66ea-00d9-c943-ef3d2e082584@i-love.sakura.ne.jp> <20180716074410.GB17280@dhcp22.suse.cz> From: Tetsuo Handa Message-ID: Date: Mon, 16 Jul 2018 19:38:21 +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: <20180716074410.GB17280@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/07/16 16:44, Michal Hocko wrote: >> If setting MMF_OOM_SKIP is guarded by oom_lock, we can enforce >> last second allocation attempt like below. >> >> CPU 0 CPU 1 >> >> mutex_trylock(&oom_lock) in __alloc_pages_may_oom() succeeds. >> get_page_from_freelist() fails. >> Enters out_of_memory(). >> >> __oom_reap_task_mm() reclaims some memory. >> mutex_lock(&oom_lock); >> >> select_bad_process() does not select new victim because MMF_OOM_SKIP is not yet set. >> Leaves out_of_memory(). >> mutex_unlock(&oom_lock) in __alloc_pages_may_oom() is called. >> >> Sets MMF_OOM_SKIP. >> mutex_unlock(&oom_lock); >> >> get_page_from_freelist() likely succeeds before reaching __alloc_pages_may_oom() again. >> Saved one OOM victim from being needlessly killed. >> >> That is, guarding setting MMF_OOM_SKIP works as if synchronize_rcu(); it waits for anybody >> who already acquired (or started waiting for) oom_lock to release oom_lock, in order to >> prevent select_bad_process() from needlessly selecting new OOM victim. > > Hmm, is this a practical problem though? Do we really need to have a > broader locking context just to defeat this race? Yes, for you think that select_bad_process() might take long time. It is possible that MMF_OOM_SKIP is set while the owner of oom_lock is preempted. It is not such a small window that select_bad_process() finds an mm which got MMF_OOM_SKIP immediately before examining that mm. > How about this goes > into a separate patch with some data justifying it? > No. We won't be able to get data until we let people test using released kernels. I don't like again getting reports like http://lkml.kernel.org/r/1495034780-9520-1-git-send-email-guro@fb.com by not guarding MMF_OOM_SKIP.