linux/fs/notify
Waiman Long 9289012374 inotify: Increase default inotify.max_user_watches limit to 1048576
The default value of inotify.max_user_watches sysctl parameter was set
to 8192 since the introduction of the inotify feature in 2005 by
commit 0eeca28300 ("[PATCH] inotify"). Today this value is just too
small for many modern usage. As a result, users have to explicitly set
it to a larger value to make it work.

After some searching around the web, these are the
inotify.max_user_watches values used by some projects:
 - vscode:  524288
 - dropbox support: 100000
 - users on stackexchange: 12228
 - lsyncd user: 2000000
 - code42 support: 1048576
 - monodevelop: 16384
 - tectonic: 524288
 - openshift origin: 65536

Each watch point adds an inotify_inode_mark structure to an inode to
be watched. It also pins the watched inode.

Modeled after the epoll.max_user_watches behavior to adjust the default
value according to the amount of addressable memory available, make
inotify.max_user_watches behave in a similar way to make it use no more
than 1% of addressable memory within the range [8192, 1048576].

We estimate the amount of memory used by inotify mark to size of
inotify_inode_mark plus two times the size of struct inode (we double
the inode size to cover the additional filesystem private inode part).
That means that a 64-bit system with 128GB or more memory will likely
have the maximum value of 1048576 for inotify.max_user_watches. This
default should be big enough for most use cases.

Link: https://lore.kernel.org/r/20201109035931.4740-1-longman@redhat.com
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2020-11-09 15:03:21 +01:00
..
dnotify fsnotify: create method handle_inode_event() in fsnotify_operations 2020-07-27 23:25:50 +02:00
fanotify mm, memcg: rework remote charging API to support nesting 2020-10-18 09:27:09 -07:00
inotify inotify: Increase default inotify.max_user_watches limit to 1048576 2020-11-09 15:03:21 +01:00
fdinfo.c fsnotify: Remove proc_fs.h include 2020-05-13 17:16:14 +02:00
fdinfo.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fsnotify.c fanotify: fix logic of reporting name info with watched parent 2020-11-09 15:03:08 +01:00
fsnotify.h fsnotify: move declaration of fsnotify_mark_connector_cachep to fsnotify.h 2019-10-17 10:31:12 +02:00
group.c fsnotify: add mutex destroy 2020-05-13 17:14:20 +02:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mark.c fsnotify: Add missing annotation for fsnotify_finish_user_wait() and for fsnotify_prepare_user_wait() 2020-04-15 11:44:43 +02:00
notification.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 18 2019-05-21 11:28:46 +02:00