]> git.proxmox.com Git - mirror_lxc.git/blobdiff - src/lxc/syscall_wrappers.h
conf: handle kernels without or not using SMT
[mirror_lxc.git] / src / lxc / syscall_wrappers.h
index 4a9dda83d1f5409e7ce6f3e263e76facd0ba8657..a5e98b565cb6666c0e04bc36bc156e3da048eddf 100644 (file)
@@ -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;
 
+       if (!cookie)
+               return ret_errno(EINVAL);
+
        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;
+                   PR_SCHED_CORE_SCOPE_THREAD, (unsigned long)cookie);
+       if (ret) {
+               *cookie = INVALID_SCHED_CORE_COOKIE;
+               return -errno;
+       }
 
-       return cookie;
+       return 0;
 }
 
 static inline int core_scheduling_cookie_create_threadgroup(pid_t pid)