[Devel] [PATCH rh7] fairsched: fix output of /proc/fairsched[2]

Vladimir Davydov vdavydov at parallels.com
Thu May 28 09:41:34 PDT 2015


It must never show UUID-named containers there, but currently it will if
UUID, and therefore cpu cgroup name, starts with a digit. This is due to
the way sscanf called by legacy_veid_to_name, which is used for
converting cpu cgroup names to fairsched ids, works.

Fix this by using kstrtoul for parsing farisched ids from cgroup name.

https://jira.sw.ru/browse/PSBM-33806

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 kernel/fairsched.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/kernel/fairsched.c b/kernel/fairsched.c
index 412afed6c77d..3879f8e6b5c9 100644
--- a/kernel/fairsched.c
+++ b/kernel/fairsched.c
@@ -32,6 +32,16 @@ static struct fairsched_node root_node = {NULL, NULL};
 
 #define fairsched_id(id) (id == FAIRSCHED_HOST_NODE ? 0 : id)
 
+static int fairsched_id_parse(const char *s)
+{
+	unsigned long id;
+
+	if (kstrtoul(s, 10, &id))
+		return -1;
+
+	return id ?: FAIRSCHED_HOST_NODE;
+}
+
 static int fairsched_open(struct fairsched_node *node, int id)
 {
 	envid_t veid = fairsched_id(id);
@@ -467,7 +477,8 @@ static struct fairsched_dump *fairsched_do_dump(int compat)
 		if (d_unhashed(dentry) || !dentry->d_inode ||
 				!S_ISDIR(dentry->d_inode->i_mode))
 			continue;
-		if (legacy_name_to_veid(dentry->d_name.name, &id) < 0)
+		id = fairsched_id_parse(dentry->d_name.name);
+		if (id < 0)
 			continue;
 		if (!ve_is_super(ve) &&
 		    strcmp(ve_name(ve), dentry->d_name.name))
-- 
2.1.4




More information about the Devel mailing list