From: Mike Yuan Date: Tue, 27 May 2025 15:06:36 +0000 (+0200) Subject: cgroup-util: move CGROUP_CPU_SHARES/BLKIO* to nspawn-oci X-Git-Tag: v258-rc1~468^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9e73d37512a4343c98c2bf535fb1fadd00f5c1e4;p=thirdparty%2Fsystemd.git cgroup-util: move CGROUP_CPU_SHARES/BLKIO* to nspawn-oci These are only used for translation from OCI metadata to cgroup v2 values. --- diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h index 7c5e6e65559..e4cb1598438 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -107,19 +107,7 @@ extern const uint64_t cgroup_io_limit_defaults[_CGROUP_IO_LIMIT_TYPE_MAX]; const char* cgroup_io_limit_type_to_string(CGroupIOLimitType t) _const_; CGroupIOLimitType cgroup_io_limit_type_from_string(const char *s) _pure_; -/* Special values for the cpu.shares attribute */ -#define CGROUP_CPU_SHARES_INVALID UINT64_MAX -#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 special {blkio,io}.bfq.weight attribute */ +/* Special values for the io.bfq.weight attribute */ #define CGROUP_BFQ_WEIGHT_INVALID UINT64_MAX #define CGROUP_BFQ_WEIGHT_MIN UINT64_C(1) #define CGROUP_BFQ_WEIGHT_MAX UINT64_C(1000) @@ -133,18 +121,6 @@ static inline uint64_t BFQ_WEIGHT(uint64_t io_weight) { CGROUP_BFQ_WEIGHT_DEFAULT + (io_weight - CGROUP_WEIGHT_DEFAULT) * (CGROUP_BFQ_WEIGHT_MAX - CGROUP_BFQ_WEIGHT_DEFAULT) / (CGROUP_WEIGHT_MAX - CGROUP_WEIGHT_DEFAULT); } -/* Special values for the blkio.weight attribute */ -#define CGROUP_BLKIO_WEIGHT_INVALID UINT64_MAX -#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); -} - typedef enum CGroupUnified { CGROUP_UNIFIED_UNKNOWN = -1, CGROUP_UNIFIED_NONE = 0, /* Both systemd and controllers on legacy */ diff --git a/src/nspawn/nspawn-oci.c b/src/nspawn/nspawn-oci.c index f891ea07420..ef3a2e31197 100644 --- a/src/nspawn/nspawn-oci.c +++ b/src/nspawn/nspawn-oci.c @@ -76,6 +76,18 @@ * */ +/* Special values for the cpu.shares attribute */ +#define CGROUP_CPU_SHARES_INVALID UINT64_MAX +#define CGROUP_CPU_SHARES_MIN UINT64_C(2) +#define CGROUP_CPU_SHARES_MAX UINT64_C(262144) +#define CGROUP_CPU_SHARES_DEFAULT UINT64_C(1024) + +/* Special values for the blkio.weight attribute */ +#define CGROUP_BLKIO_WEIGHT_INVALID UINT64_MAX +#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 int oci_unexpected(const char *name, sd_json_variant *v, sd_json_dispatch_flags_t flags, void *userdata) { return json_log(v, flags, SYNTHETIC_ERRNO(EINVAL), "Unexpected OCI element '%s' of type '%s'.", name, sd_json_variant_type_to_string(sd_json_variant_type(v)));