Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp80109imm; Thu, 12 Jul 2018 14:34:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe9rToy0ebNkOb6ZuPx/HIrAn3/U4+a5r1KKi3ibrG3y1JgO5Whk+vUcPIaf3fTDr5im9M1 X-Received: by 2002:a17:902:42c3:: with SMTP id h61-v6mr3673281pld.319.1531431294604; Thu, 12 Jul 2018 14:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531431294; cv=none; d=google.com; s=arc-20160816; b=KIDwwM1j5+ZUcrlizw5OePZSMhVETCkklZKMYDAvaUZkVABP0APd2u4XNMLpDTxWHK ASXy0LAbyioBjZ+Ik+3svF4LUNzhXlsx3eRBOBSJ0G9mfjEmKOMXygmWqKF1M9R7Lor3 x6ddHYs7srzteORrCOsX9XdFqTFIe3rTZp0vVk21PGF2xp1qx9KfdNswK3ZqmuZ0fnmv dD+KnCVB+L9iSq5Ar3wFwCOg4KDPRPjLZcmQCTI0ZdgzMZh1jGngCxLW2EAidv47GYQH j8sBZ9fy5+AXV5f0cEVOie9ErUSP+YlLwS3HDK/xVXDKO5DXQvhr0dzZNb36Y3xr2c+D KWXQ== 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:message-id :subject:cc:to:from:date:dkim-signature:arc-authentication-results; bh=INRYbdV7gCxAVtNjXKkl9vilZaEVf/iEphy06sCThzU=; b=rPLwKzuQ7YJAZhOLJfLZ/TeA5KD8wBcLmhnUKMGmQana+SVkFv/9H/mAwxxRVvJgZP JzQd1rcxmqA95vM280EtjqqmIuqHReCZfwtD6GL2dg62TIhF0atutikk1q02wLGi1+0n tBbntHghkUb7LVtjWiu1deYqsSi10Mes87pkiC4RckAWmw3YnsLMvdvooZyVJHaz6UI0 kIVStSCbW/RvXkRwhewsb9PAbydhzOzdGudWdwBGdSryXKcWYQeuuVWg59b43l0iM8jg 0lKcDEtThEmkuwYbCImQaoH7Zx+u7AEaZ3eQclnq/TG4QrqUm6n6UoQ61JomwWec7Bw0 vd/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=B6fRnf9c; 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 h66-v6si24778604pfa.238.2018.07.12.14.34.36; Thu, 12 Jul 2018 14:34:54 -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=B6fRnf9c; 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 S1733004AbeGLVp1 (ORCPT + 99 others); Thu, 12 Jul 2018 17:45:27 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44005 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732202AbeGLVp1 (ORCPT ); Thu, 12 Jul 2018 17:45:27 -0400 Received: by mail-pg1-f193.google.com with SMTP id v13-v6so4281899pgr.10 for ; Thu, 12 Jul 2018 14:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=INRYbdV7gCxAVtNjXKkl9vilZaEVf/iEphy06sCThzU=; b=B6fRnf9cfmX2V8cxVFsDwEs1eTI7sguuFEY6XODA2kgea3B2kihd1VkDgrUgxKVp2O prFX/gbIow9jYXqHiKkA3MoFzc4gqCcYKr5M+xp96Qz9nVHJAVEV7y49CJ6KOZaI1taa dtuqWgeUjVVPLt8eoFeflsmZEhYN1dtkgy/6YKc+Qc5RjtJ5Mgkc02jQBX1GADPze1vo tuZ9JsHBldkQ2ol9jJqiJu8WyIjAkiR7RQZmHjUAuyNMBOqiZSp/D/yIuU7KGoDPIxXe cEA+g4Vthk1fh/y0u8L/wUrpHu4wYarJA8LuXKnao98y5m+M8QoXvG1tXbYyyUH0rGfe 1vFw== 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:message-id:user-agent :mime-version; bh=INRYbdV7gCxAVtNjXKkl9vilZaEVf/iEphy06sCThzU=; b=DLe/LTAGD9UkVodWZIvlHDNMdef30MVNPNbE46u/hyTZt7F4H908Rw48f8NUSuqr7Z qGpOkORlzGrderOdvbI78r3iiVmpYL3jdGf10sIBpvSIpIKtQxjEkQT6INsOTojaGDRP PrOi9dCqgxtqp75cgyEluCO2qdZGca89asHg/a+jnoC4y5LEbRZ0R1ESlNdErY0aQ3dT /HdP/UfMCDkRFud3nywR5FRshxPst61ijMCbA/Sb2LgiY2UPb15ujpi3Okf00kC1tJzP Vq6gN6lCkAJXCM8Aa7p1kHctufdEx6t3mMmMrPrbRjvri7hZqp2P4MUm1Ww//1ZOeYp/ 9eSA== X-Gm-Message-State: AOUpUlG0QFFEF9YtWPZO39HtveT7tx7DxRO+tT48ylFnhZfgJJbUcifp eok7AQf8Jr36nl8mrPSfnrygXw== X-Received: by 2002:a62:5582:: with SMTP id j124-v6mr4141698pfb.20.1531431241295; Thu, 12 Jul 2018 14:34:01 -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 1-v6sm43159007pfm.145.2018.07.12.14.34.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 14:34:00 -0700 (PDT) Date: Thu, 12 Jul 2018 14:34:00 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Andrew Morton cc: Michal Hocko , Tetsuo Handa , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [patch -mm] mm, oom: remove oom_lock from exit_mmap Message-ID: 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 oom_lock isn't needed for __oom_reap_task_mm(). If MMF_UNSTABLE is already set for the mm, we can simply back out immediately since oom reaping is already in progress (or done). Signed-off-by: David Rientjes --- mm/mmap.c | 2 -- mm/oom_kill.c | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index cd2431f46188..7f918eb725f6 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3072,9 +3072,7 @@ void exit_mmap(struct mm_struct *mm) * to mmu_notifier_release(mm) ensures mmu notifier callbacks in * __oom_reap_task_mm() will not block. */ - mutex_lock(&oom_lock); __oom_reap_task_mm(mm); - mutex_unlock(&oom_lock); /* * Now, set MMF_UNSTABLE to avoid racing with the oom reaper. diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 0fe4087d5151..e6328cef090f 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -488,9 +488,11 @@ void __oom_reap_task_mm(struct mm_struct *mm) * Tell all users of get_user/copy_from_user etc... that the content * is no longer stable. No barriers really needed because unmapping * should imply barriers already and the reader would hit a page fault - * if it stumbled over a reaped memory. + * if it stumbled over a reaped memory. If MMF_UNSTABLE is already set, + * reaping as already occurred so nothing left to do. */ - set_bit(MMF_UNSTABLE, &mm->flags); + if (test_and_set_bit(MMF_UNSTABLE, &mm->flags)) + return; for (vma = mm->mmap ; vma; vma = vma->vm_next) { if (!can_madv_dontneed_vma(vma))