Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp303292rdb; Mon, 18 Sep 2023 16:05:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2qaod8MO+Ap14L6uozCBvUBILfQw0ztnzokbFm5RtNeghGOAA+gYX305JsjA0KMShYvhP X-Received: by 2002:a05:6808:aa8:b0:3a5:cc7d:3d66 with SMTP id r8-20020a0568080aa800b003a5cc7d3d66mr11647383oij.49.1695078318372; Mon, 18 Sep 2023 16:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695078318; cv=none; d=google.com; s=arc-20160816; b=O/XK/qeLQ+5TTraoNuRc3z5WqGlhqHZxJv8lqDU1Uq9M+Qwd3f/sdNVZo+U8MPQkLC Mg09IA95zDM4OV9p79WdTX3xG7AGDE+1Msk4PiS/xa+RzNMmgcQJsSiaNeSz8eMyjZOn uRiHTNzQ/25ql6Qovbm6nM4FICU6oIAUJBnFLvNFmsdctZ87jp+XRAlFC9xTE5niAYwp JcN0tmSPa+BxNyzcPyHnemPCKPmGmRD1+eiWP6LZm1sovSkOArGBzjWdel2IyM6N7+77 7V8Yt0btjgI8PaUBLem7Wmj/XV2I0KHJoj07GkZ3LwwXt4t6PjLB/ijm4hn8n0MmcH+h hUMQ== 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=3W2iG96sXNpt+qL0wzYfxSEXfbU14HH4BwI31ALCsRw=; fh=nB4b3F6n9302qwYDX0abkXwplKViRQCTPkLquCeJDfo=; b=sFM+/UPCMJrj0NERhf/Az03e6sKqYoyQR7IQV8qFs2LaXSQubLdcUzEzHZl/tm47Qf l7foS/K02t4eAbYeLi7WmuRGPRKyvL8oB5a+5aiNVjy2hO/eWbbm6vrWdL3BYrVtmCbO PTbODbiHpP62htrH167kLQP/5knFwooYwmb7F/MkgeXjJjcCcQjIosf4AViTugqcN3MU 7o5JDidYmtERx8nHheyzhqMWKaP+dBqui/jDU+RJUe6BU9pL6ez/OkoQpjLQiLPej5fw Nxr+rmbb0pumrKea6udzqEZ4wg6zCgijNxonqqZNCiwZyW0qJXOeMNYPveMqwNjkP0qT FzdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=kJFx1xc5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id x9-20020a654149000000b005659b757791si8554294pgp.384.2023.09.18.16.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 16:05:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=kJFx1xc5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 7536A828D07A; Mon, 18 Sep 2023 08:39:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229449AbjIRPjZ (ORCPT + 99 others); Mon, 18 Sep 2023 11:39:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229490AbjIRPjY (ORCPT ); Mon, 18 Sep 2023 11:39:24 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B205BBA for ; Mon, 18 Sep 2023 08:35:43 -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=3W2iG96sXNpt+qL0wzYfxSEXfbU14HH4BwI31ALCsRw=; b=kJFx1xc5KRX1gV3ixQPahDa8xR NtVwdG/6RbvBONC1WcD4awRPsWs2+LNGyk1IggDwHPiMU7RRQaenz9+vX0oEHENWHINZp+v7dbwkh Z6GsbkePAG+7zVqxxZWEVc601prwTO+DOWJA1fEHoqOW7tBjnqAddom0oo4qQXI4LHELhLgb10t7R +YSuEXa5eRNBt8AQL+DNBMM9l3/M763b87c8vmx+RS+wowL5EB3+pcF1Q0oYDHOYnQ967Yn9brtkU Efh68kGF86lUYZJrdC+3gKnX0/1WbRwdNxrs9ndowe3ynz1/a+9TCfsE5/xpNxdiL6t/H9VySTLSF ghTWBO/Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qiFdE-00Bd02-Dp; Mon, 18 Sep 2023 14:53:48 +0000 Date: Mon, 18 Sep 2023 15:53:48 +0100 From: Matthew Wilcox To: Mirsad Todorovac Cc: linux-kernel@vger.kernel.org, Andrew Morton , linux-mm@kvack.org, Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org Subject: Re: BUG: KCSAN: data-race in folio_batch_move_lru / mpage_read_end_io Message-ID: References: <22a42774-ebe1-081a-c9b9-e11f4d74bc3a@alu.unizg.hr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <22a42774-ebe1-081a-c9b9-e11f4d74bc3a@alu.unizg.hr> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:39:32 -0700 (PDT) On Mon, Sep 18, 2023 at 02:15:05PM +0200, Mirsad Todorovac wrote: > > This is what I'm currently running with, and it doesn't trigger. > > I'd expect it to if we were going to hit the KCSAN bug. > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 0c5be12f9336..d22e8798c326 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -4439,6 +4439,7 @@ struct page *__alloc_pages(gfp_t gfp, unsigned int order, int preferred_nid, > > page = __alloc_pages_slowpath(alloc_gfp, order, &ac); > > out: > > + VM_BUG_ON_PAGE(page && (page->flags & (PAGE_FLAGS_CHECK_AT_PREP &~ (1 << PG_head))), page); > > if (memcg_kmem_online() && (gfp & __GFP_ACCOUNT) && page && > > unlikely(__memcg_kmem_charge_page(page, gfp, order) != 0)) { > > __free_pages(page, order); > > Hi, > > Caught another instance of this bug involving folio_batch_move_lru: I don't seem that I can make it > happen reliably by the nature of the data racing conditions if I understood them well. Were you running with this patch at the time, or was this actually vanilla? The problem is that, if my diagnosis is correct, both of the tasks mentioned are victims; we have a prematurely freed page. While btrfs is clearly a user, it may not be btrfs's fault that the page was also allocated as an anon page. I'm trying to gather more data, and running with this patch will give us more -- because it'll dump the entire struct page instead of just the page->flags, like KCSAN is currently doing.