From patchwork Tue Dec 11 14:27:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10723899 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 1AD5914E2 for ; Tue, 11 Dec 2018 14:28:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B7E428587 for ; Tue, 11 Dec 2018 14:28:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F39562883D; Tue, 11 Dec 2018 14:28:02 +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 8E11E28587 for ; Tue, 11 Dec 2018 14:28:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B923A8E0092; Tue, 11 Dec 2018 09:27:54 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B19838E004D; Tue, 11 Dec 2018 09:27:54 -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 A0A688E0092; Tue, 11 Dec 2018 09:27:54 -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 442FB8E004D for ; Tue, 11 Dec 2018 09:27:54 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id e29so7120426ede.19 for ; Tue, 11 Dec 2018 06:27:54 -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=Iw/C/mJloVWnnEeI9hr/rFUfYtnu/dchJcsf1iUtKds=; b=U8wYOdbtK50VmjIiIUS2Nljkyp26DeYrSdrFS9M7mOB3gXa6IF0X763VcGiBX9TXlg ewOMYcv6rTHjqGL7wAZ4qpjLaRxQwZksg06GYoyCT3YZ2B/VSi1teXb5pSkkQzlvng1n OB9kBq1B4oqZchs5aoRGmMvKdpJRvYQ7QXpGz2iCchMvUz22lW15Sq6XjUSKwgHr5xNZ oJCXodxpPhIHF/LxUYNizAfMOTBPEhAX4VQqYi5imvEzOymX0Nw+2PFml4ILiJwIoAjB 5Uh7nMcOkK2DzahsqGFvOiBb7dl4F+xwxRsXwLYIohi+spF4QzJ40oOKE3A2nedtUH8W aeaw== 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: AA+aEWYDWhlTh5gcF80YT1ClD2tHz5aUrVNk34m6LLC7TantQnMhnOTa fPUq8dRL98mWcKyt6z2eYLmQ/Xp4U45AA6pJlr8mQ2Y9gO9ACk0WgqSOxL2tYJSohNCH1FsMt8O tkjsGpGYcrr4UnyjPj8+7zaKUoDzRBvs7jPUMN0U9wO/NCN2mh1UMxHAIayY67163cTmV9i03S5 K/FlIElbgjveZgWB1WDEu4Y7hrQhOOc8bqlmTZrwUMysBxcWiRoHUPBo+1r8psd7f4KjqR2FBfv eG6kl0TKsGUMfnlEVpZCbI4Hb3qWTmyy7RXBWug5ba5nkEKZ/vy84oodtbQiMxofy9LMv1PtbOF N5gyJRrDjHHAUGaRBePfGhxO5Ho3C93hih2ZBZhjn/TkneiXglI7T2OalhwoUB6IsEqCJ5lArg= = X-Received: by 2002:a17:906:753:: with SMTP id z19-v6mr12681096ejb.175.1544538473787; Tue, 11 Dec 2018 06:27:53 -0800 (PST) X-Received: by 2002:a17:906:753:: with SMTP id z19-v6mr12681052ejb.175.1544538472928; Tue, 11 Dec 2018 06:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544538472; cv=none; d=google.com; s=arc-20160816; b=c7ELiuNh/PiWSWdsndXYRaSCWoj0dHCNSga/pjOr7jUu9wn93szhAo5jSzaJ28FMZb 85jQbSCAsmfXMz+rY6KbSqLWCYpbiE3q+mkwj7kZ3aqaK7HxT5vQDdufxzzqvhWdiMXj kBRgwYJZ4gwBHAhciBgSVmYH6dPQFsM6cNFR+3VdNIUPZJbYDvCTtGx+D3fsJsKxamzv 0Ha2haRFoqZgNjKzb5gpxNE/LDOn257Yb/HOGfd/+tw8QqG9mf6YEOc1g7bwNEOOmFb3 esK7UOF1favTI1m+pLbkz9RhiJXRCQlEX+1mHa8hNMr3rRaH0mN38HLf3/l9a5hbCqGQ QqPQ== 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=Iw/C/mJloVWnnEeI9hr/rFUfYtnu/dchJcsf1iUtKds=; b=jULepHh3R5XYTfMqdsFFknHR+6fC0wtukJiIzPbmSbwZ9E9pIMAyb+Du0ZM3nCB25G NW2Nqwp/f7aPLFRdGvN9oDSZf9yJmtdROjebZgjbiHDgcPpaEF0ZP6+1azXCZh1DudMc XAP77wj8Ev6tihOsxbdYSs6wu1ghjFXRjb+IVll1EocspkbcKh6k5BENAn3WTis8CBP5 bv/Vj8emLQIPULEYx8ymhXCZUSV73pBE8uyTsez9iHrFGtHQCdPfBu5gfUajx2vRoPgw DhSBSjb/r2dvWTjaAY8GUavNtQaFabaCK3ll+uHNOG58gz+UVfiZcoIVXfVRoGYxkPWl 708Q== 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 ge18-v6sor4064756ejb.16.2018.12.11.06.27.52 for (Google Transport Security); Tue, 11 Dec 2018 06:27:52 -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/XXN9QZ5mxhdmzoODH6Q4JaQhc6thIwufE8ejAEFt0+2ubdCDlKdqiYc8LyAOjtVAPtFl91Kg== X-Received: by 2002:a17:906:22ca:: with SMTP id q10-v6mr12699179eja.66.1544538472657; Tue, 11 Dec 2018 06:27:52 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id g31sm4073975eda.96.2018.12.11.06.27.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 06:27:52 -0800 (PST) From: Michal Hocko To: Andrew Morton Cc: , LKML , Michal Hocko , David Hildenbrand , Hugh Dickins , Jan Kara , "Kirill A. Shutemov" , William Kucharski Subject: [PATCH 3/3] mm, fault_around: do not take a reference to a locked page Date: Tue, 11 Dec 2018 15:27:41 +0100 Message-Id: <20181211142741.2607-4-mhocko@kernel.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181211142741.2607-1-mhocko@kernel.org> References: <20181211142741.2607-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. Suggested-by: Jan Kara Acked-by: Kirill A. Shutemov Reviewed-by: David Hildenbrand Acked-by: Hugh Dickins Reviewed-by: William Kucharski Signed-off-by: Michal Hocko --- mm/filemap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 81adec8ee02c..a87f71fff879 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2553,6 +2553,13 @@ void filemap_map_pages(struct vm_fault *vmf, goto next; head = compound_head(page); + + /* + * Check for a locked page first, as a speculative + * reference may adversely influence page migration. + */ + if (PageLocked(head)) + goto next; if (!page_cache_get_speculative(head)) goto next;