Received: by 2002:a05:6512:e85:0:0:0:0 with SMTP id bi5csp3100656lfb; Tue, 28 Jun 2022 06:31:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tPfQqxYsqauxzHGgm3sn6F1NuFjAGMiCxDTMdo9Rad2lFEycCRI1H/xzK+SB4tt5wdB9TS X-Received: by 2002:a17:906:7394:b0:722:e9c5:8e82 with SMTP id f20-20020a170906739400b00722e9c58e82mr17899226ejl.239.1656423110579; Tue, 28 Jun 2022 06:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656423110; cv=none; d=google.com; s=arc-20160816; b=nIvYTPKFIdEt/ZlcV0Choi2auK/vwyqVToteyD8LXm5SGlwj13Xsqhcuo/ppam74fr iYhxl6VfpT4tEJ0HG67jhxLj9k6cvXGYxUHLIZ51N31EFA9hi3NVYffy07hQLWTxdUzH QBEObUxo3HA8RDKi5SaIV//CQPAt1ssWIp9uhlIxUKxklx3M+Z+nKV09Q41Lvjx5Gs1T 5X/ho8sLm3jxo4lx26YjBOuGPjyjoZHjIRmX+sp8zgwBiyJn7C/m+0xnpQBiWVFOcpCW O5ifUxrTfzgn4/uzoU0e1q2AMD2doU0ZuGtL83xI7ZVE5TR8YC8Zv16XDIqSOPK2ruNe yugQ== 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=YT77W1AlVsAd+5fjjhsWneZG4oSBwEAMjMvkdlzQ5Xk=; b=Cofau9TXJZVN7E3NhQ52qy56Ytt/X3YZHhiuz83yyB97SIEmjLljWjirwENn8PVKpP IxNGVxzWHPF93RJpDXqQ65bAITDBX6qiDeycwTr9RjPDHMMATTi6qQW67/yox+UIrfqd LsqCybqJmP/Kba/dV2SoCOWlcarHPzeUGfomhcYvY+rX2Y7LVHxuhY+msGePH5YxP/b0 GYs0+8ts5AbSK5gRbhFEI4JKYAkpPGhbUYGz7aD5F7zKBmp6HiIgzw0q9TZL1AMvPbWQ fRKxTtinpL/eHSgfbEiiVkvHbpIqqBcUmLkzbentWpRO/YCgVzP/NTss5eEBx6fBxSCJ PS3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Nnj2Ccgc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020a170906a08900b00722f8c55e6csi16776588ejy.817.2022.06.28.06.31.19; Tue, 28 Jun 2022 06:31:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Nnj2Ccgc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346451AbiF1NUd (ORCPT + 99 others); Tue, 28 Jun 2022 09:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346392AbiF1NUQ (ORCPT ); Tue, 28 Jun 2022 09:20:16 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 733E4344F8; Tue, 28 Jun 2022 06:18:29 -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=YT77W1AlVsAd+5fjjhsWneZG4oSBwEAMjMvkdlzQ5Xk=; b=Nnj2Ccgc6EeKn3kAO/0bxru+gf Z2RPO+a8J2GyLnljKGhXPnUyjyaAr6q+7arbNdCjiNMQEvPmx5r06Sf4e9BaEQtUkHD1Na9onas9Y Opw64Jcl1XgbLTZ5YUtLUpyYyUPnBbl2cu2tEr+rISNhSu1Dhjbqj4frau7IAioH3jKW6wIXyYM9z 8137jSyn4QOFwJwGnm9OGjkia7aBtuvSDbqOPvq03ay6+D1t7TmgraNga7YBRDVCod1x5c6I0eZLT GMnw7oLsfweYOSS4c24KK9jysr9ylJbJf8pyHWIEEWH5qRhVbCQxZDQYsL5GVo33DXGewm0sBiAJp JwI4O08g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6B6m-00CJb0-Oa; Tue, 28 Jun 2022 13:18:24 +0000 Date: Tue, 28 Jun 2022 14:18:24 +0100 From: Matthew Wilcox To: Dave Chinner Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , linux-mm@kvack.org Subject: Re: Multi-page folio issues in 5.19-rc4 (was [PATCH v3 25/25] xfs: Support large folios) Message-ID: References: <20211216210715.3801857-1-willy@infradead.org> <20211216210715.3801857-26-willy@infradead.org> <20220628073120.GI227878@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 28, 2022 at 12:31:55PM +0100, Matthew Wilcox wrote: > On Tue, Jun 28, 2022 at 12:27:40PM +0100, Matthew Wilcox wrote: > > On Tue, Jun 28, 2022 at 05:31:20PM +1000, Dave Chinner wrote: > > > So using this technique, I've discovered that there's a dirty page > > > accounting leak that eventually results in fsx hanging in > > > balance_dirty_pages(). > > > > Alas, I think this is only an accounting error, and not related to > > the problem(s) that Darrick & Zorro are seeing. I think what you're > > seeing is dirty pages being dropped at truncation without the > > appropriate accounting. ie this should be the fix: > > Argh, try one that actually compiles. ... that one's going to underflow the accounting. Maybe I shouldn't be writing code at 6am? diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f7248002dad9..4eec6ee83e44 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -2439,11 +2440,15 @@ static void __split_huge_page(struct page *page, struct list_head *list, __split_huge_page_tail(head, i, lruvec, list); /* Some pages can be beyond EOF: drop them from page cache */ if (head[i].index >= end) { - ClearPageDirty(head + i); - __delete_from_page_cache(head + i, NULL); + struct folio *tail = page_folio(head + i); + if (shmem_mapping(head->mapping)) shmem_uncharge(head->mapping->host, 1); - put_page(head + i); + else if (folio_test_clear_dirty(tail)) + folio_account_cleaned(tail, + inode_to_wb(folio->mapping->host)); + __filemap_remove_folio(tail, NULL); + folio_put(tail); } else if (!PageAnon(page)) { __xa_store(&head->mapping->i_pages, head[i].index, head + i, 0);