Le 23/07/2010 13:32, Michael Raymond a écrit : > I think you forgot to attach the patch. >
Sorry, here's the patch :) Brice
diff --git a/src/topology-linux.c b/src/topology-linux.c index 6f4c99f..43f3fd3 100644 --- a/src/topology-linux.c +++ b/src/topology-linux.c @@ -918,7 +918,7 @@ hwloc_strdup_mntpath(const char *escapedpath, size_t length) static void hwloc_find_linux_cpuset_mntpnt(char **cgroup_mntpnt, char **cpuset_mntpnt, int fsroot_fd) { -#define PROC_MOUNT_LINE_LEN 128 +#define PROC_MOUNT_LINE_LEN 512 char line[PROC_MOUNT_LINE_LEN]; FILE *fd; @@ -938,6 +938,14 @@ hwloc_find_linux_cpuset_mntpnt(char **cgroup_mntpnt, char **cpuset_mntpnt, int f char *type; char *tmp; + /* remove the ending " 0 0\n" that the kernel always adds */ + tmp = strchr(line, '\0'); + tmp -= 5; + if (strcmp(tmp, " 0 0\n")) + fprintf(stderr, "Unexpected end of /proc/mounts line `%s'\n", tmp); + else + *tmp = '\0'; + /* path is after first field and a space */ tmp = strchr(line, ' '); if (!tmp) @@ -958,9 +966,12 @@ hwloc_find_linux_cpuset_mntpnt(char **cgroup_mntpnt, char **cpuset_mntpnt, int f hwloc_debug("Found cpuset mount point on %s\n", path); *cpuset_mntpnt = hwloc_strdup_mntpath(path, type-path); break; + } else if (!strncmp(type, "cgroup ", 7)) { /* found a cgroup mntpnt */ char *opt, *opts; + int cpuset_opt = 0; + int noprefix_opt = 0; /* find options */ tmp = strchr(type, ' '); @@ -968,14 +979,23 @@ hwloc_find_linux_cpuset_mntpnt(char **cgroup_mntpnt, char **cpuset_mntpnt, int f continue; opts = tmp+1; - /* find "cpuset" option */ - while ((opt = strsep(&opts, ",")) && strcmp(opt, "cpuset")) - ; /* continue */ - if (!opt) + /* look at options */ + while ((opt = strsep(&opts, ",")) != NULL) { + if (!strcmp(opt, "cpuset")) + cpuset_opt = 1; + else if (!strcmp(opt, "noprefix")) + noprefix_opt = 1; + } + if (!cpuset_opt) continue; - hwloc_debug("Found cgroup/cpuset mount point on %s\n", path); - *cgroup_mntpnt = hwloc_strdup_mntpath(path, type-path); + if (noprefix_opt) { + hwloc_debug("Found cgroup emulating a cpuset mount point on %s\n", path); + *cpuset_mntpnt = hwloc_strdup_mntpath(path, type-path); + } else { + hwloc_debug("Found cgroup/cpuset mount point on %s\n", path); + *cgroup_mntpnt = hwloc_strdup_mntpath(path, type-path); + } break; } }