From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3374C43334 for ; Fri, 3 Jun 2022 12:44:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E1068D0002; Fri, 3 Jun 2022 08:44:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08FCD8D0001; Fri, 3 Jun 2022 08:44:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBE8C8D0002; Fri, 3 Jun 2022 08:44:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DD06C8D0001 for ; Fri, 3 Jun 2022 08:44:54 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7A6C1215AE for ; Fri, 3 Jun 2022 12:44:54 +0000 (UTC) X-FDA: 79536894108.10.03A3504 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id C016F160064 for ; Fri, 3 Jun 2022 12:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=prHzuJSdGpXr6LjPnJTEpBNy5odArLyBYR2PLFVZaIM=; b=nNv1FpDeC/fFG0CJOJCWZ+P397 4zUtZVcvttb8/mnnEHWzmbrMbhPB0X0OxVPwS1Ya6QHS3YIo+QvL0n5uPH/hMaYdlOxOlEzEClyJ2 y+p8YmqIgQkW8+mygDdL26+KVmZydN5xBiqt0QY/pzrjjT3o6WWYim0SAOvO5tfo7E5kKPF7CwW4z 8fiegG1fkthos8v9G1bqDslNFUyL/tgQbfvCSVe1lPv/GwuUGFucf6pxG6i8VAG3ZTCEQSanvzJLN 1xL458Ulx70RperxceADPp1+95D3dVTsDgdaCbJfrFUlR1FO49hQhbKn16ckmjwaI+2lG7CE4irRU Th6aodcw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nx6fU-007tzV-OM; Fri, 03 Jun 2022 12:44:44 +0000 Date: Fri, 3 Jun 2022 13:44:44 +0100 From: Matthew Wilcox To: Alistair Popple Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/filemap.c: Update comments in filemap_fault() Message-ID: References: <20220603071233.2296100-1-apopple@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220603071233.2296100-1-apopple@nvidia.com> X-Stat-Signature: 4sydw9q4h1hp7374rcy41gaoittqezai X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nNv1FpDe; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C016F160064 X-HE-Tag: 1654260266-610934 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: On Fri, Jun 03, 2022 at 05:12:33PM +1000, Alistair Popple wrote: > +++ b/mm/filemap.c > @@ -3168,8 +3168,9 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) > VM_BUG_ON_FOLIO(!folio_contains(folio, index), folio); > > /* > - * We have a locked page in the page cache, now we need to check > - * that it's up-to-date. If not, it is going to be due to an error. > + * We have a locked page in the page cache. Check that it's up-to-date. > + * If not it is because there was no page in the page cache (only likely > + * in the case of MADV_RANDOM) or due to error. The comment is correct, but the code is buggy! We should be calling page_cache_ra_order() in do_sync_mmap_readahead(), even if VM_RAND_READ is set (or !ra_pages, or mmap_miss is high). At least for one page. That would allow us to drop the FGP_FOR_MMAP flag as page_cache_ra_order() will instantiate a folio for us. Do you want to write that patch or should I do it?