Skip to content

change conversion from cgroup v1 to cgroup v2 #1721

@giuseppe

Description

@giuseppe

change the conversion formula from cgroup v1 to cgroup v2:
https://github.com/systemd/systemd/blob/5da476ac7728b91ad3a49c1b126b3559b4fbeed8/src/core/cgroup.c#L1598-L1611

static uint64_t cgroup_cpu_shares_to_weight(uint64_t shares) {
        return CLAMP(shares * CGROUP_WEIGHT_DEFAULT / CGROUP_CPU_SHARES_DEFAULT,
                     CGROUP_WEIGHT_MIN, CGROUP_WEIGHT_MAX);
}

static uint64_t cgroup_cpu_weight_to_shares(uint64_t weight) {
        /* we don't support idle in cgroupv1 */
        if (weight == CGROUP_WEIGHT_IDLE)
                return CGROUP_CPU_SHARES_MIN;

        return CLAMP(weight * CGROUP_CPU_SHARES_DEFAULT / CGROUP_WEIGHT_DEFAULT,
                     CGROUP_CPU_SHARES_MIN, CGROUP_CPU_SHARES_MAX);
}

Reference: kubernetes/kubernetes#131216

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions