Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5797314pxu; Thu, 22 Oct 2020 11:15:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH9x2LV9B9OUuRjWE7K9hAZSUp5daViWGGoNr+kPxQpi+Z4kZJ5vWHqgAI0KavUj4ZrE60 X-Received: by 2002:aa7:dcc7:: with SMTP id w7mr3458911edu.80.1603390524645; Thu, 22 Oct 2020 11:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603390524; cv=none; d=google.com; s=arc-20160816; b=BsiZkCm764SMbVCpBkWMdyPx1ajkynXhN+t9SaAONhNQs1r97VP6Baza3+5z3viTg6 +q0ifadV4Dl28rM/LuV1Q2hbaQK/d9Zekknll5rOoe+hppTcPhVBqHdJae0v3zwClSC5 tqfeJct6HOmhiSQlKS83wwF0ZH3oILZg+3kXtne8s+Ni5uR0gm42kAFIgcjtJ21kwkZC orF+2McLnpTM8S1ExsTk7rDDSI/OrDbkucNvOXNwGcEzfNcwAgQHU3vjodouhTLotWpC ZgIfWyYjY+dSc7O8G/GI4sK2HpDp30gsBZAMAE5CoLPi0lcGZD4CRQeNzQjrMJGO7YEn kj+A== 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=HuLFfKCiL+7vaRCur/wWQWK6xvpLJsr5bSM5cuDLJto=; b=o1SkXcGzF5EntJTDF7yICQ6BtmW2TsjvpYSkbsOOFShoKe5OGNrHeUs311dLj1Ew+h C9UO9Pmk9XvuvuVu0CIFtziI3jUGyQ4gyuhlGIITKmzm+Q3KWF9YQsxFy1GLqSfLjTfu emBJHp4sVA8lxiQT3UpR4ptyTU6JTrv8n2aI604OQvGqalwrcdSJjUeReItGsANJLXh1 Qp4GGKUu1UeD01sDcEFOr6GrmMoaDyonbF7I5He09/SxeggJpYqHgSyLL/1PCG3Y5lii TdNFOtlJhYzJGjbJENc1wBUxHCk1G/6TNcdz0pip7aCGjqjzANqSEMsiZLNOG876hjpW tpkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=N1wmpof0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jp12si1408556ejb.194.2020.10.22.11.15.02; Thu, 22 Oct 2020 11:15:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=N1wmpof0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2902449AbgJVRMw (ORCPT + 99 others); Thu, 22 Oct 2020 13:12:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2902445AbgJVRMu (ORCPT ); Thu, 22 Oct 2020 13:12:50 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 582E4C0613CE; Thu, 22 Oct 2020 10:12:50 -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=HuLFfKCiL+7vaRCur/wWQWK6xvpLJsr5bSM5cuDLJto=; b=N1wmpof0oY1B9VcE0NiPkP5PYs Vb+1DJXwCpWZpQxrWFmlc702rqpjKzM0+ch1HuJPkoiVTgLZyMDmf5I7JtHTDzkuSyoeCICE6joMN 9RRuOD1i43hu5o8/xsUlzjF8GKWxUqWuL6/LXkRZCuc5yyz/dYS+OX2+lgtCjD11WPdfaNINad527 P5ztfx35J7IjGogchCHa5nu89JrCvZdw707IJT6qfw8O/bKw0ENmCQcB5Uanbp0C3aNg/0gfoFv3w mCA+ndHQPNmpHNdZtX7y40hCKMmspJYObnpDGgFSvQ+AxDLsFIMLmRPDclj51Nrt+ny8J+yv1L+fo mTciSItw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kVe8p-0005GB-Ip; Thu, 22 Oct 2020 17:12:43 +0000 Date: Thu, 22 Oct 2020 18:12:43 +0100 From: Matthew Wilcox To: Qian Cai Cc: Christoph Hellwig , "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jens Axboe , linux-mm@kvack.org Subject: Re: kernel BUG at mm/page-writeback.c:2241 [ BUG_ON(PageWriteback(page); ] Message-ID: <20201022171243.GX20115@casper.infradead.org> References: <645a3f332f37e09057c10bc32f4f298ce56049bb.camel@lca.pw> <20201022004906.GQ20115@casper.infradead.org> <7ec15e2710db02be81a6c47afc57abed4bf8016c.camel@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7ec15e2710db02be81a6c47afc57abed4bf8016c.camel@lca.pw> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 22, 2020 at 11:35:26AM -0400, Qian Cai wrote: > On Thu, 2020-10-22 at 01:49 +0100, Matthew Wilcox wrote: > > On Wed, Oct 21, 2020 at 08:30:18PM -0400, Qian Cai wrote: > > > Today's linux-next starts to trigger this wondering if anyone has any clue. > > > > I've seen that occasionally too. I changed that BUG_ON to VM_BUG_ON_PAGE > > to try to get a clue about it. Good to know it's not the THP patches > > since they aren't in linux-next. > > > > I don't understand how it can happen. We have the page locked, and then we > > do: > > > > if (PageWriteback(page)) { > > if (wbc->sync_mode != WB_SYNC_NONE) > > wait_on_page_writeback(page); > > else > > goto continue_unlock; > > } > > > > VM_BUG_ON_PAGE(PageWriteback(page), page); > > > > Nobody should be able to put this page under writeback while we have it > > locked ... right? The page can be redirtied by the code that's supposed > > to be writing it back, but I don't see how anyone can make PageWriteback > > true while we're holding the page lock. > > It happened again on today's linux-next: > > [ 7613.579890][T55770] page:00000000a4b35e02 refcount:3 mapcount:0 mapping:00000000457ceb87 index:0x3e pfn:0x1cef4e > [ 7613.590594][T55770] aops:xfs_address_space_operations ino:805d85a dentry name:"doio.f1.55762" > [ 7613.599192][T55770] flags: 0xbfffc0000000bf(locked|waiters|referenced|uptodate|dirty|lru|active) > [ 7613.608596][T55770] raw: 00bfffc0000000bf ffffea0005027d48 ffff88810eaec030 ffff888231f3a6a8 > [ 7613.617101][T55770] raw: 000000000000003e 0000000000000000 00000003ffffffff ffff888143724000 > [ 7613.625590][T55770] page dumped because: VM_BUG_ON_PAGE(PageWriteback(page)) > [ 7613.632695][T55770] page->mem_cgroup:ffff888143724000 Seems like it reproduces for you pretty quickly. I have no luck ;-( Can you add this? +++ b/mm/page-writeback.c @@ -2774,6 +2774,7 @@ int __test_set_page_writeback(struct page *page, bool keep_write) struct address_space *mapping = page_mapping(page); int ret, access_ret; + VM_BUG_ON_PAGE(!PageLocked(page), page); lock_page_memcg(page); if (mapping && mapping_use_writeback_tags(mapping)) { XA_STATE(xas, &mapping->i_pages, page_index(page)); This is the only place (afaict) that sets PageWriteback, so that will tell us whether someone is setting Writeback without holding the lock, or whether we're suffering from a spurious wakeup.