Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp856528imu; Tue, 20 Nov 2018 08:00:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/WYRaM32uFt95aUclCteJu7RCLcjGF0YFEH9x8a6bF1rzhG5mtkaCsYgXyGDcEdbQRT+sN2 X-Received: by 2002:a17:902:820d:: with SMTP id x13mr2824261pln.229.1542729658281; Tue, 20 Nov 2018 08:00:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542729658; cv=none; d=google.com; s=arc-20160816; b=GeQzYLQaqHhEWSL2L/+bXr19G+BjuZ09/q4OSyBQmZoNv76LzmLxL0ddIpraLvXkQT Lw9kig6HLeGo7ArKWHr9chv5+mmlawh/gW+dz6H9sqqNoyQrkQMszOlHKJflca8Vw2yj XjS+ckh1QfWQn2wHW5x5BcmCVeTdyNZjsSz6PiUgD422n9oE+i11//Qju2MYfvkaegZS d0SQgPl1yp9RFLgtQ4QhO44aMU9Y2GMfnBahzR0lr8UcC5PNaYZSlvlp/3jtcfbLHShW E0PseXLZWQlLSQOG/Ly6XdJTWe0Ss1bW8r8dWwPTaH+/ycdZPAVm5968L/4sUfYVQqnP R6Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=bmslT6uQsOKX5pQbU8zJBJWLoVGJv1MNTbcnIN5QJcE=; b=N5AhVqTUxe+9eRlXYUrI3XdTboewu+q/7OZ5XCXql45vz413mbcslfxGTHnKsnLegZ 4lziG51EVCQ7JtvWetDo/pSgKCgK3JUCTCVaKByXAppm3cavsAFo7kpsUG9sMGjpM7T+ gZ90J/M2+/Y/H+T4hLvRWHPV+cibptNqpL+4REXmmHqaEG/I940vo0BA1muQzbe51PZv ZX6FkqHOBqehyDwA8rE9vyBfDpaOBXcmAUkoLghZo6DHGAjCf5K+F0oZ6J6GU7rCbnkW /RIZtp4Kr9+cljCTZX0YoklHGqmWE3XUJ8TFlVC6GuSbdhGxs0t/UATlwmD5a0gCY0ro 3sGA== 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 p16si9309032plr.31.2018.11.20.08.00.42; Tue, 20 Nov 2018 08:00:58 -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 S1728751AbeKUAla (ORCPT + 99 others); Tue, 20 Nov 2018 19:41:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:58638 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725995AbeKUAl3 (ORCPT ); Tue, 20 Nov 2018 19:41:29 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6043AB082; Tue, 20 Nov 2018 14:12:08 +0000 (UTC) Date: Tue, 20 Nov 2018 15:12:07 +0100 From: Michal Hocko To: "Kirill A. Shutemov" Cc: linux-mm@kvack.org, Andrew Morton , Oscar Salvador , Pavel Tatashin , David Hildenbrand , LKML Subject: Re: [RFC PATCH 3/3] mm, fault_around: do not take a reference to a locked page Message-ID: <20181120141207.GK22247@dhcp22.suse.cz> References: <20181120134323.13007-1-mhocko@kernel.org> <20181120134323.13007-4-mhocko@kernel.org> <20181120140715.mouc7okin3ht5krr@kshutemo-mobl1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181120140715.mouc7okin3ht5krr@kshutemo-mobl1> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 20-11-18 17:07:15, Kirill A. Shutemov wrote: > On Tue, Nov 20, 2018 at 02:43:23PM +0100, 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. > > Looks fine to me. Thanks for the review. > But please drop a line of comment in the code. As is it might be confusing > for a reader. This? diff --git a/mm/filemap.c b/mm/filemap.c index c76d6a251770..7c4e439a2e85 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2554,6 +2554,10 @@ void filemap_map_pages(struct vm_fault *vmf, head = compound_head(page); + /* + * Check the locked pages before taking a reference to not + * go in the way of migration. + */ if (PageLocked(head)) goto next; if (!page_cache_get_speculative(head)) -- Michal Hocko SUSE Labs