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 X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D152C11F67 for ; Tue, 13 Jul 2021 06:25:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F2A161183 for ; Tue, 13 Jul 2021 06:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233762AbhGMG2h (ORCPT ); Tue, 13 Jul 2021 02:28:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231261AbhGMG2g (ORCPT ); Tue, 13 Jul 2021 02:28:36 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFFFEC0613DD; Mon, 12 Jul 2021 23:25:46 -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=5NJ/GobYssN7on3zOlsbOWTmiBv2EzLNZy86W7YdGXg=; b=fbsmLbOQszWOm3dv8Pr5kj2E7C 2oH8QijCtEXZ3EozE81NW39ttgW8OJljVf+LGGn1grSH4J/TUVDG0j2e/NTp+MRk4wJ9nnd3+guTz +uiAyPZWdlJAz/ObZcfnq4duRgc9SCYl6elA/kg4FjqqjxRWiSyctVBKCNGsl9KYTYO892oJYWZI5 TrvEbdC7HmPZPoevV1PUKcLJ6czjAami4Jbi7sr+F0PnKOI41Qf+ldIkfRpOlaioGlDjqxR3FtMJ3 yq3YPlebvzDtb55VjfVt14OhvN5M9EDIMhIcPqpI3SwMoNGZzFinwEFn0SbUkZR/uo311WDKHFLwQ 3JuzSKBg==; Received: from hch by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3Bqr-000oBA-3D; Tue, 13 Jul 2021 06:25:10 +0000 Date: Tue, 13 Jul 2021 07:25:05 +0100 From: Christoph Hellwig To: Jan Kara Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Christoph Hellwig , "Darrick J. Wong" , Ted Tso , Dave Chinner , Matthew Wilcox , linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, Christoph Hellwig Subject: Re: [PATCH 03/14] mm: Protect operations adding pages to page cache with invalidate_lock Message-ID: References: <20210712163901.29514-1-jack@suse.cz> <20210712165609.13215-3-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210712165609.13215-3-jack@suse.cz> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Still looks good. That being said the additional conditional locking in filemap_fault makes it fall over the readbility cliff for me. Something like this on top of your series would help: diff --git a/mm/filemap.c b/mm/filemap.c index fd3f94d36c49..0fad08331cf4 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3040,21 +3040,23 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) * Do we have something in the page cache already? */ page = find_get_page(mapping, offset); - if (likely(page) && !(vmf->flags & FAULT_FLAG_TRIED)) { + if (likely(page)) { /* - * We found the page, so try async readahead before - * waiting for the lock. + * We found the page, so try async readahead before waiting for + * the lock. */ - fpin = do_async_mmap_readahead(vmf, page); - } else if (!page) { + if (!(vmf->flags & FAULT_FLAG_TRIED)) + fpin = do_async_mmap_readahead(vmf, page); + if (unlikely(!PageUptodate(page))) { + filemap_invalidate_lock_shared(mapping); + mapping_locked = true; + } + } else { /* No page in the page cache at all */ count_vm_event(PGMAJFAULT); count_memcg_event_mm(vmf->vma->vm_mm, PGMAJFAULT); ret = VM_FAULT_MAJOR; fpin = do_sync_mmap_readahead(vmf); - } - - if (!page) { retry_find: /* * See comment in filemap_create_page() why we need @@ -3073,9 +3075,6 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) filemap_invalidate_unlock_shared(mapping); return VM_FAULT_OOM; } - } else if (unlikely(!PageUptodate(page))) { - filemap_invalidate_lock_shared(mapping); - mapping_locked = true; } if (!lock_page_maybe_drop_mmap(vmf, page, &fpin))