}
}
-static struct cgroup_ops *cgroup_ops;
+struct cgroup_ops *cgroup_ops;
static int cgroup_mount_ns_fd = -1;
return rv;
}
-/*
- * Determine whether CPU views should be used or not.
- */
-bool use_cpuview(const char *cg)
-{
- int cfd;
-
- cfd = find_mounted_controller("cpu");
- if (cfd < 0)
- return false;
-
- cfd = find_mounted_controller("cpuacct");
- if (cfd < 0)
- return false;
-
- return true;
-}
-
/*
* check whether this is a '^processor" line in /proc/cpuinfo
*/
if (!cpuset)
goto err;
- use_view = use_cpuview(cg);
-
+ use_view = cgroup_ops->can_use_cpuview(cgroup_ops);
if (use_view)
max_cpus = max_cpu_count(cg);
goto err;
}
- if (use_cpuview(cg) && cg_cpu_usage) {
+ if (cgroup_ops->can_use_cpuview(cgroup_ops) && cg_cpu_usage) {
total_len = cpuview_proc_stat(cg, cpuset, cg_cpu_usage, cg_cpu_usage_size,
f, d->buf, d->buflen);
goto out;
struct file_info *d);
extern void prune_init_slice(char *cg);
extern char *get_cpuset(const char *cg);
-extern bool use_cpuview(const char *cg);
extern int max_cpu_count(const char *cg);
extern void do_release_file_info(struct fuse_file_info *fi);
extern int cpu_number_in_cpuset(const char *cpuset);
return cgfsng_get_io(ops, cgroup, "blkio.io_wait_time_recursive", value);
}
+static bool cgfsng_can_use_cpuview(struct cgroup_ops *ops)
+{
+ struct hierarchy *cpu, *cpuacct;
+
+ if (pure_unified_layout(ops))
+ return false;
+
+ cpu = ops->get_hierarchy(ops, "cpu");
+ if (!cpu || is_unified_hierarchy(cpu))
+ return false;
+
+ cpuacct = ops->get_hierarchy(ops, "cpuacct");
+ if (!cpuacct || is_unified_hierarchy(cpuacct))
+ return false;
+
+ return true;
+}
+
/* At startup, parse_hierarchies finds all the info we need about cgroup
* mountpoints and current cgroups, and stores it in @d.
*/
/* cpuset */
cgfsng_ops->get_cpuset_cpus = cgfsng_get_cpuset_cpus;
+ cgfsng_ops->can_use_cpuview = cgfsng_can_use_cpuview;
/* blkio */
cgfsng_ops->get_io_service_bytes = cgfsng_get_io_service_bytes;
/* cpuset */
int (*get_cpuset_cpus)(struct cgroup_ops *ops, const char *cgroup,
char **value);
+ bool (*can_use_cpuview)(struct cgroup_ops *ops);
/* io */
int (*get_io_service_bytes)(struct cgroup_ops *ops, const char *cgroup,
char **value);
};
+extern struct cgroup_ops *cgroup_ops;
+
extern struct cgroup_ops *cgroup_init(void);
extern void cgroup_exit(struct cgroup_ops *ops);
#include <sys/vfs.h>
#include "bindings.h"
-#include "config.h" // for VERSION
+#include "cgroups/cgroup.h"
+#include "config.h"
#include "sysfs_fuse.h"
static int sys_devices_system_cpu_online_read(char *buf, size_t size,
if (!cpuset)
goto err;
- use_view = use_cpuview(cg);
-
+ use_view = cgroup_ops->can_use_cpuview(cgroup_ops);
if (use_view)
max_cpus = max_cpu_count(cg);