linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: William Kucharski <william.kucharski@oracle.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Qian Cai <cai@lca.pw>, Christoph Hellwig <hch@infradead.org>,
	"Darrick J. Wong" <darrick.wong@oracle.com>,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	linux-mm@kvack.org
Subject: Re: kernel BUG at mm/page-writeback.c:2241 [ BUG_ON(PageWriteback(page); ]
Date: Thu, 22 Oct 2020 07:23:33 -0600	[thread overview]
Message-ID: <361D9B8E-CE8F-4BA0-8076-8384C2B7E860@oracle.com> (raw)
In-Reply-To: <20201022004906.GQ20115@casper.infradead.org>



> On Oct 21, 2020, at 6:49 PM, Matthew Wilcox <willy@infradead.org> 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.

Looking at __test_set_page_writeback(), I see that it (and most other
callers to lock_page_memcg()) do the following:

  lock_page_memcg(page)

  /* do other stuff */

  ret = TestSetPageWriteback(page);

  /* do more stuff */

  unlock_page_memcg(page)

yet lock_page_memcg() does have a few cases where it can (silently)
return NULL to indicate an error.

Only test_clear_page_writeback() actually saves off the return value
(but it too never bothers to check whether it is NULL or not.)

Could it be one of those error conditions is occurring leading to no
lock actually being taken?

The conditions would be extremely rare, but it feels wrong not to check
somewhere:

	  struct page *head = compound_head(page); /* rmap on tail pages */

[ ... ]

          if (mem_cgroup_disabled())
              return NULL;
  again:
          memcg = head->mem_cgroup;
          if (unlikely(!memcg))
                  return NULL;











  reply	other threads:[~2020-10-22 13:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22  0:30 kernel BUG at mm/page-writeback.c:2241 [ BUG_ON(PageWriteback(page); ] Qian Cai
2020-10-22  0:49 ` Matthew Wilcox
2020-10-22 13:23   ` William Kucharski [this message]
2020-10-22 16:46     ` Matthew Wilcox
2020-10-22 15:35   ` Qian Cai
2020-10-22 17:12     ` Matthew Wilcox
2020-10-30 12:08       ` Qian Cai
2020-10-26  9:49   ` Jan Kara
2020-10-26 13:13     ` Matthew Wilcox
2020-10-26 13:55       ` Jens Axboe
2020-10-26 14:26         ` Qian Cai
2020-11-04 15:16           ` Jan Kara
2020-11-04 15:40             ` Qian Cai
2020-10-26 14:51         ` Qian Cai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=361D9B8E-CE8F-4BA0-8076-8384C2B7E860@oracle.com \
    --to=william.kucharski@oracle.com \
    --cc=axboe@kernel.dk \
    --cc=cai@lca.pw \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).