Sateesh, I wonder if you ever saw the Cgroup class that was developed by ldoktor. Currently it is on a test module
https://github.com/autotest/autotest-client-tests/blob/master/cgroup/cgroup_common.py https://github.com/autotest/autotest-client-tests/blob/master/cgroup/cgroup_client.py But we could move them into the client (or shared) library. Lukas' implementation takes care of of a good deal of what you want to do with cgroups. Please let me know what you think, Lucas On Thu, Oct 11, 2012 at 6:47 AM, <[email protected]> wrote: > From: Satheesh Rajendran <[email protected]> > > This function would provide a support for resolving a cgroup path for a > specific controller and a given task id. > > > > Signed-off-by: Satheesh Rajendran <[email protected]> > --- > client/base_utils.py | 36 ++++++++++++++++++++++++++++++++++++ > 1 files changed, 36 insertions(+), 0 deletions(-) > > diff --git a/client/base_utils.py b/client/base_utils.py > index 5e45efd..8485142 100644 > --- a/client/base_utils.py > +++ b/client/base_utils.py > @@ -825,3 +825,39 @@ def suspend_to_disk(): > Suspend the system to disk (S4) > """ > set_power_state('disk') > + > + > +def resolve_task_cgroup_path(pid, controller): > + """ > + Resolving cgroup mount path of a particular task > + > + @params: pid : process id of a task for which the cgroup path required > + @params: controller: takes one of the controller names in controller list > + > + @return: resolved path for cgroup controllers of a given pid > + """ > + > + # Initialise cgroup controller list > + controller_list = [ 'cpuacct', 'cpu', 'memory', 'cpuset', > + 'devices', 'freezer', 'blkio', 'netcls' ] > + > + if controller not in controller_list: > + raise error.TestError("Doesn't support controller <%s>" % controller) > + > + root_path = get_cgroup_mountpoint(controller) > + > + proc_cgroup = "/proc/%d/cgroup" % pid > + if not os.path.isfile(proc_cgroup): > + raise NameError('File %s does not exist\n Check whether cgroup \ > + installed in the system' % proc_cgroup) > + > + f = open(proc_cgroup, 'r') > + proc_cgroup_txt = f.read() > + f.close > + > + mount_path = re.findall(r":%s:(\S*)\n" % controller, proc_cgroup_txt) > + logging.info(mount_path[0]) > + > + path = root_path + mount_path[0] > + logging.info(path) > + return path > -- > 1.7.1 > > _______________________________________________ > Autotest-kernel mailing list > [email protected] > https://www.redhat.com/mailman/listinfo/autotest-kernel -- Lucas _______________________________________________ Autotest-kernel mailing list [email protected] https://www.redhat.com/mailman/listinfo/autotest-kernel
