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 F138CC433F5 for ; Tue, 5 Oct 2021 01:58:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8B532611C0 for ; Tue, 5 Oct 2021 01:58:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8B532611C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C6889900002; Mon, 4 Oct 2021 21:58:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C17B96B0071; Mon, 4 Oct 2021 21:58:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B06FD900002; Mon, 4 Oct 2021 21:58:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id A43586B006C for ; Mon, 4 Oct 2021 21:58:48 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 52DEB1802EAA1 for ; Tue, 5 Oct 2021 01:58:48 +0000 (UTC) X-FDA: 78660725136.22.1DF976E Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by imf18.hostedemail.com (Postfix) with ESMTP id A63914002814 for ; Tue, 5 Oct 2021 01:58:46 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=rongwei.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0UqcME4E_1633399122; Received: from 30.25.244.41(mailfrom:rongwei.wang@linux.alibaba.com fp:SMTPD_---0UqcME4E_1633399122) by smtp.aliyun-inc.com(127.0.0.1); Tue, 05 Oct 2021 09:58:43 +0800 Message-ID: <9bde2c4c-de26-442c-0a1c-799954440c77@linux.alibaba.com> Date: Tue, 5 Oct 2021 09:58:42 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:93.0) Gecko/20100101 Thunderbird/93.0 Subject: Re: [PATCH v2 1/2] mm, thp: check page mapping when truncating page cache Content-Language: en-US To: Matthew Wilcox Cc: Song Liu , Hugh Dickins , Andrew Morton , Linux MM , Linux Kernel Mailing List , William Kucharski References: <68737431-01d2-e6e3-5131-7d7c731e49ae@linux.alibaba.com> <8d8fb192-bd8d-8a08-498d-ca7204d4a716@linux.alibaba.com> From: Rongwei Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A63914002814 X-Stat-Signature: 77qry74gdqfxqq4eh9i3bnicqku3wj5s Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf18.hostedemail.com: domain of rongwei.wang@linux.alibaba.com designates 115.124.30.43 as permitted sender) smtp.mailfrom=rongwei.wang@linux.alibaba.com X-HE-Tag: 1633399126-985988 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 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! >