diff mbox series

[09/11] mm/truncate: Fix truncation for pages of arbitrary size

Message ID 20200908195539.25896-10-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Remove assumptions of THP size | expand

Commit Message

Matthew Wilcox Sept. 8, 2020, 7:55 p.m. UTC
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) <willy@infradead.org>
---
 mm/truncate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Kirill A . Shutemov Sept. 9, 2020, 2:50 p.m. UTC | #1
On Tue, Sep 08, 2020 at 08:55:36PM +0100, Matthew Wilcox (Oracle) wrote:
> 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) <willy@infradead.org>

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
SeongJae Park Sept. 15, 2020, 7:36 a.m. UTC | #2
On Tue,  8 Sep 2020 20:55:36 +0100 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote:

> 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) <willy@infradead.org>

Reviewed-by: SeongJae Park <sjpark@amazon.de>


Thanks,
SeongJae Park
diff mbox series

Patch

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 int 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 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