On Sat, Dec 19, 2020 at 8:25 AM Amir Goldstein <amir73il@xxxxxxxxx> wrote: > > On Sat, Dec 19, 2020 at 4:31 PM Shakeel Butt <shakeelb@xxxxxxxxxx> wrote: > > > > On Sat, Dec 19, 2020 at 1:48 AM Amir Goldstein <amir73il@xxxxxxxxx> wrote: > > > > > > On Sat, Dec 19, 2020 at 12:11 AM Shakeel Butt <shakeelb@xxxxxxxxxx> wrote: > > > > > > > > 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. > > > > > > Not that I have a problem with this patch, but what problem does it try to > > > solve? > > > > I am aiming for the simplicity to not set another limit which can > > indirectly be limited by memcg limits. I just want to set the memcg > > limit on our production environment which runs multiple workloads on a > > system and not think about setting a sensible value to > > max_user_instances in production. I would prefer to set > > max_user_instances to max int and let the memcg limits of the > > workloads limit their inotify usage. > > > > understood. > and I guess the multiple workloads cannot run each in their own userns? > because then you wouldn't need to change max_user_instances limit. > No workloads can run in their own user namespace but please note that max_user_instances is shared between all the user namespaces. > [snip] > > > Any reason why you did not include fanotify in this patch? > > > > The motivation was inotify's max_user_instances but we can charge > > fsnotify_group for fanotify as well. Though I would prefer that to be > > a separate patch. Let me know what you prefer? > > > > I would prefer to add the helper fsnotify_alloc_user_group() > that will use the GFP_KERNEL_ACCOUNT allocation flags > internally. > > fsnotify_alloc_group() is used by all backends that initialize a single > group instance for internal use and fsnotify_alloc_user_group() will be > used by inotify/fanotify when users create instances. > I see no reason to separate that to two patches. > SGTM.