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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 4CF3DC43461 for ; Tue, 8 Sep 2020 20:20:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E0EA120936 for ; Tue, 8 Sep 2020 20:20:00 +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="oxs7jd6K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0EA120936 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 856456B0074; Tue, 8 Sep 2020 16:20:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 82E906B0075; Tue, 8 Sep 2020 16:20:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76A0F6B0078; Tue, 8 Sep 2020 16:20:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 619ED6B0074 for ; Tue, 8 Sep 2020 16:20:00 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 24EF3181AEF10 for ; Tue, 8 Sep 2020 20:20:00 +0000 (UTC) X-FDA: 77241010560.10.shoes87_3e16794270d7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id E896316A06B for ; Tue, 8 Sep 2020 20:19:59 +0000 (UTC) X-HE-Tag: shoes87_3e16794270d7 X-Filterd-Recvd-Size: 3179 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Sep 2020 20:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=LjtV5wk6eIAid7tNJvpICxRfbTSJyHh+qMf4hAvSbBQ=; b=oxs7jd6KdExFLWT9Y2KQmjTTle AILKtncWkcHlsNdU9jaPP6SoLPnWf/LZPXDfxvggcfgwLRo7PI5tV5XswigVGDD6bEPav1NMDtkuB UmSnxSX6WYxhjisQezRwrz9ks/VU7l9vZDhw0cun8HHx65PSkwAJzHXz5H3Tmnxj1Ygv7uhw1Pqnd 8zzSAsSDORoAZt5Om8O5pxYh0O0bSbX0suV84Gb2g6aIML5jRJF6ewE00O/JuDNd3RQ9n+A8FAig2 qFHEPITUQqPnjbiwj0C8VSofVDvTmBG8PQF11iL5N6SicM1+7HrHNWLO4Jyg4C8HHAH4b72lCXZr3 cAZUloNg==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFjib-0006nW-L3; Tue, 08 Sep 2020 19:55:53 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , "Kirill A . Shutemov" , Huang Ying Subject: [PATCH 09/11] mm/truncate: Fix truncation for pages of arbitrary size Date: Tue, 8 Sep 2020 20:55:36 +0100 Message-Id: <20200908195539.25896-10-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200908195539.25896-1-willy@infradead.org> References: <20200908195539.25896-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E896316A06B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 Content-Transfer-Encoding: quoted-printable 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: Remove the assumption that a compound page is HPAGE_PMD_SIZE, and the assumption that any page is PAGE_SIZE. Signed-off-by: Matthew Wilcox (Oracle) --- mm/truncate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/truncate.c b/mm/truncate.c index dd9ebc1da356..1cc93b57fb41 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -168,7 +168,7 @@ void do_invalidatepage(struct page *page, unsigned in= t offset, * becomes orphaned. It will be left on the LRU and may even be mapped = into * user pagetables if we're racing with filemap_fault(). * - * We need to bale out if page->mapping is no longer equal to the origin= al + * We need to bail out if page->mapping is no longer equal to the origin= al * mapping. This happens a) when the VM reclaimed the page while we wai= ted on * its lock, b) when a concurrent invalidate_mapping_pages got there fir= st and * c) when tmpfs swizzles a page between a tmpfs inode and swapper_space= . @@ -177,12 +177,12 @@ static void truncate_cleanup_page(struct address_space *mapping, struct page *page) { if (page_mapped(page)) { - pgoff_t nr =3D PageTransHuge(page) ? HPAGE_PMD_NR : 1; + unsigned int nr =3D thp_nr_pages(page); unmap_mapping_pages(mapping, page->index, nr, false); } =20 if (page_has_private(page)) - do_invalidatepage(page, 0, PAGE_SIZE); + do_invalidatepage(page, 0, thp_size(page)); =20 /* * Some filesystems seem to re-dirty the page even after --=20 2.28.0