Received: by 10.192.165.156 with SMTP id m28csp555049imm; Thu, 19 Apr 2018 03:47:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+PFAEZTcBDOL5XZf3dsPqMZOlVGNi1n/tb/VOgXyVBCJjcPPPZhLx+M3fkquC/PwCWyAAV X-Received: by 10.101.75.202 with SMTP id p10mr4780273pgr.339.1524134845977; Thu, 19 Apr 2018 03:47:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524134845; cv=none; d=google.com; s=arc-20160816; b=aHWHlTeetwvr1uLAoXI8PSiXNYkA4pTkt46W2HImcPZBv5E+UIxig/Cl5U32hs4C54 b9+sdu4iS2z3k5PMeyXsOaTyGEW1ghwnTxHriq0F8riY5B+dkB5WMQjHPF8+FR0LXmHp 3ILqp/99VJWv0UGJsPz+Ytk6wfRxoHUrSbpMcp2A/CNDiSmndEl+LXOm2HaYKxNlrvRX vDbftqpuK/Khg82RBhm1gRFYvhrfLZuHgggfubq5490NF9+zmKGCkH5vDi0VxNX4cayq jZG56N2Ty+VO/8cxn38mnVfeDtJHPAkK0qC5BvjKDwdwslZyKzKJ2mNfzKUUoqWu/bi6 BgCg== 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=CFtptiQHO3lh9kAZhO0Y02TUYhTu54Du5kovTKnmBeI=; b=TWTWUrorQ2lwyOyq7EM8zcGZqk7QOMRNkANt/e7LNPIbO2Wvt0vdKSKilXQocS1Hfi UhPv2JzmdVuMZ0qSyZFXAV7qOcYgNmI3TyXVtDm0mincXWlSOsTun+mq3lWRbDj4ivK7 hXM2NaM2QHJwVgi2tA+axAYKJCVQlHWEeB/hniInesQ24MbQMyEYtLNUSxbJ6l9A19go X/fqsXr27peGeJVMT60msR7JQrHjox1IFwU8gc+cJ+3ZCfHWjlY9Xz1QXeMse5Jhwk97 gx4WYN3DQ9WdDg9oWjv2SeG9O+OV+Kv8SzlFOuZ1en1DAsf67HwYR5sROmwH133tXDq/ jq3Q== 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 f3-v6si3269961plf.446.2018.04.19.03.47.12; Thu, 19 Apr 2018 03:47:25 -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 S1752654AbeDSKqF (ORCPT + 99 others); Thu, 19 Apr 2018 06:46:05 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:10339 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751865AbeDSKqD (ORCPT ); Thu, 19 Apr 2018 06:46:03 -0400 Received: from fsav101.sakura.ne.jp (fsav101.sakura.ne.jp [27.133.134.228]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w3JAjkxW091970; Thu, 19 Apr 2018 19:45:46 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav101.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav101.sakura.ne.jp); Thu, 19 Apr 2018 19:45:46 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav101.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 w3JAjk3r091967; Thu, 19 Apr 2018 19:45:46 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) To: mhocko@kernel.org, rientjes@google.com Cc: 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> <20180419063556.GK17484@dhcp22.suse.cz> In-Reply-To: <20180419063556.GK17484@dhcp22.suse.cz> Message-Id: <201804191945.BBF87517.FVMLOQFOHSFJOt@I-love.SAKURA.ne.jp> X-Mailer: Winbiff [Version 2.51 PL2] X-Accept-Language: ja,en,zh Date: Thu, 19 Apr 2018 19:45:46 +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: > > exit_mmap() does not block before set_bit(MMF_OOM_SKIP) once it is > > entered. > > Not true. munlock_vma_pages_all might take page_lock which can have > unpredictable dependences. This is the reason why we are ruling out > mlocked VMAs in the first place when reaping the address space. Wow! Then, > While you are correct, strictly speaking, because unmap_vmas can race > with the oom reaper. With the lock held during the whole operation we > can indeed trigger back off in the oom_repaer. It will keep retrying but > the tear down can take quite some time. This is a fair argument. On the > other hand your lock protocol introduces the MMF_OOM_SKIP problem I've > mentioned above and that really worries me. The primary objective of the > reaper is to guarantee a forward progress without relying on any > externalities. We might kill another OOM victim but that is safer than > lock up. current code has a possibility that the OOM reaper is disturbed by unpredictable dependencies, like I worried that I think that there is a possibility that the OOM reaper tries to reclaim mlocked pages as soon as exit_mmap() cleared VM_LOCKED flag by calling munlock_vma_pages_all(). when current approach was proposed. We currently have the MMF_OOM_SKIP problem. We need to teach the OOM reaper stop reaping as soon as entering exit_mmap(). Maybe let the OOM reaper poll for progress (e.g. none of get_mm_counter(mm, *) decreased for last 1 second) ?