On 09/04/2012 04:19 AM, Prem Karat wrote:
The set of functions implemented here will return the cgroup controller
mount points from /etc/cgconfig.conf file which will help in building
the path for various cgroup stat files
Signed-off-by: Prem Karat<[email protected]>
---
client/base_utils.py | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
diff --git a/client/base_utils.py b/client/base_utils.py
index 3e435fa..0a69488 100644
--- a/client/base_utils.py
+++ b/client/base_utils.py
@@ -755,6 +755,102 @@ def process_is_alive(name_pattern):
ignore_status=True) == 0
From codes POV, one function should be enough to do the same thing then
caller just
need to know a interface, in addition, the cgroup's configuration may be
different for
different OS platform, so it should looks like this:
def get_cgroup_mntpt(controller, cgconf="/etc/cgconfig.conf"):
controller_list = [ 'cpuacct', 'cpu', 'memory', 'cpuset', \
'devies', 'freezer', 'blkio', 'netcls' ]
f_cgcon = open("%s" %cgconf, "rU")
cgconf_txt = f_cgcon.read()
f_cgcon.close()
if controller not in controller_list:
raise error.TestError("Doesn't support controller <%s>" %
controller)
else:
mntpt = re.findall(r"(?<!#)%s\s*=\s*(.*);" %controller, cgconf_txt)
return mntpt[0]
Regards,
Alex
+def get_cgroup_cpuacct_mntpt():
+ """
+ Get cgroup cpuacct controller mount point from /etc/cgconfig.conf file
+ This would help in building the path of domain specific
+ cpuacct.usage_percpu and other domain specific cgroup stat files
+ """
+ f_cgcon = open("/etc/cgconfig.conf", "rU")
+ cgconf_txt = f_cgcon.read()
+ f_cgcon.close()
+ cpuact_mntpt = re.findall(r"(?<!#)cpuacct\s*=\s*(.*);", cgconf_txt)
+ return cpuact_mntpt[0]
+
+
+def get_cgroup_cpu_mntpt():
+ """
+ Get cgroup cpu controller mount point from /etc/cgconfig.conf file
+ This would help in building the path of domain specific cpu stat files.
+ """
+ f_cgcon = open("/etc/cgconfig.conf", "rU")
+ cgconf_txt = f_cgcon.read()
+ f_cgcon.close()
+ cpu_mntpt = re.findall(r"(?<!#)cpu\s*=\s*(.*);", cgconf_txt)
+ return cpu_mntpt[0]
+
+
+def get_cgroup_memory_mntpt():
+ """
+ Get cgroup memory controller mount point from /etc/cgconfig.conf file
+ This would help in building the path of domain specific mem files
+ """
+ f_cgcon = open("/etc/cgconfig.conf", "rU")
+ cgconf_txt = f_cgcon.read()
+ f_cgcon.close()
+ mem_mntpt = re.findall(r"(?<!#)memory\s*=\s*(.*);", cgconf_txt)
+ return mem_mntpt[0]
+
+
+def get_cgroup_cpuset_mntpt():
+ """
+ Get cgroup cpuset controller mount point from /etc/cgconfig.conf file
+ This would help in building the path of domain specific cpuset files.
+ """
+ f_cgcon = open("/etc/cgconfig.conf", "rU")
+ cgconf_txt = f_cgcon.read()
+ f_cgcon.close()
+ cpuset_mntpt = re.findall(r"(?<!#)cpuset\s*=\s*(.*);", cgconf_txt)
+ return cpuset_mntpt[0]
+
+
+def get_cgroup_devices_mntpt():
+ """
+ Get cgroup device controller mount point from /etc/cgconfig.conf file
+ This would help in building the path of domain specific dev files.
+ """
+ f_cgcon = open("/etc/cgconfig.conf", "rU")
+ cgconf_txt = f_cgcon.read()
+ f_cgcon.close()
+ devices_mntpt = re.findall(r"(?<!#)devices\s*=\s*(.*);", cgconf_txt)
+ return devices_mntpt[0]
+
+
+def get_cgroup_freezer_mntpt():
+ """
+ Get cgroup freezer controller mount point from /etc/cgconfig.conf file
+ This would help in building the path of domain specific freezer stats.
+ """
+ f_cgcon = open("/etc/cgconfig.conf", "rU")
+ cgconf_txt = f_cgcon.read()
+ f_cgcon.close()
+ freezer_mntpt = re.findall(r"(?<!#)freezer\s*=\s*(.*);", cgconf_txt)
+ return freezer_mntpt[0]
+
+
+def get_cgroup_blkio_mntpt():
+ """
+ Get cgroup blkio controller mount point from /etc/cgconfig.conf file
+ This would help in building the path of domain specfc blkio stat files
+ """
+ f_cgcon = open("/etc/cgconfig.conf", "rU")
+ cgconf_txt = f_cgcon.read()
+ f_cgcon.close()
+ blkio_mntpt = re.findall(r"(?<!#)blkio\s*=\s*(.*);", cgconf_txt)
+ return blkio_mntpt[0]
+
+
+def get_cgroup_netcls_mntpt():
+ """
+ Get cgroup net_cls controller mount point from /etc/cgconfig.conf file
+ """
+ f_cgcon = open("/etc/cgconfig.conf", "rU")
+ cgconf_txt = f_cgcon.read()
+ f_cgcon.close()
+ netcls_mntpt = re.findall(r"(?<!#)net_cls\s*=\s*(.*);", cgconf_txt)
+ return netcls_mntpt[0]
+
+
def get_hwclock_seconds(utc=True):
"""
Return the hardware clock in seconds as a floating point value.
_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel