All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Krzysztof Oledzki <olel@ans.pl>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Nick Piggin <nickpiggin@yahoo.com.au>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Osterried <osterried@jesse.de>,
	protasnb@gmail.com, bugme-daemon@bugzilla.kernel.org
Subject: Re: [Bug 9182] Critical memory leak (dirty pages)
Date: Thu, 20 Dec 2007 15:12:17 +0100	[thread overview]
Message-ID: <20071220141217.GA4745@atjola.homenet> (raw)
In-Reply-To: <alpine.LFD.0.9999.0712190903350.21557@woody.linux-foundation.org>

On 2007.12.19 09:44:50 -0800, Linus Torvalds wrote:
> 
> 
> On Sun, 16 Dec 2007, Krzysztof Oledzki wrote:
> > 
> > I'll confirm this tomorrow but it seems that even switching to data=ordered
> > (AFAIK default o ext3) is indeed enough to cure this problem.
> 
> Ok, do we actually have any ext3 expert following this? I have no idea 
> about what the journalling code does, but I have painful memories of ext3 
> doing really odd buffer-head-based IO and totally bypassing all the normal 
> page dirty logic.
> 
> Judging by the symptoms (sorry for not following this well, it came up 
> while I was mostly away travelling), something probably *does* clear the 
> dirty bit on the pages, but the dirty *accounting* is not done properly, 
> so the kernel keeps thinking it has dirty pages.
> 
> Now, a simple "grep" shows that ext3 does not actually do any 
> ClearPageDirty() or similar on its own, although maybe I missed some other 
> subtle way this can happen. And the *normal* VFS routines that do 
> ClearPageDirty should all be doing the proper accounting.
> 
> So I see a couple of possible cases:
> 
>  - actually clearing the PG_dirty bit somehow, without doing the 
>    accounting.
> 
>    This looks very unlikely. PG_dirty is always cleared by some variant of 
>    "*ClearPageDirty()", and that bit definition isn't used for anything 
>    else in the whole kernel judging by "grep" (the page allocator tests 
>    the bit, that's it).

OK, so I looked for PG_dirty anyway.

In 46d2277c796f9f4937bfa668c40b2e3f43e93dd0 you made try_to_free_buffers
bail out if the page is dirty.

Then in 3e67c0987d7567ad666641164a153dca9a43b11d, Andrew fixed
truncate_complete_page, because it called cancel_dirty_page (and thus
cleared PG_dirty) after try_to_free_buffers was called via
do_invalidatepage.

Now, if I'm not mistaken, we can end up as follows.

truncate_complete_page()
  cancel_dirty_page() // PG_dirty cleared, decr. dirty pages
  do_invalidatepage()
    ext3_invalidatepage()
      journal_invalidatepage()
        journal_unmap_buffer()
          __dispose_buffer()
            __journal_unfile_buffer()
              __journal_temp_unlink_buffer()
                mark_buffer_dirty(); // PG_dirty set, incr. dirty pages

If journal_unmap_buffer then returns 0, try_to_free_buffers is not
called and neither is cancel_dirty_page, so the dirty pages accounting
is not decreased again.

As try_to_free_buffers got its ext3 hack back in
ecdfc9787fe527491baefc22dce8b2dbd5b2908d, maybe
3e67c0987d7567ad666641164a153dca9a43b11d should be reverted? (Except for
the accounting fix in cancel_dirty_page, of course).


On a side note, before 8368e328dfe1c534957051333a87b3210a12743b the task
io accounting for cancelled writes happened always happened if the page
was dirty, regardless of page->mapping. This was also already true for
the old test_clear_page_dirty code, and the commit log for
8368e328dfe1c534957051333a87b3210a12743b doesn't mention that semantic
change either, so maybe the "if (account_size)" block should be moved
out of the if "(mapping && ...)" block?

Björn - not sending patches because he needs sleep and wouldn't have a
        damn clue about what to write as a commit message anyway

  parent reply	other threads:[~2007-12-20 14:24 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20071215221935.306A5108068@picon.linux-foundation.org>
2007-12-15 23:08 ` [Bug 9182] Critical memory leak (dirty pages) Krzysztof Oledzki
2007-12-16  4:35   ` Andrew Morton
2007-12-16  9:33     ` Krzysztof Oledzki
2007-12-16  9:51       ` Andrew Morton
2007-12-16 13:46         ` Krzysztof Oledzki
2007-12-16 21:51           ` Andrew Morton
2007-12-17 14:26             ` Jan Kara
2007-12-17 17:17             ` Krzysztof Oledzki
2007-12-19 17:44           ` Linus Torvalds
2007-12-20  1:05             ` Jan Kara
2007-12-20  1:19               ` Nick Piggin
2007-12-20 14:12             ` Björn Steinbrink [this message]
2007-12-20 15:04               ` Jan Kara
2007-12-20 16:05                 ` Jan Kara
2007-12-20 16:25               ` Linus Torvalds
2007-12-20 17:25                 ` Jan Kara
2007-12-20 19:24                   ` Linus Torvalds
2007-12-21  1:59                     ` Nick Piggin
2007-12-20 22:28                 ` Björn Steinbrink
2007-12-21 19:59                   ` Krzysztof Oledzki
2007-12-21 20:42                     ` [PATCH] Fix dirty page accounting leak with ext3 data=journal Björn Steinbrink
     [not found] <20071216095834.1B899108069@picon.linux-foundation.org>
2007-12-16 10:12 ` [Bug 9182] Critical memory leak (dirty pages) Krzysztof Oledzki
     [not found] <20071205213750.14194108010@picon.linux-foundation.org>
     [not found] ` <Pine.LNX.4.64.0712052238520.21312@bizon.gios.gov.pl>
     [not found]   ` <Pine.LNX.4.64.0712111844510.21312@bizon.gios.gov.pl>
2007-12-12 13:28     ` Krzysztof Oledzki
     [not found] <20071205135655.1A832108010@picon.linux-foundation.org>
2007-12-05 14:09 ` Krzysztof Oledzki
2007-09-28  8:42 Strange system hangs Krzysztof Oledzki
2007-09-28 20:14 ` Nick Piggin
2007-12-02 15:09   ` Krzysztof Oledzki
     [not found]     ` <200712030936.25363.osterried@jesse.de>
2007-12-13 15:17       ` [Bug 9182] Critical memory leak (dirty pages) Krzysztof Oledzki
2007-12-13 15:44         ` Peter Zijlstra
2007-12-13 16:16           ` Krzysztof Oledzki
2007-12-15 12:33             ` Krzysztof Oledzki
2007-12-15 21:53               ` Krzysztof Oledzki

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=20071220141217.GA4745@atjola.homenet \
    --to=b.steinbrink@gmx.de \
    --cc=akpm@linux-foundation.org \
    --cc=bugme-daemon@bugzilla.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=olel@ans.pl \
    --cc=osterried@jesse.de \
    --cc=peterz@infradead.org \
    --cc=protasnb@gmail.com \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.