Received: by 10.192.165.156 with SMTP id m28csp798641imm; Tue, 17 Apr 2018 21:13:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+1mSa7brJFuNrZ2T4ycndY5f3IQDjafrldAZ/LZ+IyAg4ZYiIg9o6AY4PEK5xVB/WtZdiI X-Received: by 10.99.7.86 with SMTP id 83mr464120pgh.211.1524024832430; Tue, 17 Apr 2018 21:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524024832; cv=none; d=google.com; s=arc-20160816; b=LF+oOZ2290Vn/g4MJpIeY/JuFs0JPC2X1Jd06yv3LhYLqf3uHgNETjkKg7AazZgnqI lhHH9bGansYZo+fHX4aIbVhi2tQLBJvWIkwSyk+Q9nwPX8/FUvRVKplslMuwrK38h0Dn Fnq5tsU4W95NoD9HEuRQM8mDl/cpSh1IE6qWoj+IXu8iyIuBj919lr3pisTeR+ME9GVV F/g+8Gv3mxtfOBJqaaf9afhfz/7smaaesoxtwWNkYDM/nHVMZ4tvMY2M40O5RWeX9QjD CKxjWVOHW82NH5tJRsaYczB/feCDAtLwmo+liHS07jaYcAO8lb3ca5rrvW1Jmhlw51z2 5TYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=+FQulpm9z12d9B3TDhF7+iN1iMkYRrkd3NnneNZ/zk0=; b=PRyQSdFJBuSqFmZswLdzuiojOLLgsIQ3eEr+0DT1j9lpZQHMBFceXfU6DrECps2RXG ylEvMXCLj+vp9CuAHUCR2sUQ9djSTzSduoShr6OTaS6AwT6hqLX8r3rpK7RFRdMZ9gMu DLSbscqTNXrXb2W9lPx7483tiXqY1hh71MyhFN/MIzL+pdvat+mVs7XlbwgpODn2a4JA VtAMjTWvKJvG6mtRJ0B1XgGyzwdpdBX5iAMx++WnBb/NabyVzrjx7wGNXBR2dpmSCcDh jpwG2dElLHTqGSNOOELBYUDtcVUdpubDcBtBx7HjbUbuQsBA/25n3zqEKuXmJqdftbrF wTMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Hm5fX91A; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si353663pgp.168.2018.04.17.21.13.28; Tue, 17 Apr 2018 21:13:52 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=Hm5fX91A; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752983AbeDRELj (ORCPT + 99 others); Wed, 18 Apr 2018 00:11:39 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:36508 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407AbeDRELi (ORCPT ); Wed, 18 Apr 2018 00:11:38 -0400 Received: by mail-pl0-f66.google.com with SMTP id m7-v6so310701plt.3 for ; Tue, 17 Apr 2018 21:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=+FQulpm9z12d9B3TDhF7+iN1iMkYRrkd3NnneNZ/zk0=; b=Hm5fX91AJ7HIDBFbiz6Not8mqF2oLXKHu67gve018iq0yyvpsrMfLk7OlULcgLQXic l2zJKqSJffxdiGne6GpTYrtbytKGStJwrAOsZMB9YdHT5vAo+Tu3wqBsGnR92RxVm9NB ms8hkd8HRBiVxPBnzD1xngbWU7O1Pb8m8i2JS4fSzgjBZ4ZZVhs7c/iKsT+sGgLrfRH6 s0G4IYiosdRbp3wqxINaNKzGx4tqW/8baI/nZe+AOKCI0qv2O62wY0iDpbrXCmTZHQ61 pO+zNclmMPHWO8krPpxGcrJ5VLDGJCgHw5YkWTsaJmTCCQtwLcB0dxYuKiqu1i7JpTOX 5qEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=+FQulpm9z12d9B3TDhF7+iN1iMkYRrkd3NnneNZ/zk0=; b=nTYl/e+EfW/gZ67oulOusG7CkARqLlXKcJnXxz6tNtqyATgZ9j3dYQQTBZJZmvcxVu owGXrHIgcX3Xo8Rl9foIlvRGvcRfObr1ZtCNxo49oeBasGVh33OOFqy1eqXHDj6vBc0G 6hObsUNu9Zf3zXkXbY5jLpXLqM97xLQNIIEhcLwgMCh5+MGD7z4vQQCc7bI6sYfcoM/s 61XsuRTJRmvm0iy2eFUz+hYkRLOtAKn/YeyOWRcic9Ritkkqd9XedLftgVcdeZeaYS0I PRvKXmf4y5AbuSjyB/2Wf+nKQgpgw8oxKoGaKT1Btru7M/oU4VzU945yEu5CRSF0K+gc ESQQ== X-Gm-Message-State: ALQs6tBzVcU6ZeeEhcUenam1j49OVwT8uUc1z3n0lUGfQM5imJrp8g8O P0CZv9iZI9j5xZSCFkS3EU2VZQ== X-Received: by 2002:a17:902:3084:: with SMTP id v4-v6mr558050plb.262.1524024697369; Tue, 17 Apr 2018 21:11:37 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id s5sm506770pgv.8.2018.04.17.21.11.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Apr 2018 21:11:36 -0700 (PDT) Date: Tue, 17 Apr 2018 21:11:36 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Tetsuo Handa cc: Andrew Morton , Michal Hocko , Andrea Arcangeli , Roman Gushchin , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch v2] mm, oom: fix concurrent munlock and oom reaper unmap In-Reply-To: <201804180355.w3I3tM6T001187@www262.sakura.ne.jp> Message-ID: References: <201804180355.w3I3tM6T001187@www262.sakura.ne.jp> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) 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 On Wed, 18 Apr 2018, Tetsuo Handa wrote: > > Fix this by reusing MMF_UNSTABLE to specify that an mm should not be > > reaped. This prevents the concurrent munlock_vma_pages_range() and > > unmap_page_range(). The oom reaper will simply not operate on an mm that > > has the bit set and leave the unmapping to exit_mmap(). > > This change assumes that munlock_vma_pages_all()/unmap_vmas()/free_pgtables() > are never blocked for memory allocation. Is that guaranteed? For example, > i_mmap_lock_write() from unmap_single_vma() from unmap_vmas() is never blocked > for memory allocation? Commit 97b1255cb27c551d ("mm,oom_reaper: check for > MMF_OOM_SKIP before complaining") was waiting for i_mmap_lock_write() from > unlink_file_vma() from free_pgtables(). Is it really guaranteed that somebody > else who is holding that lock is never waiting for memory allocation? > Commit 97b1255cb27c is referencing MMF_OOM_SKIP already being set by exit_mmap(). The only thing this patch changes is where that is done: before or after free_pgtables(). We can certainly move it to before free_pgtables() at the risk of subsequent (and eventually unnecessary) oom kills. It's not exactly the point of this patch. I have thousands of real-world examples where additional processes were oom killed while the original victim was in free_pgtables(). That's why we've moved the MMF_OOM_SKIP to after free_pgtables(). I'm not sure how likely your scenario is in the real world, but if it poses a problem then I believe it should be fixed by eventually deferring previous victims as a change to oom_evaluate_task(), not exit_mmap(). If you'd like me to fix that, please send along your test case that triggers it and I will send a patch.