diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2018-08-06 10:48:20 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2018-08-06 10:48:20 +0000 |
commit | 549dcdb34e38f475111de691361dc7e15c75061f (patch) | |
tree | b2fa6721e79d3725f710960095254d1794adb4a4 /sys | |
parent | 936b2b64ae413c203b397023d4844f8f657c452a (diff) | |
download | src-549dcdb34e38f475111de691361dc7e15c75061f.tar.gz src-549dcdb34e38f475111de691361dc7e15c75061f.zip |
Implement current_work() function in the LinuxKPI.
Tested by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies
Notes
Notes:
svn path=/head/; revision=337376
Diffstat (limited to 'sys')
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/sched.h | 2 | ||||
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/workqueue.h | 4 | ||||
-rw-r--r-- | sys/compat/linuxkpi/common/src/linux_work.c | 15 |
3 files changed, 20 insertions, 1 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/sched.h b/sys/compat/linuxkpi/common/include/linux/sched.h index 7ba4df34247f..d0a5fde27cda 100644 --- a/sys/compat/linuxkpi/common/include/linux/sched.h +++ b/sys/compat/linuxkpi/common/include/linux/sched.h @@ -60,6 +60,7 @@ #define TASK_COMM_LEN (MAXCOMLEN + 1) +struct work_struct; struct task_struct { struct thread *task_thread; struct mm_struct *mm; @@ -78,6 +79,7 @@ struct task_struct { TAILQ_ENTRY(task_struct) rcu_entry; int rcu_recurse; int bsd_interrupt_value; + struct work_struct *work; /* current work struct, if set */ }; #define current ({ \ diff --git a/sys/compat/linuxkpi/common/include/linux/workqueue.h b/sys/compat/linuxkpi/common/include/linux/workqueue.h index 9746c1720b2a..8a9fbace3a07 100644 --- a/sys/compat/linuxkpi/common/include/linux/workqueue.h +++ b/sys/compat/linuxkpi/common/include/linux/workqueue.h @@ -209,6 +209,9 @@ do { \ #define destroy_workqueue(wq) \ linux_destroy_workqueue(wq) +#define current_work() \ + linux_current_work() + /* prototypes */ extern struct workqueue_struct *system_wq; @@ -232,5 +235,6 @@ extern bool linux_flush_work(struct work_struct *); extern bool linux_flush_delayed_work(struct delayed_work *); extern bool linux_work_pending(struct work_struct *); extern bool linux_work_busy(struct work_struct *); +extern struct work_struct *linux_current_work(void); #endif /* _LINUX_WORKQUEUE_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_work.c b/sys/compat/linuxkpi/common/src/linux_work.c index 3831d7a169c3..e01e507c6be8 100644 --- a/sys/compat/linuxkpi/common/src/linux_work.c +++ b/sys/compat/linuxkpi/common/src/linux_work.c @@ -220,8 +220,9 @@ linux_work_fn(void *context, int pending) struct work_struct *work; struct workqueue_struct *wq; struct work_exec exec; + struct task_struct *task; - linux_set_current(curthread); + task = current; /* setup local variables */ work = context; @@ -240,9 +241,15 @@ linux_work_fn(void *context, int pending) case WORK_ST_CANCEL: WQ_EXEC_UNLOCK(wq); + /* set current work structure */ + task->work = work; + /* call work function */ work->func(work); + /* set current work structure */ + task->work = NULL; + WQ_EXEC_LOCK(wq); /* check if unblocked */ if (exec.target != work) { @@ -579,6 +586,12 @@ linux_init_delayed_work(struct delayed_work *dwork, work_func_t func) callout_init_mtx(&dwork->timer.callout, &dwork->timer.mtx, 0); } +struct work_struct * +linux_current_work(void) +{ + return (current->work); +} + static void linux_work_init(void *arg) { |