Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp703588imu; Tue, 20 Nov 2018 05:45:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/XL/CzFUIWDI5w76qAaWSckDEgW7GW1G+S/uM2HPtVJcOyzKt54bwdFm2ftDAaKjKn7dVkG X-Received: by 2002:a17:902:7c0a:: with SMTP id x10mr2309537pll.65.1542721511717; Tue, 20 Nov 2018 05:45:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542721511; cv=none; d=google.com; s=arc-20160816; b=lNYyqzT+sMvdpl9PJp6U8B7tvB5CZi34+MpzL2rKIqeaQ+ToIDV8OYQcCAk1T+23Jv mDjeAuX/SgMHc4mQKGnHcPcKTNPJTXZBtriXzfmUALf0lItaKeBh1RrgnarQ3bTC/tco m4NNEzhClUzcw6MXUcBAmIeOxui55s7X57GsdjdZrpFFCb1611jM7Yr2sPTaBUER02hP 5qpgsz2pOvp5mfb7AXel7mq6Apu54PGS2fQ8jgfXtWZkjQREgbxPlRoys60pZEZfsja2 x9HJpAGGkx+xLCWFZojJvCF0ZydWB8AX18DKk9nlHWPnVMK5D/X/mB9hLz6o0JWyYVXb 4qpg== 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=/sEYolIbYeBRlPTEJk3IyaZRfhMjojYPi0YASgHfRGI=; b=K8GACb3cXVa7Mrg9DW6Aw/1cSdSgLRIeD0xco671kuwWCqL/nrw0GRKjPEnebZLbvE cK9WlLYHrPtXssJPVpJ2c6R+wbZcW7vLNxABu378golMCISKGuNSu/1SzD9klCdRr3dJ e3ozJ9Dk+/izi3oilhEQkr6E8NvGXeSkNG+imPJl8AKEoihxYPFcHKkPnLptvytVHGLs /JaaSKEYn+09bs5ThrBe+RAgKlsXt72NFx+n4vblRnUoQkzx+6Q48+niTE/Jjyp0BiQ8 O5tMgbg9FuYo/eR7dSxxAoOs+klxIMOykVnEsDFD/fRHb2LN7bHMp66B1uq0wdYhR0E3 R2VQ== 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 go3si14107254plb.97.2018.11.20.05.44.57; Tue, 20 Nov 2018 05:45:11 -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 S1729210AbeKUAND (ORCPT + 99 others); Tue, 20 Nov 2018 19:13:03 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:46524 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbeKUAMw (ORCPT ); Tue, 20 Nov 2018 19:12:52 -0500 Received: by mail-ed1-f65.google.com with SMTP id o10so1924139edt.13 for ; Tue, 20 Nov 2018 05:43:38 -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=/sEYolIbYeBRlPTEJk3IyaZRfhMjojYPi0YASgHfRGI=; b=rdMKhPjnbw/W99DJks3v4bJlG/nEtLvdV4le/2GBDNgRCQoSltCP4GrOmBBK3kNu4r oXYMOH3ffiu7hDNSULRkJKZVzmcGBZ6EVx6FDREK2TZSqHdYsn7DJZGAhi54bqT9RXws rYEXBSbLfacAJVAD8bhjwkXB/ysZMj3O9cup/riI1RvpmpRjY6Jc2rmc2ML6m2AFcZmX KKR+lFQpaCM7F8wyi4IlmMZpKAg5epYHaoGutuCfVJ81o30MwyypAEByEANEAlpu0eEn bJ8sIx9edeHaXaY6Jl+gE+rRHcApz6OSlC/FwMMi70tfQXbm+adqwFeTaU6wp9ZVTLw2 uneQ== X-Gm-Message-State: AA+aEWbXb1dyFE5H/l5atHu+HZxjjClhR5zG51V9WoFRPqlPpDqAuPZJ YmxvQWxDXFJ+/yVtQoYPahI= 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 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. Cc: "Kirill A. Shutemov" Suggested-by: Jan Kara Signed-off-by: Michal Hocko --- 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; -- 2.19.1