Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1432877rdb; Mon, 2 Oct 2023 09:18:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdRRe87bPz+BwBKfg5yrOqkxjDv9W7+2GzUVHyFcvh94vDH5tOJM1XuvfKmcxNJRm3Y7kX X-Received: by 2002:a05:6a21:338d:b0:151:577:32d1 with SMTP id yy13-20020a056a21338d00b00151057732d1mr14408708pzb.22.1696263530948; Mon, 02 Oct 2023 09:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696263530; cv=none; d=google.com; s=arc-20160816; b=MwT0LDlsv8XEiIBTZKPCb/s0+AMzSiVlV6fxc6p9yuACe0+YroH+WdMH4kK9NHdveY pBwhzNe9TX4fU6HkduJcbtxzg/EifUA6P8/Fl1TXDp5esyhEyNSnB4ELXYdsUgGUEhma NAy2unRZkcBdx00HtBAlXhwS2kzXa/43g9+KrXco7xI693vv/sB+UdJ4OH1xi99mzIFY yg1Z/tgUMnnUwuxWo0/Q3WsZNFDE/XNg5Q/gHNaJ+KzwIUatbWAOZK0tpAfGnaumsSXI 69JPrDamNZPD+HzS00xTknubOpT6ypAL3ImzeMJOjGe80iJxKQBxE4K05FPSd7yjIBhk V5Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vPWjZhtEz0XZOfaHC6v5q0++fyRvHTSEI8HhpIfDjOA=; fh=lyXrRHkzIit/8cDigWc3IzfazmQpH485/dCDc0dDaAc=; b=tvbvMUb26iIEItHSFNS1A6Ngp8tHctAm5+N7RwC1FdWArRQUUKMsmysSMmyf8BTpv/ WXV48RlGz3SC/QxL3oeLEzwy+IEO7/10kacRkubsGz8MMRRq79PpKoJmZGZ84AyHbLR6 1kt8bsLiRqKw4AQ+LS6m0ckIc7aAmTA+yfXUkNNN2WmL0rJPLKOSVpNZWCsOnaAe5VTt Qz0NiOuTJoPiObIerkFmw2tJkifxFpkaccXp4GdlaRnoJ9CucMlKB1Rfoturhyb/4Wo7 P3fIG9k4xWOefZP4KhckbpHNnyh0ZjSgVw7tW8tpcSQjFqkaDoFHeAv5rdUHFc9WlMPa 2wEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=E6lZ4CUI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id q16-20020a656850000000b0056b4065299esi27600326pgt.621.2023.10.02.09.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:18:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=E6lZ4CUI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id E1F9E80AC47A; Mon, 2 Oct 2023 09:02:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238382AbjJBQCJ (ORCPT + 99 others); Mon, 2 Oct 2023 12:02:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238367AbjJBQCH (ORCPT ); Mon, 2 Oct 2023 12:02:07 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A515D3 for ; Mon, 2 Oct 2023 09:02:04 -0700 (PDT) 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=vPWjZhtEz0XZOfaHC6v5q0++fyRvHTSEI8HhpIfDjOA=; b=E6lZ4CUI7Wr7e0ZDL5o1kKW2iH 8dZp176IPQmhLWHsCYyq+xODP0IoDOkbBLN2HdkbJw41kE7l1ko/zDp/jpboryWxKxSG5KZHC8pZI VE9MUGh6v0h+FW4wV3opPFMo19kgDo9xm+gWXHqJKAcApZoRkJ6e8MrJ+jN6GhpeLeg67YWNCdRUR zQVR6O/phSWirUIYJ7/SlxxHCO3XguVu12sPxqU5kFhLlB9ihyNpL4gSeHaDXuCziSrGsjTWQ6Rol sksg8yoe7FlsZOWsbkCGn95h6EAdP01ExcE6YEph7I69sGRyEpsHt9iOJmJctkRRmXxcT8lX7H/qc mGMv4mGA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qnLMu-009vnO-6t; Mon, 02 Oct 2023 16:02:00 +0000 Date: Mon, 2 Oct 2023 17:02:00 +0100 From: Matthew Wilcox To: Lorenzo Stoakes Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Jan Kara Subject: Re: [PATCH] mm/filemap: clarify filemap_fault() comments for not uptodate case Message-ID: References: <20230930231029.88196-1-lstoakes@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230930231029.88196-1-lstoakes@gmail.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 02 Oct 2023 09:02:29 -0700 (PDT) On Sun, Oct 01, 2023 at 12:10:29AM +0100, Lorenzo Stoakes wrote: > The existing comments in filemap_fault() suggest that, after either a minor > fault has occurred and filemap_get_folio() found a folio in the page cache, > or a major fault arose and __filemap_get_folio(FGP_CREATE...) did the job > (having relied on do_sync_mmap_readahead() or filemap_read_folio() to read > in the folio), the only possible reason it could not be uptodate is because > of an error. > > This is not so, as if, for instance, the fault occurred within a VMA which > had the VM_RAND_READ flag set (via madvise() with the MADV_RANDOM flag > specified), this would cause even synchronous readahead to fail to read in > the folio. > > I confirmed this by dropping page caches and faulting in memory madvise()'d > this way, observing that this code path was reached on each occasion. > > Clarify the comments to include this case, and additionally update the > comment recently added around the invalidate lock logic to make it clear > the comment explicitly refers to the minor fault case. I do appreciate the comment being made accurate, but I wonder if we shouldn't change the code to match the comment. We're got two "should"s pointing in different directions -- we "should" not use readahead if readahead is disabled, and we "should" always use readahead first, using read_folio() only if readahead doesn't succeed. The code isn't ideally structured for this, but I'm going to play with it a bit and see what I can create.