Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp715475imu; Tue, 11 Dec 2018 06:30:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uw6bFsbxPP4gffAjAeIAM0a2W1Cux0Gs32a0Pdm+riWSxCPp/ZjNT1ofOIA3AQR3OGF1g+ X-Received: by 2002:a17:902:9692:: with SMTP id n18mr16595478plp.333.1544538651484; Tue, 11 Dec 2018 06:30:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544538651; cv=none; d=google.com; s=arc-20160816; b=TkFn280glmCJxmykawHV15RZWoc9Xq5MNtsAPDQcixs/RsU8UVSdh7jrzDzJaN05dE V2amGWrNYEgHNSOdD4Zv2+q50EG/3lMu9SicROEudMOw0BIrrzOkUbrcRGBxE1A/wZ6A CnX3qYnk+Zl1LlrOPDEJ0hlXYOynQH8UeGnkHVDJT3ERTxrx+YCCSQvOoVHqVGmGa/RV oVeh0/tLyRSyxevRKdFG61dzSjXHrrs4UhvsDUkllP/Rs2mgtbHkisEpsscX2pJgjDQb zQq7r7iiwc3642vSxtYLcU15kklz2ub454ZAzZQ989zXlCU6NYwxi3A8bEQACNnjGsHR uWUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Iw/C/mJloVWnnEeI9hr/rFUfYtnu/dchJcsf1iUtKds=; b=mCgrrwtsUwgyv9gfZivAU1fYo2NyiFBHfg+WN9ZMqqHLR7oikG70XnMwpEkITM8Wr8 oYbcXchbzIg8YMxm68wqDqN6fMPC05CqCn4QFsD/tIJmplqYSuvbJjyFujbZvgl2EwDn fViO1RU9VMqhyw2bxGRIr6Kub7Y8KIHUzHlAv4dTVNiTqrrT18Rw8wIORtiQM4Vya/91 1N3OYqpB0XgrQxcay7mj1asgajwdy0teZCApZ+eSqiNJTB6FennhSXA8ZpGBiN885msH VB7PxcrwAARtJEFmtZYqDZUiFjf7wRbR5DOtmXGHiFPs81Gv1+fTHsnj1rxtzfzKk3Y4 fnAQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2si13555789pgr.67.2018.12.11.06.30.36; Tue, 11 Dec 2018 06:30:51 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726860AbeLKO14 (ORCPT + 99 others); Tue, 11 Dec 2018 09:27:56 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:45516 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbeLKO1y (ORCPT ); Tue, 11 Dec 2018 09:27:54 -0500 Received: by mail-ed1-f68.google.com with SMTP id d39so12639312edb.12 for ; Tue, 11 Dec 2018 06:27:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=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=JF+eQD8DgFl54saMVW+1nBv8TjlxCQE0bVkgviugDVwhasCaEnKdcqLKs1+kfW8Rku LQuRkyDNlThSc9wLEONTYEIbnj9JYt44rsc2qy9TdRgb7Kc2YZuaoF7CyTlELLAARe/d yu7YZhwuaesX4eq45kWScwhCCi8+ZYCklp/sg5mjQGP+enjfEcmmkBs1yB0iLXhLGdaU v6O+MJbUYegth1ZQisV5dlpoYbEMfj2zH/pY+nmpH+8W6iYy507v3e4xkIVXPaJSPMj/ zYPkUoKXCqaTnV5vZhRiqFiLG0loiRlYp07itCSlXe4G32V1aV+Swp+cDULUTeRIv5kr OaGg== X-Gm-Message-State: AA+aEWZRE2ZjQpbUhTMpyXKCLXQ9dnbU5D+oIgeHsSc5d+tgogY9NwR4 S+CuI50TDXtIkUhMPZj4pPI= 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.19.2