mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 03:53:18 +00:00
Merge pull request #4010 from brauner/2021-10-23.fixes
conf: handle kernels without or not using SMT
This commit is contained in:
commit
16210a56b6
@ -409,8 +409,8 @@ static int get_attach_context(struct attach_context *ctx,
|
||||
SYSERROR("Failed to retrieve namespace flags");
|
||||
ctx->ns_clone_flags = ret;
|
||||
|
||||
ctx->core_sched_cookie = core_scheduling_cookie_get(ctx->init_pid);
|
||||
if (!core_scheduling_cookie_valid(ctx->core_sched_cookie))
|
||||
ret = core_scheduling_cookie_get(ctx->init_pid, &ctx->core_sched_cookie);
|
||||
if (ret || !core_scheduling_cookie_valid(ctx->core_sched_cookie))
|
||||
INFO("Container does not run in a separate core scheduling domain");
|
||||
else
|
||||
INFO("Container runs in separate core scheduling domain %llu",
|
||||
@ -1155,9 +1155,9 @@ __noreturn static void do_attach(struct attach_payload *ap)
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
core_sched_cookie = core_scheduling_cookie_get(getpid());
|
||||
if (!core_scheduling_cookie_valid(core_sched_cookie) &&
|
||||
ctx->core_sched_cookie != core_sched_cookie) {
|
||||
ret = core_scheduling_cookie_get(getpid(), &core_sched_cookie);
|
||||
if (ret || !core_scheduling_cookie_valid(core_sched_cookie) ||
|
||||
(ctx->core_sched_cookie != core_sched_cookie)) {
|
||||
SYSERROR("Invalid core scheduling domain cookie %llu != %llu",
|
||||
(llu)core_sched_cookie,
|
||||
(llu)ctx->core_sched_cookie);
|
||||
|
@ -1566,14 +1566,19 @@ static int core_scheduling(struct lxc_handler *handler)
|
||||
|
||||
ret = core_scheduling_cookie_create_threadgroup(handler->pid);
|
||||
if (ret < 0) {
|
||||
if (ret == -ENODEV) {
|
||||
INFO("The kernel doesn't support or doesn't use simultaneous multithreading (SMT)");
|
||||
conf->sched_core = false;
|
||||
return 0;
|
||||
}
|
||||
if (ret == -EINVAL)
|
||||
return syserror("The kernel does not support core scheduling");
|
||||
|
||||
return syserror("Failed to create new core scheduling domain");
|
||||
}
|
||||
|
||||
conf->sched_core_cookie = core_scheduling_cookie_get(handler->pid);
|
||||
if (!core_scheduling_cookie_valid(conf->sched_core_cookie))
|
||||
ret = core_scheduling_cookie_get(handler->pid, &conf->sched_core_cookie);
|
||||
if (ret || !core_scheduling_cookie_valid(conf->sched_core_cookie))
|
||||
return syserror("Failed to retrieve core scheduling domain cookie");
|
||||
|
||||
TRACE("Created new core scheduling domain with cookie %llu",
|
||||
|
@ -367,17 +367,21 @@ static inline bool core_scheduling_cookie_valid(__u64 cookie)
|
||||
return (cookie > 0) && (cookie != INVALID_SCHED_CORE_COOKIE);
|
||||
}
|
||||
|
||||
static inline __u64 core_scheduling_cookie_get(pid_t pid)
|
||||
static inline int core_scheduling_cookie_get(pid_t pid, __u64 *cookie)
|
||||
{
|
||||
__u64 cookie;
|
||||
int ret;
|
||||
|
||||
ret = prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, pid,
|
||||
PR_SCHED_CORE_SCOPE_THREAD, (unsigned long)&cookie);
|
||||
if (ret)
|
||||
return INVALID_SCHED_CORE_COOKIE;
|
||||
if (!cookie)
|
||||
return ret_errno(EINVAL);
|
||||
|
||||
return cookie;
|
||||
ret = prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, pid,
|
||||
PR_SCHED_CORE_SCOPE_THREAD, (unsigned long)cookie);
|
||||
if (ret) {
|
||||
*cookie = INVALID_SCHED_CORE_COOKIE;
|
||||
return -errno;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int core_scheduling_cookie_create_threadgroup(pid_t pid)
|
||||
|
Loading…
Reference in New Issue
Block a user