linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] inotify_add_watch/inotify_rm_watch loops trigger oom
@ 2016-02-14  8:35 Eryu Guan
  2016-02-14 14:39 ` Jeff Layton
  0 siblings, 1 reply; 6+ messages in thread
From: Eryu Guan @ 2016-02-14  8:35 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: jlayton, jack

[-- Attachment #1: Type: text/plain, Size: 680 bytes --]

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

[-- Attachment #2: inotify.c --]
[-- Type: text/plain, Size: 505 bytes --]

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/inotify.h>

int main(int argc, char *argv[])
{
	int notify_fd;
	int wd, ret;

	notify_fd = inotify_init();

	for (;;) {
		wd = inotify_add_watch(notify_fd, argv[1], IN_MODIFY | IN_CREATE | IN_DELETE );
		if (wd < 0) {
			perror("inotify_add_watch");
		}
		ret = inotify_rm_watch(notify_fd, wd);
		if (ret < 0) {
			perror("inotify_rm_watch");
		}
	}
out:
	close(notify_fd);

	return 0;
}

[-- Attachment #3: inotify-oom.log.bz2 --]
[-- Type: application/x-bzip2, Size: 7155 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-02-15  6:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2016-02-15  1:24     ` Jeff Layton
2016-02-15  2:33     ` Linus Torvalds
2016-02-15  6:01       ` Paul E. McKenney

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).