Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp5790920rdb; Sun, 31 Dec 2023 17:55:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGD2AugGYf9+bVv3Xh9YJIIWrJv0cN7zKCqNa24Dnu4Oy0TL8WH04utTSoDPaMNmCp+0Ec X-Received: by 2002:ad4:4ea5:0:b0:680:b1b4:30a2 with SMTP id ed5-20020ad44ea5000000b00680b1b430a2mr1928564qvb.128.1704074137811; Sun, 31 Dec 2023 17:55:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704074137; cv=none; d=google.com; s=arc-20160816; b=iad+X35YdzfOOBYPDylKgIjmWZGvc32g1bqHp3xQwemmCZXqiRlybNlueOjLSlrsP1 O9lsi/6hGtTlOYSqy2hB1AtIWi5Ofe/kgcAv7X7BnuQ9S7UFTwXr4kHOXACLvNUFF2yO HBa6aLCUrAg1Ftj1vanggK0sRDkqWU+FhnyBYUlaXBBYPxVBrsli+8W4bgN885mYe4PE 9fbZEY4NesDDSu4LRcYXeQbNmsGsp66SSh4UgE0g39/5EiaTIV/7a1mZsX2dFqH9LV4H rezt97wbRU+T8l7oEmQfQrotdvV5rhGLRDjzBdTUFP09kD0IH2ZmqLNsWROb87MyfwnZ DH+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=I2+jNtGi2lJvwWE37E3mOCVXAt6+YxJ9zI8dQK5wuz4=; fh=9E48kTFwclmSO8TcqRIv6Wby2EsVvfwXPxpyACCtUVg=; b=iPD9FpAzuZYwuyAz+luLMyl7mh3Kf9T2mhjxryE5PgDAUInXTk5E2vDCyNfF4M+RGM epqfV97tIs8qZ7/XKKQ23k87/K8OsVaT41UdPIy8mCfPg5YRyuq4DQEjRaH+qSubaLYe LApNW1iqiIC6UiRfWv57OLF8gN0640ikKTF48KXKy0mPEovU1kXYC9pNTE6lyStwwX1q jbVxmUQ1bdfyckNcelGAyIkRDFhbdx7RguHjHF4oyNBS0kHxhbysKjkwIeoLJPiCo5Rz cfjCtEkqH2pyM5pi/iKkFZ0qyw51shgOD9kzHq20xLbl4M9DcacPA/OFPmIi7fycw7Fj vr8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13812-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13812-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g27-20020a0caadb000000b0067ef267d46fsi22644786qvb.457.2023.12.31.17.55.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 17:55:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13812-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13812-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13812-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 77B101C21D05 for ; Mon, 1 Jan 2024 01:55:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E896881E; Mon, 1 Jan 2024 01:55:30 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail115-95.sinamail.sina.com.cn (mail115-95.sinamail.sina.com.cn [218.30.115.95]) (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 2480B7F9 for ; Mon, 1 Jan 2024 01:55:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.118.70.64]) by sina.com (172.16.235.24) with ESMTP id 65921B8100004871; Mon, 1 Jan 2024 09:55:16 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 15200245089584 X-SMAIL-UIID: 0DEB7DF064144DCD825404CC9C1C793E-20240101-095516-1 From: Hillf Danton To: Matthew Wilcox 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 Date: Mon, 1 Jan 2024 09:55:04 +0800 Message-Id: <20240101015504.2446-1-hdanton@sina.com> In-Reply-To: References: <8bb29431064fc1f70a42edef75a8788dd4a0eecc.camel@sapience.com> <20231231012846.2355-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-Transfer-Encoding: 8bit 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