Commit 33e64f41 authored by Jan Kiszka's avatar Jan Kiszka

cobalt/posix/thread: Factor out thread_lookup_or_shadow

This pattern will be reused by cobalt_thread_setschedprio.
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 9f271d91
......@@ -463,32 +463,46 @@ static inline int pthread_setmode_np(int clrmask, int setmask, int *mode_r)
return 0;
}
int cobalt_thread_setschedparam_ex(unsigned long pth,
int policy,
const struct sched_param_ex *param_ex,
__u32 __user *u_winoff,
int __user *u_promoted)
static struct cobalt_thread *thread_lookup_or_shadow(unsigned long pth,
__u32 __user *u_winoff,
int *promoted_r)
{
struct cobalt_local_hkey hkey;
struct cobalt_thread *thread;
int ret, promoted = 0;
*promoted_r = 0;
hkey.u_pth = pth;
hkey.mm = current->mm;
trace_cobalt_pthread_setschedparam(pth, policy, param_ex);
thread = thread_lookup(&hkey);
if (thread == NULL) {
if (u_winoff == NULL)
return -ESRCH;
return ERR_PTR(-ESRCH);
thread = cobalt_thread_shadow(&hkey, u_winoff);
if (IS_ERR(thread))
return PTR_ERR(thread);
promoted = 1;
if (!IS_ERR(thread))
*promoted_r = 1;
}
return thread;
}
int cobalt_thread_setschedparam_ex(unsigned long pth,
int policy,
const struct sched_param_ex *param_ex,
__u32 __user *u_winoff,
int __user *u_promoted)
{
struct cobalt_thread *thread;
int ret, promoted;
trace_cobalt_pthread_setschedparam(pth, policy, param_ex);
thread = thread_lookup_or_shadow(pth, u_winoff, &promoted);
if (IS_ERR(thread))
return PTR_ERR(thread);
ret = __cobalt_thread_setschedparam_ex(thread, policy, param_ex);
if (ret)
return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment