From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li Zefan Subject: Re: [PATCH 3/3] cgroup: implement cgroup.subtree_populated for the default hierarchy Date: Wed, 16 Apr 2014 12:16:52 +0800 Message-ID: <534E0434.2090403@huawei.com> References: <1397511846-2904-1-git-send-email-tj@kernel.org> <1397511846-2904-4-git-send-email-tj@kernel.org> <534DEF62.4090900@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Kay Sievers Cc: rlove-L7G0xEPcOZbYtjvyW6yDsg@public.gmane.org, Greg Kroah-Hartman , containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org, LKML , Lennart Poettering , eparis-FjpueFixGhCM4zKIHC2jIg@public.gmane.org, Tejun Heo , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, john-jueV0HHMeujJJrXXpGQQMAC/G2K4zDHf@public.gmane.org List-Id: containers.vger.kernel.org On 2014/4/16 11:33, Kay Sievers wrote: > On Tue, Apr 15, 2014 at 7:48 PM, Li Zefan wrote: >> On 2014/4/15 5:44, Tejun Heo wrote: >>> cgroup users often need a way to determine when a cgroup's >>> subhierarchy becomes empty so that it can be cleaned up. cgroup >>> currently provides release_agent for it; unfortunately, this mechanism >>> is riddled with issues. >>> >>> * It delivers events by forking and execing a userland binary >>> specified as the release_agent. This is a long deprecated method of >>> notification delivery. It's extremely heavy, slow and cumbersome to >>> integrate with larger infrastructure. >>> >>> * There is single monitoring point at the root. There's no way to >>> delegate management of subtree. >>> >>> * The event isn't recursive. It triggers when a cgroup doesn't have >>> any tasks or child cgroups. Events for internal nodes trigger only >>> after all children are removed. This again makes it impossible to >>> delegate management of subtree. >>> >>> * Events are filtered from the kernel side. "notify_on_release" file >>> is used to subscribe to or suppress release event. This is >>> unnecessarily complicated and probably done this way because event >>> delivery itself was expensive. >>> >>> This patch implements interface file "cgroup.subtree_populated" which >>> can be used to monitor whether the cgroup's subhierarchy has tasks in >>> it or not. Its value is 0 if there is no task in the cgroup and its >>> descendants; otherwise, 1, and kernfs_notify() notificaiton is >>> triggers when the value changes, which can be monitored through poll >>> and [di]notify. >>> >> >> For the old notification mechanism, the path of the cgroup that becomes >> empty will be passed to the user specified release agent. Like this: >> >> # cat /sbin/cpuset_release_agent >> #!/bin/sh >> rmdir /dev/cpuset/$1 >> >> How do we achieve this using inotify? >> >> - monitor all the cgroups, or >> - monitor all the leaf cgroups, and travel cgrp->parent to delete all >> empty cgroups. >> - monitor root cgroup only, and travel the whole hierarchy to find >> empy cgroups when it gets an fs event. >> >> Seems none of them is scalible. > > The manager would add all cgroups as watches to one inotify file > descriptor, it should not be problem to do that. > Never use inotify. Thanks for explanation, so I think inotify can scale to thounsands of cgroups after I googled a bit.