Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp5335470rdb; Sat, 30 Dec 2023 17:29:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1JuVggiJXsiGu3copCYDhpOJAV042Mq9eZnXzE1r1ZsvD8jU/aFO69zLklgMgHFNhKdYW X-Received: by 2002:a05:6870:d0c3:b0:1fb:1904:bcdf with SMTP id k3-20020a056870d0c300b001fb1904bcdfmr17776981oaa.16.1703986163541; Sat, 30 Dec 2023 17:29:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703986163; cv=none; d=google.com; s=arc-20160816; b=DxGzmkhOtQjCLUN/F2TtNE3hoP1DvEntTYJAbKg1PNsyjwYEc+nSYofQVk/b08FSIC 7L6WcgsyFjEllXWyxXSgg466PDNo8lPxKdxavm+QvvFdqXmPzqNDst6l2jK62J7B7Fj/ HHXlpnPotLtjeI3R2rSD7LtdweGvCsX/8nJ1pjtvdQBFQTFHOvuX3mRm1PVRKdD9wjk8 qStkwdhIAxgBrKJKfgkoukYAwa+0Yfk3pD/TgwEtdxBHwGWhVI0H0LPDAtagZnxuBjU5 IDzPT/JnHE6Q/vsikp7LowqE/4QicSYmdiYMpC40AbY4jBDhNFB6Wdj9sthSpgrLuE/w osQA== 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=1EpB+RIDaU569xr49ozEnq1A7im/xq7I6VKW7+mx0t8=; fh=3cmkbP0fLsoHtbZFr0dk1Dvr+fbFaRkI0FsJCENDUCY=; b=Cr307aRjOWx9nEgab+12SsF5mKOovH6Z3TawT8pjpdZujoYfJtgmgt5pvkzbBGbfFJ uLwEMTIwNOqzLMslRgVLC22qBJ/NHvUQrMXrO282T+GRpgTLBnGSUUHSpH8hNcbLvut1 fIfSIUXWAc+8vNjvEtTwaIt52zqjiDTOzOxspaJ86ahfnQ6BmlQrtqX505410vOTwYkd y+4GAPH1BkF/84m9Tix2tLthLYGYS8wR/29x04IWsI8CS9aPNft8kek0PR7vpBUItpa7 JAJQ9/Qa4gxTYhK7C4KigsMJuwJUICOmd6cMQiooss5jci+QuR42RlGda0dsYC2FHRaR eFdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13620-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z3-20020a656103000000b005cddfe4eb92si16457761pgu.883.2023.12.30.17.29.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Dec 2023 17:29:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13620-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B08B1B21275 for ; Sun, 31 Dec 2023 01:29:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B83CCA53; Sun, 31 Dec 2023 01:29:13 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail78-36.sinamail.sina.com.cn (mail78-36.sinamail.sina.com.cn [219.142.78.36]) (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 600017F7 for ; Sun, 31 Dec 2023 01:29:06 +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.68.80]) by sina.com (172.16.235.25) with ESMTP id 6590C3D700005C47; Sun, 31 Dec 2023 09:28:58 +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: 34086234210350 X-SMAIL-UIID: 17A82AA05F31419BBB3E201479107F12-20231231-092858-1 From: Hillf Danton To: Genes Lists Cc: Matthew Wilcox , 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: Sun, 31 Dec 2023 09:28:46 +0800 Message-Id: <20231231012846.2355-1-hdanton@sina.com> In-Reply-To: <8bb29431064fc1f70a42edef75a8788dd4a0eecc.camel@sapience.com> References: <8bb29431064fc1f70a42edef75a8788dd4a0eecc.camel@sapience.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 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. --- x/mm/page-writeback.c +++ y/mm/page-writeback.c @@ -2661,12 +2661,19 @@ void __folio_mark_dirty(struct folio *fo { unsigned long flags; +again: xa_lock_irqsave(&mapping->i_pages, flags); - if (folio->mapping) { /* Race with truncate? */ + if (folio->mapping && mapping == folio->mapping) { WARN_ON_ONCE(warn && !folio_test_uptodate(folio)); folio_account_dirtied(folio, mapping); __xa_set_mark(&mapping->i_pages, folio_index(folio), PAGECACHE_TAG_DIRTY); + } else if (folio->mapping) { /* Race with truncate? */ + struct address_space *tmp = folio->mapping; + + xa_unlock_irqrestore(&mapping->i_pages, flags); + mapping = tmp; + goto again; } xa_unlock_irqrestore(&mapping->i_pages, flags); } --