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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6AB5C433EF for ; Mon, 4 Oct 2021 19:06:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3767C61108 for ; Mon, 4 Oct 2021 19:06:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3767C61108 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9FA37940069; Mon, 4 Oct 2021 15:06:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A9B594000B; Mon, 4 Oct 2021 15:06:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89A2B940069; Mon, 4 Oct 2021 15:06:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0113.hostedemail.com [216.40.44.113]) by kanga.kvack.org (Postfix) with ESMTP id 7A27294000B for ; Mon, 4 Oct 2021 15:06:37 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3A61027740 for ; Mon, 4 Oct 2021 19:06:37 +0000 (UTC) X-FDA: 78659686434.11.27430E2 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id C46EBF0017CA for ; Mon, 4 Oct 2021 19:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=7zYvaCcq57Js9HjY/9WIt0IYEIm/CuFzck0eVZIai9g=; b=vyk2lzF+2IZ/khyEnmhSkvPS8E VyUjFIxDfsc0bA6aExl92KlG4k5UD1AcK6KPGMjadqdtLDM3pf4ofruHu5qW0Is4kgOb8kfv+yY/3 ZPQkg+HHdKFPxLcUF2WH0oKOLxK9/EG2AJbvBSMwC34Kn4CnucZtXKTUjy/mkqsUQm0CvicuvlcFa yL/oWXGOuNiJ1o9fNWzVLRErw7emIqwqDACX2xsp6Tc8bnAqElrZ2vqFZmrE4w4184QujRnofHMxO KZ9jhxS6EF46riwLNtFOFqxUAvfOPtvQTaMgfhdpUKmSJQaZhvc7Djco/xhBTyCa3as+fP7RLle7c XwRlbf1w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXTGx-00HDiE-U4; Mon, 04 Oct 2021 19:05:35 +0000 Date: Mon, 4 Oct 2021 20:05:11 +0100 From: Matthew Wilcox To: Rongwei Wang Cc: Song Liu , Hugh Dickins , Andrew Morton , Linux MM , Linux Kernel Mailing List , William Kucharski Subject: Re: [PATCH v2 1/2] mm, thp: check page mapping when truncating page cache Message-ID: References: <68737431-01d2-e6e3-5131-7d7c731e49ae@linux.alibaba.com> <8d8fb192-bd8d-8a08-498d-ca7204d4a716@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8d8fb192-bd8d-8a08-498d-ca7204d4a716@linux.alibaba.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C46EBF0017CA X-Stat-Signature: shr7cgrq1doshtknx1t4rox1b6hcpzyx Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=vyk2lzF+; dmarc=none; spf=none (imf16.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1633374396-300556 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: 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.