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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 2434FC433E6 for ; Fri, 28 Aug 2020 18:01:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DB2952098B for ; Fri, 28 Aug 2020 18:01:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="HwvG40IR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB2952098B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6AF336B0005; Fri, 28 Aug 2020 14:01:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65FBD6B0007; Fri, 28 Aug 2020 14:01:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5755C6B0008; Fri, 28 Aug 2020 14:01:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 3E3846B0005 for ; Fri, 28 Aug 2020 14:01:49 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D16C8180AD83E for ; Fri, 28 Aug 2020 18:01:48 +0000 (UTC) X-FDA: 77200745496.13.tin45_2712bd227077 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id C186A18141ECE for ; Fri, 28 Aug 2020 18:01:45 +0000 (UTC) X-HE-Tag: tin45_2712bd227077 X-Filterd-Recvd-Size: 3075 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Fri, 28 Aug 2020 18:01:44 +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=TCdSDveP9DgaruAwbNsFcYgSDvQtSk4Vjo66ti6ZCeo=; b=HwvG40IR7695pwSDW5J+mZ2xXt BmajendNPRfCQw7hmmyaLViI4UkRnB5MXsgbwtq9nSN7w3De2M5hbfXHXN1v4YUt9RUbbW9NbR36d wr9ze1WE/D/BFjBUCLmfe/1DtF5pspQatSpNCcIuUroi7fNLMafb6LzSiKvEltuXQ+RVtD9Eg0zWZ 2PNYy1FAfy6KVSSXTUf/R6ZMvRs+m8tjVms+C43Hses3LvADXn9uBicGeB4hNECGUg8EEDQ8383q3 uo+EE4CncoCPvz/TVovO1ZPgprD4P1VXM/ggfLHWiy0eu2LBWPQtrrGPY0/diSztqWTyhL+/dqhNh 67YbH2Xw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBih2-0005hF-JA; Fri, 28 Aug 2020 18:01:40 +0000 Date: Fri, 28 Aug 2020 19:01:40 +0100 From: Matthew Wilcox To: Hugh Dickins Cc: Linux MM , Yang Shi , Yang Shi Subject: Re: Is shmem page accounting wrong on split? Message-ID: <20200828180140.GQ14765@casper.infradead.org> References: <20200828142546.GN14765@casper.infradead.org> <20200828145528.GO14765@casper.infradead.org> <20200828173122.GP14765@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200828173122.GP14765@casper.infradead.org> X-Rspamd-Queue-Id: C186A18141ECE X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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, Aug 28, 2020 at 06:31:22PM +0100, Matthew Wilcox wrote: > On Fri, Aug 28, 2020 at 10:08:52AM -0700, Hugh Dickins wrote: > > It's a good observation of an oddity that I probably didn't think of, > > but you haven't said which kind of shmem page accounting goes wrong here > > (vm_enough_memory? df of filesystem? du of filesystem? memcg charge? > > all of the above? observed in practice?), and what needs solving. Oh, I forgot to say which > The problem I've observed in practice is following the same pattern in > truncate_inode_pages_range(). The call to delete_from_page_cache_batch() > trips the assertion that the page hasn't already been deleted from the > page cache. I think the solution is obvious -- don't add the page to > locked_pvec if page->mapping is NULL. Here's the change I'm currently testing. It's survived about eight minutes of xfstests so far, which is far longer than it was surviving before. - /* Try to split huge page, so we can truly punch the hole or truncate */ - return split_huge_page(page) >= 0; + /* + * split_huge_page may remove the page itself; if so, we should + * not attempt to remove it again. + */ + return split_huge_page(page) >= 0 && page->mapping;