Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1766717pxb; Fri, 1 Oct 2021 19:37:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+RmnrN8H6/j4epRneTRR244fCSb8yeTGX6xCk+qnFLjmDg1mzvpkIv471lu4P7FrtrrdL X-Received: by 2002:a50:9b06:: with SMTP id o6mr1338897edi.284.1633142252585; Fri, 01 Oct 2021 19:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633142252; cv=none; d=google.com; s=arc-20160816; b=LO8YXWv+cklbanhxD3vMzVMmr1se3BS2XhOTgqlEgNb5RFyXnsg+0uMUrapvnJEwQn 4EEeCPT4x3CJDwYd7S/OPG6eXT/84l8u8FJiSMOrHfNd68wzdcsDQNlUT1I8j1mANmuL eAJTNe6CHivTeDWPILOXGvEadrvI18ynJ+8C4pMd5k3wcaaPyj1zvNi7Va1LT5BasjqP X8Df0okNmtA4utnbOHlkOTKDDP+pGsRNrC6HLDOYzcMGWFHbUZtlPJQ8YpJyry3ldZ+4 SCyLe+n2866E8w3dOrNT62rNbsYrJdP2Sh0SSLBMeTFhQdy/8g8v8SJxxjlgT/RFsqtQ AKow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=Kes5AXBP1j2FcmPCg5RrHVifsIobIcslPHMdAVIsenk=; b=kMY48SkZIFJMQmkxY+4O2lUvWtNY5mycx0gjhFMf2o24vBDJMReR0Asz1zWy86oezH 8TKz0ZSOHhXty8eJhT2Z0dVfdpxPniAt7kaxQo8qOtyATDYi4e5eOj6OJx6eBGwpMWMG YU9cGUQre3yyU3A0UYI6jJ3NmRnOBHy/jgQ5vtAUJksSragWeYRPwfqE2w9R07pmLdWs qi447C2Aq2UyqQFt/+YoSbfDfPUL47z6KfhVBjOyxefec48i/I8VNX5lq8nVXedN8QxD GIonioL2WFn88Db1WYw7rA/PRJfRaftgIpSLSiLWBQU7MxbnWfpQ5SsoFC4HJkzinHGz XrqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si9317866edc.320.2021.10.01.19.37.07; Fri, 01 Oct 2021 19:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232387AbhJBCYN (ORCPT + 99 others); Fri, 1 Oct 2021 22:24:13 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:50765 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232278AbhJBCYM (ORCPT ); Fri, 1 Oct 2021 22:24:12 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >