From patchwork Tue Nov 20 13:43:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10690405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC7341709 for ; Tue, 20 Nov 2018 13:43:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD0E121C9A for ; Tue, 20 Nov 2018 13:43:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1707277D9; Tue, 20 Nov 2018 13:43:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CA2721C9A for ; Tue, 20 Nov 2018 13:43:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D30636B203F; Tue, 20 Nov 2018 08:43:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C1DF26B2040; Tue, 20 Nov 2018 08:43:40 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A496D6B2041; Tue, 20 Nov 2018 08:43:40 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 303116B203F for ; Tue, 20 Nov 2018 08:43:40 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id t2so1272280edb.22 for ; Tue, 20 Nov 2018 05:43:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/sEYolIbYeBRlPTEJk3IyaZRfhMjojYPi0YASgHfRGI=; b=MfPVpRZiFcBQxgbak5Inpev/ytvdNmjQEhzaA4o+LAwxu3omoW/tnc7wHhqXnR7Wgi hrkhZTwBYrjTQJaic7BNBUe3dx+5b0K05yu2qXVs2WI1sGRQJOIgKt8QN8H9/uHbnYL5 25C9MexglfxB+kcfO+6qTJNi66T257ifhp0AN45v7dxsi0IBXigdHoYtW1XbnHGCLWNH KjEse0lxeZcElGVRR/b5d7cHL6QfUpWq+RzEpLvzc6dVgTN0PmmHZgvvCNbO0yA4JYHL qyOpJ26+6WY7FQjVwjJUV7nEbYkUaB9X1G3VPzV6psGIUzqV+nQc2WWYPaeWHtEKfhnt NWkA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: AGRZ1gLScqBl4t7tHAbf1dZZHsjwUELNzUW2gN/dWh0s33/8X61EjLe9 R2soEM2fE7OZBEAVCcph1I+6S5LbJym72ERGGoCsrYH/5GWL/z/cXLtZgt3XBwr55zBe7yEGula tXT0UbH3BdZrhu7nTAQi0k5pHzAURyodJ4YLuMWCCPsHFgqqA/3ej2Od3EKBmoUvfK5FNMAH1b3 yLBPIFGe7iupMA9s7yCE7jNFOsoIP1cYjnfZFAsaM5rr9cNGSR+/Ku7PlJvNxkwXNxG6ehrKxs/ h7jgtxQE/S7+rMosdOQ8oSi62s8TSHADwBLzpSt+pUZ7zygZ0e0l2tpfeglo1Vb3Qn72z33EeE0 IWFEUB06Vhyg6Vnn/XfiHSbcx29vcd5VPjThYiOnJTjK1T1cCL27C0OEZWyp3RdfWurS8qDl3Q= = X-Received: by 2002:a17:906:858c:: with SMTP id v12-v6mr2028704ejx.172.1542721419688; Tue, 20 Nov 2018 05:43:39 -0800 (PST) X-Received: by 2002:a17:906:858c:: with SMTP id v12-v6mr2028673ejx.172.1542721418750; Tue, 20 Nov 2018 05:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542721418; cv=none; d=google.com; s=arc-20160816; b=JRfZO2o+oUGSUPu6l1sjQW8l7ngVQlLswuC5QGrupCq1nFw5cMK2y7Wv79VC6zVrL9 SVvjWmPUMO/m3CXyK+0XPztewpFEiKoU/QCEck0IATW5JjtQag/1ke5eqt1VfjOL1C/z k1KNHReFSkhrSxjtI5O+FQbwQufi2JIGHirvh5AykWq6CwxTi4s1rnsQ74DzUyZ3FUQ+ 7lB6+HAI40T+MzlgkFxDI6GyACaLiGABqsuJDOnUDFtUm5TuxmJ28GJdyPHeyNVTdAWJ 4av6NBpFss/fOvoaX3Uw57RdbLSKRmK4ltflpITn4F4JWGIx83TKakgSTxQ0cHnEDzw4 dzpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=/sEYolIbYeBRlPTEJk3IyaZRfhMjojYPi0YASgHfRGI=; b=OzEmUVnw3yAi1wKXjkknu/z4Y0ObbVJqwHi+YmlGO+sLO8cgvZp4/cVCtynpTil0bV IXXqfyXObPBoxCvYM/Phjfao/DmRpzsGkEKSNt6L57m8oyUcUP23i+O1BupwzaaU25tN EASkZH6CHIyhmJITFhajiv8ujbv1rxjcbseeWcADuM6wzjI84yxIsQyHxdBBfRYgIlUi qZ6wrIYBrYSqREvzSnqy1aZw1aGpoGHsD3+W2+KdafCd9dN8jnpXDyPEvKJhZRk1D5F1 /RsjcbP0mCCRbXOdBRnTls0cGEQjCes66aF2SIPo36xj/TeGegFtYhrp9Yd0Z45GKMir GhNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s4sor6858427edx.12.2018.11.20.05.43.38 for (Google Transport Security); Tue, 20 Nov 2018 05:43:38 -0800 (PST) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: AFSGD/Xq+FylGFMKZlo0fPRxIfOZYXl+3i3vcWbXu5KuTcyyuMAc1+bVUL4AAeeLNkbOPYEcxvkmwQ== X-Received: by 2002:a50:a6cf:: with SMTP id f15mr2266604edc.97.1542721418061; Tue, 20 Nov 2018 05:43:38 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id 49sm8428786edz.59.2018.11.20.05.43.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 05:43:37 -0800 (PST) From: Michal Hocko To: Cc: Andrew Morton , Oscar Salvador , Pavel Tatashin , David Hildenbrand , LKML , Michal Hocko , "Kirill A. Shutemov" Subject: [RFC PATCH 3/3] mm, fault_around: do not take a reference to a locked page Date: Tue, 20 Nov 2018 14:43:23 +0100 Message-Id: <20181120134323.13007-4-mhocko@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120134323.13007-1-mhocko@kernel.org> References: <20181120134323.13007-1-mhocko@kernel.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Michal Hocko filemap_map_pages takes a speculative reference to each page in the range before it tries to lock that page. While this is correct it also can influence page migration which will bail out when seeing an elevated reference count. The faultaround code would bail on seeing a locked page so we can pro-actively check the PageLocked bit before page_cache_get_speculative and prevent from pointless reference count churn. Cc: "Kirill A. Shutemov" Suggested-by: Jan Kara Signed-off-by: Michal Hocko Acked-by: Kirill A. Shutemov Reviewed-by: David Hildenbrand Acked-by: Hugh Dickins Reviewed-by: William Kucharski --- mm/filemap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 81adec8ee02c..c76d6a251770 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2553,6 +2553,9 @@ void filemap_map_pages(struct vm_fault *vmf, goto next; head = compound_head(page); + + if (PageLocked(head)) + goto next; if (!page_cache_get_speculative(head)) goto next;