Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1421901imu; Tue, 20 Nov 2018 17:55:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/U1oLBEu0YA1L1v8+SxLVa22fdvgy/5XceQGsA6alWLY5/COEhvWPZzhuRmm75areCrhy4h X-Received: by 2002:a17:902:24c:: with SMTP id 70-v6mr4591618plc.120.1542765330020; Tue, 20 Nov 2018 17:55:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542765329; cv=none; d=google.com; s=arc-20160816; b=jb+yYaKsqS6r0MoGJ5+Z4o3EM4lWdW4dfDaT/c8WPflbEqpFr4nYXd4bHGaXzYHTun ERjgZq3kNLXQF7CIG3tAAHray9PyH9cnCTcBWD5jvao1PpC4+ZxGVtBDTlhzzwLlzsxF L0CgfMCSK8n6EiiL2pTQA+ZLRcbqRXsRizEjiYWeLft0HTm8j3jCzVa6cvjOErQYrn1H BNDDTZkNVUzT6qSRBgql+1via6mbG+ehRVDnPGjU9+GC1oHQUG02ilctFPlzrZ0wecsO oijehe/TrG3klqXXaQYc7j35lvFogeQHCAw3VqjlXWaKRvrtxC0OomShhEUWecLoM7GQ Jj0Q== 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:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=NQhDUiRdx+ni6DnegyCIvUwQH41AOZN7l3quC8qClOE=; b=azst2bRp7CJG9JWKouqFXdXMR0WgG+W5FlbI1jzOLFL1pin1X6nXbf9xg/Wp9yGs4d GMlt4o12rW4/5/8E9PBr/5sulNXJWpHQd8h/8IK64QAAW0ik28ocmOE7/oDhehC5qaGn TlOuNuE5t7Y1c0RmIXgpZgfilVct0qlLh+UvNOpMNl8ctTmvsWbUmmv/46TF95mdHwCq ZST7q6V+y0JepjPCy4HTgIiDl5/ewvg5RR5Qj96n5dqesRA2TbpJxSi6VkzKC1MEL88c wKbmGDhMO9CrNSk23JMl6jpyNG14DvOvCRTM3SZLgIdqn9KXLRyrbuWk6kWX+M9oqMlP B/cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CdfboDlT; 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 y11si22091603pgj.442.2018.11.20.17.55.15; Tue, 20 Nov 2018 17:55:29 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=CdfboDlT; 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 S1726229AbeKUMTf (ORCPT + 99 others); Wed, 21 Nov 2018 07:19:35 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:40747 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725913AbeKUMTf (ORCPT ); Wed, 21 Nov 2018 07:19:35 -0500 Received: by mail-pl1-f196.google.com with SMTP id b22-v6so3000262pls.7 for ; Tue, 20 Nov 2018 17:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=NQhDUiRdx+ni6DnegyCIvUwQH41AOZN7l3quC8qClOE=; b=CdfboDlTmfJPTp44yOLj2Rk/WxPrQ34XpH8zLG56fbhnerG1nFY7bKwrUqT5OsYz8E GSmYWx2Q08ny+q+AJoijmv2TQJbMDhjDeH0H0Hg/9qPsBhvzcPs8dTUjadkIfX+fSJ0l XRFKx7O8FtIBf4MtvyvnlJoBpc3dprtJff1O6JCPbUE3wsyYXE1KCpTt1bZb75QVGzPM INExqyqNkc7AbxTwvpEMgWaE07s5PVbKmGUcpVIkf6B68tQvYBdioh3fRKSwCVbGgC9P Oak9doFUYGbZxYOxb9OztmHaVjzJVNqJ9mWFHDzQZYJ4CjSB3ilR9oizqh8jlnoNrSeg 3tkw== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=NQhDUiRdx+ni6DnegyCIvUwQH41AOZN7l3quC8qClOE=; b=BFxY1TozX2zv+xQ8yprVfreAp7s4MRCeT5myGgK8eOzYQuEOxcGIIwqeCKOCVIZamb D1q56+cBPk7utgXitL5sND7oHhLUYzEC+h1KWHWvLguqWLJmRldYxqltqrAqQqgnzz9h 740LrdjHYdswARCIrFLdLitL15m1zhFJSBD7IuNHQrI23/XjmbxOxeJQCIpCbUxDUaLy dVZaDLeoVteR9IYf+MlIA2+NCSJg4dHgARdCzvwzvZdqjjwZ0dQ+16XI11AghFlTYTeA 8COPL4kI/1Zn9e+CxCXS5iiR7DsMxdsNOtc3/XSJJ15zlyvNntd1a1o/ZBLaFxubUdOx nnzQ== X-Gm-Message-State: AGRZ1gK1XuRjG9ITXSdYLCKDl9K6IjXTZT7RxxIkFAGIHF65KsuEcnme ry7wXfmUx0ofgo9+Z+4gsOfkhQ== X-Received: by 2002:a62:ed09:: with SMTP id u9-v6mr4630060pfh.188.1542764843686; Tue, 20 Nov 2018 17:47:23 -0800 (PST) Received: from [100.112.89.103] ([104.133.8.103]) by smtp.gmail.com with ESMTPSA id h17-v6sm63357489pfj.125.2018.11.20.17.47.22 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Nov 2018 17:47:22 -0800 (PST) Date: Tue, 20 Nov 2018 17:47:21 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Michal Hocko cc: linux-mm@kvack.org, Andrew Morton , Oscar Salvador , Pavel Tatashin , David Hildenbrand , LKML , Michal Hocko , "Kirill A. Shutemov" Subject: Re: [RFC PATCH 3/3] mm, fault_around: do not take a reference to a locked page In-Reply-To: <20181120134323.13007-4-mhocko@kernel.org> Message-ID: References: <20181120134323.13007-1-mhocko@kernel.org> <20181120134323.13007-4-mhocko@kernel.org> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) 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 On Tue, 20 Nov 2018, Michal Hocko wrote: > 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: Hugh Dickins though I think this patch is more useful to the avoid atomic ops, and unnecessary dirtying of the cacheline, than to avoid the very transient elevation of refcount, which will not affect page migration very much. > --- > 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