Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp5906936rdb; Mon, 1 Jan 2024 01:08:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfyBlboYBiK81UQBVavmuUCgIXuLum5gFdczMZAR8XKlTN54H/RU/g9Ap2b7wIYWSVE1N3 X-Received: by 2002:a50:d7d3:0:b0:553:db85:a508 with SMTP id m19-20020a50d7d3000000b00553db85a508mr6540505edj.84.1704100094873; Mon, 01 Jan 2024 01:08:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704100094; cv=none; d=google.com; s=arc-20160816; b=RGZ39UEM1WtWsgpQRpcXPKNtp1VgmA3oNeOyQV+kDlU5AGqCYYEyIQc1xCby98o+yT 5WefaZH9Vz6geqwSY2cGPrjAb3gkyBAD3rDe3gqx73PsbzbHZNAv7rnmTlUy7H+v7VPX j4dz50UfXsfdHx5H94+ryZVTc62O9HsXwxT3mTea1yPOFLFxHhMKYnPRRilIW7AAg3Zr JZlm6miZxtUOiN2b/VoXNARFVvELTVFg8GwjIU4wluFyVMrLemzjgB5Ua2adoVgMooKO dT7r97cxdklL6nvY/rsVU5nDdYzfX8Wr8mDWY4RbkuOSUrMIbXJLqfMpy3qdT3GtWGJe HIXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=HXbZ0sxnDZzhlQp2F6Mpy+dhtbcwpBUtIlShgaOKyHE=; fh=VYfFV0qGCSDtIM3nhKzqXzUIkJ3M8zyjNIkvX0xjs4s=; b=HzDKJpd462Ztcc1hWCS8lgfPHnKuKDju6HzCgrIjeblZ2fpQUXaho5lFwikBZ4sD6a hDTT+YX8lgMnmAbF2TIkdA+EUD1azv1Mnjw9rEKxMSRzrABjcpqIz/rHMnEdmsBvT3Zw 5dm3GfkA9eeYW0bWEtdA/3hghcjevK1LARjzSWx+Bg1npmu8aiCvnUwUqAuq9dKcQUbQ Nw6opQZJZEmgj+pd1ZO1W/xBUSE30bwvUVg52GnIAUpz4gAsa4jbyN7rxmW2KrhyPkXY YEHUyGZ2OmHlU2XeJZfgT2LT4gR2UyIuTYFNzuSIR4iRtSTg9oifhabnkgly3LCxla2f 6iRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=dMJHNqsl; spf=pass (google.com: domain of linux-kernel+bounces-13843-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13843-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a31-20020a509ea2000000b0054cfd045e4esi10141028edf.363.2024.01.01.01.08.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 01:08:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13843-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=dMJHNqsl; spf=pass (google.com: domain of linux-kernel+bounces-13843-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13843-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9D1BB1F21F14 for ; Mon, 1 Jan 2024 09:08:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A00D4435; Mon, 1 Jan 2024 09:08:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="dMJHNqsl" X-Original-To: linux-kernel@vger.kernel.org Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB1C63C28; Mon, 1 Jan 2024 09:08:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org 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=HXbZ0sxnDZzhlQp2F6Mpy+dhtbcwpBUtIlShgaOKyHE=; b=dMJHNqslObVykUwGUh7oBNKQbJ dTBwsbSKgXSx6mgGrtVy6fS1Jco+6rzyqoL+TPl6tLvXlsVt7wXfSoU4rxIX1oge7YiPtoIVMSXHS u2gOa4ImoDONf8qjT/QhbvlRU4Ukk5+Ew/8JYvxPKmQXwqpBOvtf+gW6FYn9QLCb6ZZhpIrameylM 88CAOLshXbNvBW3YAfHvodHqEjGcj/mB1SEHryW6SAEEmpzB9+kp7YDFuwzSJI6oV5raGMuUZ5oVi PP320X5QmfO4tdl4ARdwoFKAkTiU1x3J/aHPsOkIXs5PRfigvqowcGodoKDQUrkPDj3+E0o6pWSeE 6OyWF2mA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rKEH2-008Rnu-77; Mon, 01 Jan 2024 09:07:52 +0000 Date: Mon, 1 Jan 2024 09:07:52 +0000 From: Matthew Wilcox To: Hillf Danton Cc: Genes Lists , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: 6.6.8 stable: crash in folio_mark_dirty Message-ID: References: <8bb29431064fc1f70a42edef75a8788dd4a0eecc.camel@sapience.com> <20231231012846.2355-1-hdanton@sina.com> <20240101015504.2446-1-hdanton@sina.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240101015504.2446-1-hdanton@sina.com> On Mon, Jan 01, 2024 at 09:55:04AM +0800, Hillf Danton wrote: > On Sun, 31 Dec 2023 13:07:03 +0000 Matthew Wilcox > > On Sun, Dec 31, 2023 at 09:28:46AM +0800, Hillf Danton wrote: > > > On Sat, Dec 30, 2023 at 10:23:26AM -0500 Genes Lists > > > > Apologies in advance, but I cannot git bisect this since machine was > > > > running for 10 days on 6.6.8 before this happened. > > > > > > > > Dec 30 07:00:36 s6 kernel: ------------[ cut here ]------------ > > > > Dec 30 07:00:36 s6 kernel: WARNING: CPU: 0 PID: 521524 at mm/page-writeback.c:2668 __folio_mark_dirty (??:?) > > > > Dec 30 07:00:36 s6 kernel: CPU: 0 PID: 521524 Comm: rsync Not tainted 6.6.8-stable-1 #13 d238f5ab6a206cdb0cc5cd72f8688230f23d58df > > > > Dec 30 07:00:36 s6 kernel: block_dirty_folio (??:?) > > > > Dec 30 07:00:36 s6 kernel: unmap_page_range (??:?) > > > > Dec 30 07:00:36 s6 kernel: unmap_vmas (??:?) > > > > Dec 30 07:00:36 s6 kernel: exit_mmap (??:?) > > > > Dec 30 07:00:36 s6 kernel: __mmput (??:?) > > > > Dec 30 07:00:36 s6 kernel: do_exit (??:?) > > > > Dec 30 07:00:36 s6 kernel: do_group_exit (??:?) > > > > Dec 30 07:00:36 s6 kernel: __x64_sys_exit_group (??:?) > > > > Dec 30 07:00:36 s6 kernel: do_syscall_64 (??:?) > > > > > > See what comes out if race is handled. > > > Only for thoughts. > > > > I don't think this can happen. Look at the call trace; > > block_dirty_folio() is called from unmap_page_range(). That means the > > page is in the page tables. We unmap the pages in a folio from the > > page tables before we set folio->mapping to NULL. Look at > > invalidate_inode_pages2_range() for example: > > > > unmap_mapping_pages(mapping, indices[i], > > (1 + end - indices[i]), false); > > folio_lock(folio); > > folio_wait_writeback(folio); > > if (folio_mapped(folio)) > > unmap_mapping_folio(folio); > > BUG_ON(folio_mapped(folio)); > > if (!invalidate_complete_folio2(mapping, folio)) > > > What is missed here is the same check [1] in invalidate_inode_pages2_range(), > so I built no wheel. > > folio_lock(folio); > if (unlikely(folio->mapping != mapping)) { > folio_unlock(folio); > continue; > } > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/truncate.c#n658 That's entirely different. That's checking in the truncate path whether somebody else already truncated this page. What I was showing was why a page found through a page table walk cannot have been truncated (which is actually quite interesting, because it's the page table lock that prevents the race).