Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set cpu.rt_period_us and cpu.rt_runtime_us in the appropriate order #4235

Closed
wants to merge 1 commit into from

Commits on Apr 28, 2024

  1. libct/cg/v1:solution to the failure of setting rt_period and rt_runtime

    As reported in issue opencontainers#4094, sometimes setting rt_period_us and
    rt_runtime_us at the same time will fail. The reason is that in
     cgroupv1, these two values cannot be set atomically.
    
    When we set a new rt_period_us, the kernel will determine
    whether the current configuration of new_limit1 = old_quota/new_period
    exceeds the limit. If it exceeds the limit, an error will be reported.
    Maybe it is reasonable to set rt_runtime_us first so that the
    new_limit2 = new_quota/old_period.
    for example:
    The original state of cgv1 is rt_period_us: 10000 rt_runtime_us: 5000
    The user wants to change it to rt_period_us: 1000 rt_runtime_us:300.
    The new rt_runtime_us should be set first.
    
    In the opposite case, if rt_runtime_us is set first, new_limit2 may still
    exceed the limit, but new_limit1 will be valid.
    for example:
    The original state of cgv1 is rt_period_us: 1000 rt_runtime_us: 500
    The user wants to change it to rt_period_us: 10000 rt_runtime_us:3000.
    The new rt_period_us should be set first.
    
    Therefore, new_limit1 and new_limit2 should be calculated in advance,
    and the smaller corresponding setting order should be selected to set
    rt_period_us and rt_runtime_us.
    
    Signed-off-by: ls-ggg <335814617@qq.com>
    ls-ggg authored and coolli committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    685f8db View commit details
    Browse the repository at this point in the history