diff options
Diffstat (limited to 'sys/compat/linuxkpi/common/include')
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/kthread.h | 11 | ||||
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/sched.h | 19 |
2 files changed, 21 insertions, 9 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/kthread.h b/sys/compat/linuxkpi/common/include/linux/kthread.h index f85a3f40ac55..61cdc3b8060a 100644 --- a/sys/compat/linuxkpi/common/include/linux/kthread.h +++ b/sys/compat/linuxkpi/common/include/linux/kthread.h @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,15 +45,18 @@ static inline void linux_kthread_fn(void *arg) { struct task_struct *task; + struct thread *td = curthread; task = arg; - task_struct_set(curthread, task); + task_struct_fill(td, task); + task_struct_set(td, task); if (task->should_stop == 0) task->task_ret = task->task_fn(task->task_data); - PROC_LOCK(task->task_thread->td_proc); + PROC_LOCK(td->td_proc); task->should_stop = TASK_STOPPED; wakeup(task); - PROC_UNLOCK(task->task_thread->td_proc); + PROC_UNLOCK(td->td_proc); + task_struct_set(td, NULL); kthread_exit(); } diff --git a/sys/compat/linuxkpi/common/include/linux/sched.h b/sys/compat/linuxkpi/common/include/linux/sched.h index c2d66d7fa6dd..ca1effe88600 100644 --- a/sys/compat/linuxkpi/common/include/linux/sched.h +++ b/sys/compat/linuxkpi/common/include/linux/sched.h @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,10 +50,12 @@ #define TASK_STOPPED 2 /* - * A task_struct is only provided for those tasks created with kthread. - * Using these routines with threads not started via kthread will cause - * panics because no task_struct is allocated and td_retval[1] is - * overwritten by syscalls which kernel threads will not make use of. + * A task_struct is only provided for threads created by kthread() and + * file operation callbacks. + * + * Using these routines outside the above mentioned contexts will + * cause panics because no task_struct is assigned and td_retval[1] is + * overwritten by syscalls. */ struct task_struct { struct thread *task_thread; @@ -62,10 +64,17 @@ struct task_struct { int task_ret; int state; int should_stop; + pid_t pid; + const char *comm; }; #define current task_struct_get(curthread) #define task_struct_get(x) ((struct task_struct *)(uintptr_t)(x)->td_retval[1]) +#define task_struct_fill(x, y) do { \ + (y)->task_thread = (x); \ + (y)->comm = (x)->td_name; \ + (y)->pid = (x)->td_tid; \ +} while (0) #define task_struct_set(x, y) (x)->td_retval[1] = (uintptr_t)(y) /* ensure the task_struct pointer fits into the td_retval[1] field */ |