Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1093701pxb; Wed, 29 Sep 2021 17:06:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaI/rq7Qu6Zdu9f2sN6Vti8qQsggkMA7BbhW/5pZxtaSMWuh50suK9DwU0WXvSXl5oCKgb X-Received: by 2002:a17:90b:1496:: with SMTP id js22mr2915421pjb.57.1632960410602; Wed, 29 Sep 2021 17:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632960410; cv=none; d=google.com; s=arc-20160816; b=M9rJYjcqyCLZdESqORs6NCaAKIdBh6Gy66hOMakCNAPz+Idzz15nrgQW+8ZXJp4g/Y tUzL90A6mhgCOkRtx/Ll97NOR22XOB6L7oxVFIUYVqEDl5qmCvkrI6PIC26YRppWMAku bs78Um2Fgi0yXvgR6iB1/lpII48WSNL6i2LEpUzrLdKbYueJqAV9xrEU8x4jB/hlnfi/ 6UkMbM24v+1rl1pF5DQhMvusCTGYSlZC/g8GyvwzDRbj/tpy/bPpsoYVpCONGqBs0AkV D+C1iVN2eFL3TwXqctqHy2KnbcI32YTXQGID0u7M8RCPJbRlAvEOUSn1LA7dnQMAev9u RGeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gzbQERF6x+EIArRP2/cV+6lI/UWsckEqZ6f0LRsHXHE=; b=Iv5bga9W2KLyWTUJId6UrG1p1bpk47cgMKExMEzanSRMhH0YMadnw0fiTZBrq88lNT 9l6LKUXGDgmze1avYvgn0TfB3uljgl0+dQjRhC1q+90RDjD/LWQyppagOMy90NxQVKPu 2/9TEKF7/7EZtlhuoLZp4Up/J43hAwl8AYiNDBki2BNI7a5iUyVKxqGzjUNz2QN8WZ0q SSUz924PflctkVArD+WmPZV5azJn8QAGBelXK+L6t20M2P4HCFOySdM0bnEhCKCOFfzD d9cE1elKFeJPBJZbSKif0pIyCrM+oEHhVOTFfvC6PZ4ndt7/QIBies/rh1grEUPxSR/Z o0cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Ey0f+HiK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 188si1562209pga.6.2021.09.29.17.06.31; Wed, 29 Sep 2021 17:06:50 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Ey0f+HiK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344976AbhI3AFP (ORCPT + 99 others); Wed, 29 Sep 2021 20:05:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231238AbhI3AFO (ORCPT ); Wed, 29 Sep 2021 20:05:14 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18B00C06161C for ; Wed, 29 Sep 2021 17:03:33 -0700 (PDT) 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=gzbQERF6x+EIArRP2/cV+6lI/UWsckEqZ6f0LRsHXHE=; b=Ey0f+HiKfvoPWo/hz+noSNujur 6gQgigq8p2t2KAHbZv1BxL0OSABG9G3Ktig6espCV3/GHaJYX9PLlythflNNGjNLRUC0CaVyfjBBa upFVYit1P3V6n35QOVJsXviB3CHJSPB402F3EEXwjgNYJTn+Qei0lT0pMo/5ll+ub141nSpThBFg8 1TJr2e8SnFD3DbfK3B/pBi0WXOSZDqXMPfwIGfsh7cxDedXgXThhixbTQQeTUSV+63r7HQSNXZkk8 T6nAGyd21JAIunBmt5LEYo0LzpQoTXGJdyXUgaTp1K+bu7bGQOuXT4ApbNKksvrrL1fNHHltzwmU8 9DYjtniw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVjVB-00CM5V-Bf; Thu, 30 Sep 2021 00:01:11 +0000 Date: Thu, 30 Sep 2021 01:00:41 +0100 From: Matthew Wilcox To: Song Liu Cc: Rongwei Wang , Andrew Morton , Linux MM , Linux Kernel Mailing List , William Kucharski , Hugh Dickins Subject: Re: [PATCH v2 1/2] mm, thp: check page mapping when truncating page cache Message-ID: References: <20210923194343.ca0f29e1c4d361170343a6f2@linux-foundation.org> <9e41661d-9919-d556-8c49-610dae157553@linux.alibaba.com> <68737431-01d2-e6e3-5131-7d7c731e49ae@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 29, 2021 at 04:41:48PM -0700, Song Liu wrote: > The issue is NOT caused by concurrent khugepaged:collapse_file() and > truncate_pagecache(inode, 0). With some printks, we can see a clear > time gap (>2 second ) between collapse_file() finishes, and > truncate_pagecache() (which crashes soon). Therefore, my earlier > suggestion that adds deny_write_access() to collapse_file() does NOT > work. > > The crash is actually caused by concurrent truncate_pagecache(inode, 0). > If I change the number of write thread in stress_madvise_dso.c to one, > (IOW, one thread_read and one thread_write), I cannot reproduce the > crash anymore. > > I think this means we cannot fix this issue in collapse_file(), because it > finishes long before the crash. Ah! So are we missing one or more of these locks: inode_lock(inode); filemap_invalidate_lock(mapping); in the open path?