Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp5521171rdb; Sun, 31 Dec 2023 05:07:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpMgHA4fUCdFmE3wwxM+YHRaBir24emJYzbRki1SI0xEJxLxaoqBh2/C/glFjvxHfrfkcT X-Received: by 2002:a05:6122:1d0f:b0:4b7:43e6:29fa with SMTP id gc15-20020a0561221d0f00b004b743e629famr6235536vkb.8.1704028052622; Sun, 31 Dec 2023 05:07:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704028052; cv=none; d=google.com; s=arc-20160816; b=CxEFp2L02ibGLs0Na2z2AwNOoPLBFceS39Xv/yAxGJUz4eAShEQNcWWVbSI+ZLTJTT VWMlI3Fn+lWbVx9ooVzqXKKx1qZp35TuqshnLJ8fE4AafSGe3gE+4gmVcxKGIHh3BOvV 5TdXh+UftrwEuNDx3nqxP0XkN9HrSw8KCGig3DkSIOh2E8Lfngx2SOQWPUnQE3eVxmaF xGvLfmPQHHmccrGu1FcFbLW0Z1ly5WSoAMi+uSxCueNbqTdeXDvMFveJZVc+qbwx68n1 o3Yxfr39j5LCnZP9ZWrxqCu/Bkx5MURYovCNZ2Uus4MjdhColdb6u/FKr/rS/rXsCWc9 exEw== 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=Qgrieap/ole6x6jYsISD/ePi3BdA5BVA5GTXQ+NppF8=; fh=VYfFV0qGCSDtIM3nhKzqXzUIkJ3M8zyjNIkvX0xjs4s=; b=QCEcRgIrC3QmoB70VsgweSSS4s9R9qZZw092VgF7da6YbsojaRDYKzhVxRdQND7Np1 mQgUNUEVPPRTHo/1dOXaCiAXxFHG605+5qAu9Rm8F7hbihkXLK+aP+B89Ejuxq7i/8JR JcLVwjuKMm+GRatPzwxCC1M4uDIv7MDgjjIsdRWM1x9SaI/s3yIa9pcsgQbGytbFCpuM Ix7MuCvuHoo0ZcteX59j1z2iWN+BXqRWBpYb9p8I+KQ60PSVK7IP5jt4CTPaWrW5r6Ot uZ/tvXIfzO5Meeritd9Sn772dgqgQMv9Gis5AxACcRt/kKVSUcjrdQqlZMEwXwm9Huwt ZyAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=vd+WJ1ej; spf=pass (google.com: domain of linux-kernel+bounces-13706-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13706-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 k4-20020a1fd304000000b004b2cdb9be6dsi3286087vkg.163.2023.12.31.05.07.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 05:07:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13706-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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=vd+WJ1ej; spf=pass (google.com: domain of linux-kernel+bounces-13706-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13706-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 5C8E71C212F5 for ; Sun, 31 Dec 2023 13:07:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEB5C8F6A; Sun, 31 Dec 2023 13:07:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="vd+WJ1ej" 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 7EEF58F49; Sun, 31 Dec 2023 13:07:18 +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=Qgrieap/ole6x6jYsISD/ePi3BdA5BVA5GTXQ+NppF8=; b=vd+WJ1ejSpDkbMALMRIQ/s2vTl LL0gwyRqKsqKp8i+9VpptdcjB4juRO5y6b8zARSBmABKf8PGUAMle9KVhdTXYTf0Am/saSQXw04uU 6FKKnvptyzbh+H/34h9ASMoZ9/1umfKgtOX/JXOJOScchowUFOR0tRuRao5DVTKh2Fy1AWQvpuz5K 3FLRaIY25URYIf9cbU4DrsqLzrDYRc5T1JT9HKZFAzOhsA47apLLIhtJhj6zxqZc0i634KOliIqYg cdmqun3zNvB981cxyf71clmsF97kLsiBoyDdV+29moFlm6vtwuPtkcM185TGn/GRbXFMIK00u+C9F ed/sgQcw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rJvWx-007p83-SY; Sun, 31 Dec 2023 13:07:03 +0000 Date: Sun, 31 Dec 2023 13:07:03 +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> 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: <20231231012846.2355-1-hdanton@sina.com> 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)) ... and invalidate_complete_folio2() is where we set ->mapping to NULL in __filemap_remove_folio -> page_cache_delete().