Re: [PATCH v2 1/2] mm, thp: check page mapping when truncating page cache

From: Rongwei Wang
Date: Mon Oct 04 2021 - 21:58:50 EST




On 10/5/21 3:05 AM, Matthew Wilcox wrote:
On Tue, Oct 05, 2021 at 01:26:50AM +0800, Rongwei Wang wrote:
Hi,
I have run our cases these two days to stress test new Patch #1. The new
Patch #1 mainly add filemap_invalidate_{un}lock before and after
truncate_pagecache(), basing on original Patch #1. And the crash has not
happened.

You shouldn't need most of patch 1.

In fact, the only two patches you should need would be this:

+++ b/mm/filemap.c
@@ -2093,7 +2093,6 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t start,
if (!xa_is_value(page)) {
if (page->index < start)
goto put;
- VM_BUG_ON_PAGE(page->index != xas.xa_index, page);
if (page->index + thp_nr_pages(page) - 1 > end)
goto put;
if (!trylock_page(page))

(already in Andrew's tree) and:

- if (filemap_nr_thps(inode->i_mapping))
+ if (filemap_nr_thps(inode->i_mapping)) {
+ filemap_invalidate_lock(inode->i_mapping);
truncate_pagecache(inode, 0);
+ filemap_invalidate_unlock(inode->i_mapping);
+ }

If you can still hit a bug with just those two patches, then something
else is going wrong, and needs to be investigated.
OK, I see what your mean. I will send Patch v3 and only keep filemap_invalidate_{un}lock in Patch #1.

Thanks!