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 EB15AC433EF for ; Sat, 2 Oct 2021 02:22:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6A7496115C for ; Sat, 2 Oct 2021 02:22:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6A7496115C 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 C8ECB6B006C; Fri, 1 Oct 2021 22:22:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C3B0A6B0071; Fri, 1 Oct 2021 22:22:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADBDD6B0072; Fri, 1 Oct 2021 22:22:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id 9DB756B006C for ; Fri, 1 Oct 2021 22:22:30 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6120C2D3BE for ; Sat, 2 Oct 2021 02:22:30 +0000 (UTC) X-FDA: 78649898460.22.7708740 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf02.hostedemail.com (Postfix) with ESMTP id A5FB77002CA2 for ; Sat, 2 Oct 2021 02:22:28 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R381e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04407;MF=rongwei.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0UqFeYLV_1633141344; Received: from 192.168.31.179(mailfrom:rongwei.wang@linux.alibaba.com fp:SMTPD_---0UqFeYLV_1633141344) by smtp.aliyun-inc.com(127.0.0.1); Sat, 02 Oct 2021 10:22:25 +0800 Message-ID: <635ae57e-454e-0ef9-784d-3736b3bf44ac@linux.alibaba.com> Date: Sat, 2 Oct 2021 10:22:23 +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: Hugh Dickins , Matthew Wilcox Cc: Song Liu , Andrew Morton , Linux MM , Linux Kernel Mailing List , William Kucharski References: <68737431-01d2-e6e3-5131-7d7c731e49ae@linux.alibaba.com> <67906bf5-4de9-8433-3d70-cc8fc5cc2347@linux.alibaba.com> <3d264ed9-f8fd-60d4-7125-f9f745ebeb52@google.com> From: Rongwei Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A5FB77002CA2 X-Stat-Signature: ftjc597mrp9ofrazghpt6eqttcb5rmtw Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf02.hostedemail.com: domain of rongwei.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=rongwei.wang@linux.alibaba.com X-HE-Tag: 1633141348-716969 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/1/21 12:49 AM, Hugh Dickins wrote: > On Thu, 30 Sep 2021, Matthew Wilcox wrote: >> On Wed, Sep 29, 2021 at 10:24:44PM -0700, Hugh Dickins wrote: >>> >>> Aside from the above page->index mischeck in find_lock_entries(), >>> I now think this bug needs nothing more than simply removing the >>> VM_BUG_ON_PAGE(PageTail(page), page) from truncate_inode_page(). >> >> I don't think that's right. This bug was also observed when calling >> truncate(), so there's clearly a situation where two concurrent calls >> to truncate_pagecache() leaves a THP in the cache. > > I assume you're thinking of one of the fuzzer blkdev ones: > https://lore.kernel.org/linux-mm/CACkBjsbtF_peC7N_4mRfHML_BeiPe+O9DahTfr84puSG_J9rcQ@mail.gmail.com/ > or > https://lore.kernel.org/lkml/CACkBjsYwLYLRmX8GpsDpMthagWOjWWrNxqY6ZLNQVr6yx+f5vA@mail.gmail.com/ > > I haven't started on those ones yet: yes, I imagine one or both of those > will need a further fix (S_ISREG() check somewhere if we're lucky; but > could well be nastier); but for the bug in this thread, I expect > removing the VM_BUG_ON_PAGE(PageTail) to be enough. Thanks for your advices! I'm so sorry that delay the test due to my recent vacation. I plan to start further test tomorrow. I think removing the VM_BUG_ON_PAGE(PageTail) is a good idea, but also think using filemap_invalidate_lock is safer and necessary. And of course, this is just my own view! So, now, I tend to use filemap_invalidate_lock and either check page mapping again or remove VM_BUG_ON_PAGE(PageTail). Anyway, I will run more tests and then give feedback. Thanks! > > If you're thinking of something else, please send a link if you can - thanks. > > Hugh >