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 4F2DFC433F5 for ; Wed, 29 Sep 2021 23:42:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F91061269 for ; Wed, 29 Sep 2021 23:42:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347313AbhI2Xnq (ORCPT ); Wed, 29 Sep 2021 19:43:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:53866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347524AbhI2Xnn (ORCPT ); Wed, 29 Sep 2021 19:43:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C1C676126A for ; Wed, 29 Sep 2021 23:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632958921; bh=otV9VV/sFcF022eYj5odI220EtLVp8iNHKDlnTKMYts=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MABys8Z/Y8aBZd0ydLplveETTesiDBeKHDu/pTycjplmN3OTjdf5osT6dFwgfjE9w 1WD/AJIsr+eO9oidOxUCby37TKrvZxRNssqyfuOBMe24rwl/4H9mjfe5MwX+0iwn8h h8nGjt8UTvIJbeDF+Dqx0o1+Pi51ejS5s2BPEghw9h2J+SvQy2/Lm755RIkCNBcWmk Q2rZroP9Rxrlp82/jswReK/kTomgAifBS4xkfyStPAwcPTnGwVdl6+8Hs6W5k/YrAZ cWveMGgB50sEnWsZTOygQnAdXcmEna94kFfRFPzkoY/9R620kbQgxEOGllODea3sgD qCX68asy4QjXw== Received: by mail-lf1-f47.google.com with SMTP id y26so17556058lfa.11 for ; Wed, 29 Sep 2021 16:42:01 -0700 (PDT) X-Gm-Message-State: AOAM5318sK3n6YHiP/Y/w0PDfa0T19pR3ZqkQ/elEpMcj/F1LH9NJQnN BGSIgYd3Wuf7eA6jhC3iNCi3qCgUSCr+Hpm8cEI= X-Google-Smtp-Source: ABdhPJxHqAjSpOeee9Gqzi1rY9sY5DM00t+Nr1XmoZToxp1W8xpUS2LPcFfuGRc/ndeFpb0W/nBQOoEpcB3X7s5V7cE= X-Received: by 2002:a2e:5442:: with SMTP id y2mr2794204ljd.436.1632958920169; Wed, 29 Sep 2021 16:42:00 -0700 (PDT) MIME-Version: 1.0 References: <20210922070645.47345-2-rongwei.wang@linux.alibaba.com> <20210923194343.ca0f29e1c4d361170343a6f2@linux-foundation.org> <9e41661d-9919-d556-8c49-610dae157553@linux.alibaba.com> <68737431-01d2-e6e3-5131-7d7c731e49ae@linux.alibaba.com> In-Reply-To: From: Song Liu Date: Wed, 29 Sep 2021 16:41:48 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] mm, thp: check page mapping when truncating page cache To: Matthew Wilcox Cc: Rongwei Wang , Andrew Morton , Linux MM , Linux Kernel Mailing List , William Kucharski , Hugh Dickins Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 29, 2021 at 10:56 AM Matthew Wilcox wrote: > [...] > > Now, I am able to crash the system on > > find_lock_entries () { > > ... > > VM_BUG_ON_PAGE(page->index != xas.xa_index, page); > > } > > I guess it is related. I will test more. > > That's a bogus VM_BUG_ON. I have a patch in my tree to delete it. > Andrew has it too, but for some reason, he hasn't sent it on to Linus. > > +++ 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)) Yes, after removing this line, I am able to see the same bug. Here is my finding so far: 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. Thanks, Song