From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Kirill A. Shutemov" Subject: [PATCHv3, RFC 22/34] thp, mm: truncate support for transparent huge page cache Date: Fri, 5 Apr 2013 14:59:46 +0300 Message-ID: <1365163198-29726-23-git-send-email-kirill.shutemov@linux.intel.com> References: <1365163198-29726-1-git-send-email-kirill.shutemov@linux.intel.com> Cc: Al Viro , Hugh Dickins , Wu Fengguang , Jan Kara , Mel Gorman , linux-mm@kvack.org, Andi Kleen , Matthew Wilcox , "Kirill A. Shutemov" , Hillf Danton , Dave Hansen , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" To: Andrea Arcangeli , Andrew Morton Return-path: In-Reply-To: <1365163198-29726-1-git-send-email-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org From: "Kirill A. Shutemov" If we starting position of truncation is in tail page we have to spilit the huge page page first. We also have to split if end is within the huge page. Otherwise we can truncate whole huge page at once. Signed-off-by: Kirill A. Shutemov --- mm/truncate.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mm/truncate.c b/mm/truncate.c index c75b736..0152feb 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -231,6 +231,17 @@ void truncate_inode_pages_range(struct address_space *mapping, if (index > end) break; + /* split page if we start from tail page */ + if (PageTransTail(page)) + split_huge_page(compound_trans_head(page)); + if (PageTransHuge(page)) { + /* split if end is within huge page */ + if (index == (end & ~HPAGE_CACHE_INDEX_MASK)) + split_huge_page(page); + else + /* skip tail pages */ + i += HPAGE_CACHE_NR - 1; + } if (!trylock_page(page)) continue; WARN_ON(page->index != index); @@ -280,6 +291,8 @@ void truncate_inode_pages_range(struct address_space *mapping, if (index > end) break; + if (PageTransHuge(page)) + split_huge_page(page); lock_page(page); WARN_ON(page->index != index); wait_on_page_writeback(page); -- 1.7.10.4