From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Jeff Layton <jlayton@poochiereds.net>
Cc: Eryu Guan <guaneryu@gmail.com>,
linux-fsdevel@vger.kernel.org, jack@suse.com,
akpm@linux-foundation.org, torvalds@linux-foundation.org
Subject: Re: [BUG] inotify_add_watch/inotify_rm_watch loops trigger oom
Date: Sun, 14 Feb 2016 17:02:38 -0800 [thread overview]
Message-ID: <20160215010238.GT6719@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160214093931.40da9afa@tlielax.poochiereds.net>
On Sun, Feb 14, 2016 at 09:39:31AM -0500, Jeff Layton wrote:
> On Sun, 14 Feb 2016 16:35:43 +0800
> Eryu Guan <guaneryu@gmail.com> wrote:
>
> > Hi,
> >
> > Starting from v4.5-rc1 running inotify_add_watch/inotify_rm_watch in
> > loop could trigger OOM and system becomes unusuable. v4.4 kernel is fine
> > with the same stress test.
> >
> > Reverting c510eff6beba ("fsnotify: destroy marks with call_srcu instead
> > of dedicated thread") on top of v4.5-rc3 passed the same test, seems
> > that this patch introduced some kind of memleak?
> >
> > On v4.5-rc[1-3] the test program triggers oom within 10 minutes on my
> > test vm with 8G mem. After reverting the commit in question the same vm
> > survived more than 1 hour stress test.
> >
> > ./inotify <mnt>
> >
> > I attached the test program and oom console log. If more information is
> > needed please let me know.
> >
> > Thanks,
> > Eryu
>
> Thanks Eryu, I think I see what the problem is. This reproducer is
> creating and deleting marks very rapidly. But the SRCU code has this:
>
> #define SRCU_CALLBACK_BATCH 10
> #define SRCU_INTERVAL 1
>
> So, process_srcu will only process 10 entries at a time, and only once
> per jiffy. The upshot there is that that reproducer can create entries
> _much_ faster than they can be cleaned up now that we're using
> call_srcu in this codepath. If you kill the program before the OOM
> killer kicks in, they all eventually get cleaned up but it does take a
> while (minutes).
>
> I clearly didn't educate myself enough as to the limitations of
> call_srcu before converting this code over to use it (and I missed
> Paul's subtle hints in that regard). We may need to revert that patch
> before v4.5 ships, but I'd like to ponder it for a few days to and see
> whether there is some way to batch them up so that they get reaped more
> efficiently without requiring the dedicated thread.
One thought would be to add an "emergency mode" to SRCU similar to that
already in RCU. Something to the effect that if the current list of
callbacks is going to take more than a second to drain at the configured
per-jiffy rate, just process them without waiting.
Would that help in this case, or am I missing something about the
reproducer?
Thanx, Paul
next prev parent reply other threads:[~2016-02-15 1:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-14 8:35 [BUG] inotify_add_watch/inotify_rm_watch loops trigger oom Eryu Guan
2016-02-14 14:39 ` Jeff Layton
2016-02-15 1:02 ` Paul E. McKenney [this message]
2016-02-15 1:24 ` Jeff Layton
2016-02-15 2:33 ` Linus Torvalds
2016-02-15 6:01 ` Paul E. McKenney
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=20160215010238.GT6719@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=guaneryu@gmail.com \
--cc=jack@suse.com \
--cc=jlayton@poochiereds.net \
--cc=linux-fsdevel@vger.kernel.org \
--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 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).