]> git.ipfire.org Git - thirdparty/linux.git/commit
inotify, memcg: account inotify instances to kmemcg
authorShakeel Butt <shakeelb@google.com>
Sun, 20 Dec 2020 04:46:08 +0000 (20:46 -0800)
committerJan Kara <jack@suse.cz>
Tue, 5 Jan 2021 13:42:54 +0000 (14:42 +0100)
commitac7b79fd190b02e7151bc7d2b9da692f537657f3
treec0f539a0633e9cc0d88adb905dd37894dad6dfff
parent36bbbd0e234d817938bdc52121a0f5473b3e58f5
inotify, memcg: account inotify instances to kmemcg

Currently the fs sysctl inotify/max_user_instances is used to limit the
number of inotify instances on the system. For systems running multiple
workloads, the per-user namespace sysctl max_inotify_instances can be
used to further partition inotify instances. However there is no easy
way to set a sensible system level max limit on inotify instances and
further partition it between the workloads. It is much easier to charge
the underlying resource (i.e. memory) behind the inotify instances to
the memcg of the workload and let their memory limits limit the number
of inotify instances they can create.

With inotify instances charged to memcg, the admin can simply set
max_user_instances to INT_MAX and let the memcg limits of the jobs limit
their inotify instances.

Link: https://lore.kernel.org/r/20201220044608.1258123-1-shakeelb@google.com
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/notify/fanotify/fanotify_user.c
fs/notify/group.c
fs/notify/inotify/inotify_user.c
include/linux/fsnotify_backend.h