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=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 BCB08C433E7 for ; Fri, 16 Oct 2020 02:42:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5284120878 for ; Fri, 16 Oct 2020 02:42:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="WPu37cZp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5284120878 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DF6F2940024; Thu, 15 Oct 2020 22:42:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D57B7940007; Thu, 15 Oct 2020 22:42:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2062940024; Thu, 15 Oct 2020 22:42:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0060.hostedemail.com [216.40.44.60]) by kanga.kvack.org (Postfix) with ESMTP id 96A0F940007 for ; Thu, 15 Oct 2020 22:42:32 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 30700824999B for ; Fri, 16 Oct 2020 02:42:32 +0000 (UTC) X-FDA: 77376240144.19.rest71_101829627219 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 137941AD1AD for ; Fri, 16 Oct 2020 02:42:32 +0000 (UTC) X-HE-Tag: rest71_101829627219 X-Filterd-Recvd-Size: 3277 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 02:42:31 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75FEC20897; Fri, 16 Oct 2020 02:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602816150; bh=zj5Qi72+JcUV02+1z7NhEspgEON4ujFhOiOxPWE0y5w=; h=Date:From:To:Subject:In-Reply-To:From; b=WPu37cZplgGC1uurxfSKDcNItLaCyfl+dNdj3DS2w6IbsyNxISfhCy4JK5lrz9GEP /p/0nu0BMZLaSSUtDEyZgqJoRhl91aEj0kpa3s/XMRl6TkuBJWdup6TmwTKZWpvx1L 23dT7Ye6m2NX7XnB9NLLeBiQzgLXwVzv5+dJEErs= Date: Thu, 15 Oct 2020 19:42:29 -0700 From: Andrew Morton To: akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, sjpark@amazon.de, torvalds@linux-foundation.org, willy@infradead.org, ying.huang@intel.com Subject: [patch 027/156] mm/truncate: fix truncation for pages of arbitrary size Message-ID: <20201016024229.fSxjDMkXl%akpm@linux-foundation.org> In-Reply-To: <20201015192732.f448da14e9854c7cb7299956@linux-foundation.org> User-Agent: s-nail v14.8.16 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: From: "Matthew Wilcox (Oracle)" Subject: mm/truncate: fix truncation for pages of arbitrary size Remove the assumption that a compound page is HPAGE_PMD_SIZE, and the assumption that any page is PAGE_SIZE. Link: https://lkml.kernel.org/r/20200908195539.25896-10-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Kirill A. Shutemov Reviewed-by: SeongJae Park Cc: Huang Ying Signed-off-by: Andrew Morton --- mm/truncate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/mm/truncate.c~mm-truncate-fix-truncation-for-pages-of-arbitrary-size +++ a/mm/truncate.c @@ -168,7 +168,7 @@ void do_invalidatepage(struct page *page * 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 original + * We need to bail out if page->mapping is no longer equal to the original * mapping. This happens a) when the VM reclaimed the page while we waited on * its lock, b) when a concurrent invalidate_mapping_pages got there first 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 = PageTransHuge(page) ? HPAGE_PMD_NR : 1; + unsigned int nr = thp_nr_pages(page); unmap_mapping_pages(mapping, page->index, nr, false); } if (page_has_private(page)) - do_invalidatepage(page, 0, PAGE_SIZE); + do_invalidatepage(page, 0, thp_size(page)); /* * Some filesystems seem to re-dirty the page even after _