diff options
author | Daniel Mack <github@zonque.org> | 2015-09-13 20:44:30 +0200 |
---|---|---|
committer | Daniel Mack <github@zonque.org> | 2015-09-13 20:44:30 +0200 |
commit | 5669ef3644e3044036eeaaf6bb4b1a6a7e63130c (patch) | |
tree | 1f2f6f436e6070aeea41960ed91fee8705d2aac3 /src/basic/cgroup-util.h | |
parent | 2d0fd6e1c5bbaddef56ecf0fc8c59478fb9ba822 (diff) | |
parent | e7ab4d1ac9f8d99eecd5e2d22eb482a1fb0fbf23 (diff) |
Merge pull request #1251 from poettering/cgroups-cleanup
cgroups cleanup + other fixes
Diffstat (limited to 'src/basic/cgroup-util.h')
-rw-r--r-- | src/basic/cgroup-util.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h index 7e1b4f9c72..33ca28cab7 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -53,6 +53,30 @@ typedef enum CGroupMask { _CGROUP_MASK_ALL = CGROUP_CONTROLLER_TO_MASK(_CGROUP_CONTROLLER_MAX) - 1 } CGroupMask; +/* Special values for the cpu.shares attribute */ +#define CGROUP_CPU_SHARES_INVALID ((uint64_t) -1) +#define CGROUP_CPU_SHARES_MIN UINT64_C(2) +#define CGROUP_CPU_SHARES_MAX UINT64_C(262144) +#define CGROUP_CPU_SHARES_DEFAULT UINT64_C(1024) + +static inline bool CGROUP_CPU_SHARES_IS_OK(uint64_t x) { + return + x == CGROUP_CPU_SHARES_INVALID || + (x >= CGROUP_CPU_SHARES_MIN && x <= CGROUP_CPU_SHARES_MAX); +} + +/* Special values for the blkio.weight attribute */ +#define CGROUP_BLKIO_WEIGHT_INVALID ((uint64_t) -1) +#define CGROUP_BLKIO_WEIGHT_MIN UINT64_C(10) +#define CGROUP_BLKIO_WEIGHT_MAX UINT64_C(1000) +#define CGROUP_BLKIO_WEIGHT_DEFAULT UINT64_C(500) + +static inline bool CGROUP_BLKIO_WEIGHT_IS_OK(uint64_t x) { + return + x == CGROUP_BLKIO_WEIGHT_INVALID || + (x >= CGROUP_BLKIO_WEIGHT_MIN && x <= CGROUP_BLKIO_WEIGHT_MAX); +} + /* * General rules: * @@ -161,3 +185,6 @@ bool cg_is_legacy_wanted(void); const char* cgroup_controller_to_string(CGroupController c) _const_; CGroupController cgroup_controller_from_string(const char *s) _pure_; + +int cg_cpu_shares_parse(const char *s, uint64_t *ret); +int cg_blkio_weight_parse(const char *s, uint64_t *ret); |