• Waiman Long's avatar
    inotify: Increase default inotify.max_user_watches limit to 1048576 · 92890123
    Waiman Long authored
    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 0eeca283 ("[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.comReviewed-by: default avatarAmir Goldstein <amir73il@gmail.com>
    Signed-off-by: default avatarWaiman Long <longman@redhat.com>
    Signed-off-by: default avatarJan Kara <jack@suse.cz>
    92890123
inotify_user.c 21.4 KB