Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1092072pxb; Wed, 29 Sep 2021 17:04:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPCpGEhTuFsA/wSJ+2YXJWS8rm/39wacRpFaP3vOVAhdf0p9HA8lxjibrM6eI8EKiIjTYw X-Received: by 2002:a50:cf87:: with SMTP id h7mr3530875edk.152.1632960278479; Wed, 29 Sep 2021 17:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632960278; cv=none; d=google.com; s=arc-20160816; b=cdynwYcrZVKPD/H4HwUbP1cv370MngWzt7gRbVQnqVQZ9WjXYwT1IMcb996R+92XCB im0Hz4czVGja/hTJMr2vFeFMrxyvqUWhpcN9mM+aKwBjdrzp3HWx9N0rB3EDFnfVesdG fh63HIp2Z+s7QASrVm7O1r3H1HA6Da6BMbFxFeuZDukv5Qly2ewTpeNw+Emzvh7H8u2M Du8N3hzbBelWWPabkCbBaoS3MK4aGFwyTMlcVXc9O7SuTNlzPmOafljbWPCdIRhXWFV/ aHaHNrcsNnNxYNO6BQWEpIaYYc4SweBbmpw7slrsCBDqd7lAfqyzEZMwWyKBhkZlzCzZ FPCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=LUe9FBliUJ3BKJ3m1te6chyTRqbLF0DsjZyJjSdPEN4=; b=BydYR1rf6w1FFUabP/5xYI9+bBj0fTRNnXm0s8IzmWJoK3IRQJ7wbIm0vuIQTvxGy3 f8Vh7CqVYmXH0VKebZ2jFFto+dL2rUSAr3vGMxjQLtYwPYk4Rzc8Kkv45M20GnI0A6b0 njv8QSWbE7TZyWxd717jZwpMIiwegrN2nwQ3FI+Pm0CUYlD/B6vlmc4qKVWsg3QFSoJS nkDwuehg6S4Q1vWG9U1ggL0tOpyAvlipkt7RrBuhb/R+6Ansr76RTGYuh+XynPT9vsNS Gt1/dIYtEsmri7NCDZkgXKZFBOo8IAi5lGIpumT+NDlO5q9Lkj/brwVHg7wBbm+lwyuL 1IJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="MABys8Z/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b27si1535696ejd.608.2021.09.29.17.04.02; Wed, 29 Sep 2021 17:04:38 -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=@kernel.org header.s=k20201202 header.b="MABys8Z/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347614AbhI2Xnn (ORCPT + 99 others); Wed, 29 Sep 2021 19:43:43 -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-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