Received: by 10.192.165.156 with SMTP id m28csp1232367imm; Wed, 18 Apr 2018 06:28:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx48VV6aJRd6V34oqaND3nf+vmFQEN8aYwZN/K736MZVmR5mG+PVbg+aPC0HqGi5kgtNGgzpb X-Received: by 10.99.109.132 with SMTP id i126mr1769363pgc.414.1524058086498; Wed, 18 Apr 2018 06:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524058086; cv=none; d=google.com; s=arc-20160816; b=DtSFvGuB4FoN766AyYhwb9hF98fJoj59wVAJNx79iBEDUDjsXxFTwrmZPWJwIv0TXx J68Idgs/tJnJF08/ciM1n2GL2WISdJWExSDtR4NWWMay236WW+chX9uL01OxGL4EJhUR 53qqauUS+ULT8JKyBlQ4FGE66TssO7ly6wH4sD0TlUfhfhyVxOe6q9SrOydL2iNxqpWg c1ff5QxyzEJbWptgmUavGRTF8y86S51K8KmtaDTchRBYs4hM6hnmraBmpcyxJjb5nl8H vyzBfOK3yj52m2BeGY6C81S91vyu0LYt5DQb4ZJ6GZSIpJSidRrfcYtUNDAwLp2rLeXs wW4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:date:message-id:in-reply-to :references:from:subject:cc:to:arc-authentication-results; bh=QyDEsh5UioUi+Fxk63wc/AkBvmQIalNVqCCVvcYeDo0=; b=n4SWhc2WiMJjZ2M4H5/uvpSsadEMwSzS/iHir0SdqXtjEXER/uP7SuQYmPYBqZdLgD Rrj39Ystz52M6w2F0rUyKUyL/wq+Oo4ZodJX0ZzZDhzNq0JqJS07cTNwFXPwxvq8/H25 tfC9mkyYhZyVMpgDqR9A/5eh1xFTG40S8N1perpXH242KGUWI4GN68JJHUiy4Qyx1LVu 2OAo5QNGG8alYNniCtQU8+zI1zrPSGki2AalP0NHd4N/anax2bwWUnWPWqn7iTj2v0tO QF93ijXy1hOhyUBzDdOAktAantQD9YKgvdz+OIu1ubG1yiB1RQEdhVOo2j/iet5cPY+P Rlqw== 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 b1-v6si1241492pld.227.2018.04.18.06.27.52; Wed, 18 Apr 2018 06:28:06 -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 S1754014AbeDRN0M (ORCPT + 99 others); Wed, 18 Apr 2018 09:26:12 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:20987 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753170AbeDRN0L (ORCPT ); Wed, 18 Apr 2018 09:26:11 -0400 Received: from fsav403.sakura.ne.jp (fsav403.sakura.ne.jp [133.242.250.102]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w3IDPtv4006030; Wed, 18 Apr 2018 22:25:55 +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); Wed, 18 Apr 2018 22:25:55 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav403.sakura.ne.jp) Received: from AQUA (softbank126099184120.bbtec.net [126.99.184.120]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w3IDPtGJ006027; Wed, 18 Apr 2018 22:25:55 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) To: mhocko@kernel.org Cc: rientjes@google.com, akpm@linux-foundation.org, aarcange@redhat.com, guro@fb.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch v2] mm, oom: fix concurrent munlock and oom reaper unmap From: Tetsuo Handa References: <20180418075051.GO17484@dhcp22.suse.cz> <201804182049.EDJ21857.OHJOMOLFQVFFtS@I-love.SAKURA.ne.jp> <20180418115830.GA17484@dhcp22.suse.cz> In-Reply-To: <20180418115830.GA17484@dhcp22.suse.cz> Message-Id: <201804182225.EII57887.OLMHOFVtQSFJOF@I-love.SAKURA.ne.jp> X-Mailer: Winbiff [Version 2.51 PL2] X-Accept-Language: ja,en,zh Date: Wed, 18 Apr 2018 22:25:54 +0900 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michal Hocko wrote: > > > Can we try a simpler way and get back to what I was suggesting before > > > [1] and simply not play tricks with > > > down_write(&mm->mmap_sem); > > > up_write(&mm->mmap_sem); > > > > > > and use the write lock in exit_mmap for oom_victims? > > > > You mean something like this? > > or simply hold the write lock until we unmap and free page tables. That increases possibility of __oom_reap_task_mm() giving up reclaim and setting MMF_OOM_SKIP when exit_mmap() is making forward progress, doesn't it? I think that it is better that __oom_reap_task_mm() does not give up when exit_mmap() can make progress. In that aspect, the section protected by mmap_sem held for write should be as short as possible. > It would make the locking rules much more straightforward. > What you are proposing is more focused on this particular fix and it > would work as well but the subtle locking would still stay in place. Yes, this change is focused on -stable patch. > I am not sure we want the trickiness. I don't like the trickiness too. I think we can even consider direct OOM reaping suggested at https://patchwork.kernel.org/patch/10095661/ . > > > Then, I'm tempted to call __oom_reap_task_mm() before holding mmap_sem for write. > > It would be OK to call __oom_reap_task_mm() at the beginning of __mmput()... > > I am not sure I understand. To reduce possibility of __oom_reap_task_mm() giving up reclaim and setting MMF_OOM_SKIP.