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 E7A9DC433EF for ; Tue, 28 Jun 2022 13:18:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 445646B0071; Tue, 28 Jun 2022 09:18:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CE558E0001; Tue, 28 Jun 2022 09:18:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26F966B0073; Tue, 28 Jun 2022 09:18:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 10EA86B0071 for ; Tue, 28 Jun 2022 09:18:36 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id D074F120F23 for ; Tue, 28 Jun 2022 13:18:35 +0000 (UTC) X-FDA: 79627698990.06.5B62015 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id 83788A002D for ; Tue, 28 Jun 2022 13:18:34 +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=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: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422315; a=rsa-sha256; cv=none; b=WT0Mx5r8xnewNUZfpiD79IIV8y/k37uMm0xFLeH2GwcpYuNuaC5OU/WQ1ayYxOmzFlzGfx kKOwufKgk0O1EJvqmZ2CLRExlULmdVfKxAll4eGyxWMlicIrxbavRIAhPc+tXuPjMfyXv0 DPSbB4qjrNUCjMIHkDMJ/FuL1Sb0V40= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Nnj2Ccgc; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422315; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YT77W1AlVsAd+5fjjhsWneZG4oSBwEAMjMvkdlzQ5Xk=; b=N3qX7LeArw1QXpEhhyDDgISNYr4jx1d42I/+Z6e+fjmvih6Vm2/Lj49F/lAp2YMajTYDQv XS5BWl8ge/ql9TcyOfH1pbWlZIaZeSzhzLkIzEpHCHD9eYeXTVqd7O/6w6oLwJV8alpXhH LPzW2TEUR6HjzUCztx/8YEVFM+vciyQ= X-Stat-Signature: 3xorxc5umqq49tsr7kuk7zh5pdiytcpb X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 83788A002D Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Nnj2Ccgc; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1656422314-119324 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 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);