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.6 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 6EECBC2D0A3 for ; Thu, 29 Oct 2020 21:54:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9B3002075E for ; Thu, 29 Oct 2020 21:54:42 +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="XPhU5PrJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B3002075E 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 A3C2E6B005C; Thu, 29 Oct 2020 17:54:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9ED196B005D; Thu, 29 Oct 2020 17:54:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 903506B0062; Thu, 29 Oct 2020 17:54:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id 611B46B005C for ; Thu, 29 Oct 2020 17:54:41 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F3441180AD815 for ; Thu, 29 Oct 2020 21:54:40 +0000 (UTC) X-FDA: 77426317920.19.print53_45108d727290 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id D2C241AD1AD for ; Thu, 29 Oct 2020 21:54:40 +0000 (UTC) X-HE-Tag: print53_45108d727290 X-Filterd-Recvd-Size: 3268 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Thu, 29 Oct 2020 21:54:40 +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=bv8hnTa54VlkYDZjalLAhF4ZVRuvo5SR7h8bMctCOls=; b=XPhU5PrJG7WY0XuucbwD8TVC+n mI5h6nxWWCsXPz4MdpP5l2WZdYAKeNArmwMIU94/5zCrq3pRkGEMn1afIm1nUkg8XmzYsG41agOAY ylLvV4/j7ZVBtA8orn2sSXN1a/jPWmJjF0LnIkS3KfVtuGaDAuUhCZtAaT14RSKUO57s851SVGjM5 8Su2L82N5tMeEdjRa6i/FMks4QuZNY63hxSZ266LrSRzrbX+XQozDHgP6mG3oDFglongZB0pWa91H WKw58zTaD4mBnJpEWJJ0RHOTeqNJY6UuPKkbSF1Miq4+qkZ3feZlLTrW8g9j2dFdhdIT7QcJwUKxa nrze2CbA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYFsU-0000hO-Nw; Thu, 29 Oct 2020 21:54:38 +0000 Date: Thu, 29 Oct 2020 21:54:38 +0000 From: Matthew Wilcox To: Zi Yan Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 02/19] mm: Use multi-index entries in the page cache Message-ID: <20201029215438.GE27442@casper.infradead.org> References: <20201029193405.29125-1-willy@infradead.org> <20201029193405.29125-3-willy@infradead.org> <4D931CDD-2CB1-4129-974C-12255156154E@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4D931CDD-2CB1-4129-974C-12255156154E@nvidia.com> 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 Thu, Oct 29, 2020 at 04:49:39PM -0400, Zi Yan wrote: > On 29 Oct 2020, at 15:33, Matthew Wilcox (Oracle) wrote: > > > We currently store order-N THPs as 2^N consecutive entries. While this > > consumes rather more memory than necessary, it also turns out to be buggy. > > A writeback operation which starts in the middle of a dirty THP will not > > notice as the dirty bit is only set on the head index. With multi-index > > entries, the dirty bit will be found no matter where in the THP the > > iteration starts. > > A multi-index entry can point to a THP with any size and the code relies > on thp_last_tail() to check whether it has finished processing the page > pointed by the entry. Is it how this change works? Maybe I need to do a better explanation here. Let me try again ... Consider an order-2 page (at address p) at index 4. Before this change, the node in the XArray contains: 4: p 5: p 6: p 7: p After this change, it contains: 4: p 5: sibling(4) 6: sibling(4) 7: sibling(4) When we mark page p as dirty, we set a bit on entry 4, since that's the head page. Now we try to fsync pages 5-19, we start the lookup at index 5. Before this patch, the pagecache knows that p is a head page, but the XArray doesn't. So when it looks at entry 5, it sees a normal pointer and no mark on it -- the XArray doesn't get to interpret the contents of the pointers stored in it. After this patch, we tell the XArray that indices 4-7 are a single entry, so the marked iteration actually loads the entry at 5, sees it's a sibling of 4, sees that 4 is marked dirty and returns p.