Author: hselasky
Date: Mon Aug  6 10:48:20 2018
New Revision: 337376
URL: https://svnweb.freebsd.org/changeset/base/337376

Log:
  Implement current_work() function in the LinuxKPI.
  
  Tested by:    Johannes Lundberg <johal...@gmail.com>
  MFC after:    1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/sched.h
  head/sys/compat/linuxkpi/common/include/linux/workqueue.h
  head/sys/compat/linuxkpi/common/src/linux_work.c

Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/sched.h       Mon Aug  6 
09:22:07 2018        (r337375)
+++ head/sys/compat/linuxkpi/common/include/linux/sched.h       Mon Aug  6 
10:48:20 2018        (r337376)
@@ -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 ({ \

Modified: head/sys/compat/linuxkpi/common/include/linux/workqueue.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/workqueue.h   Mon Aug  6 
09:22:07 2018        (r337375)
+++ head/sys/compat/linuxkpi/common/include/linux/workqueue.h   Mon Aug  6 
10:48:20 2018        (r337376)
@@ -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_ */

Modified: head/sys/compat/linuxkpi/common/src/linux_work.c
==============================================================================
--- head/sys/compat/linuxkpi/common/src/linux_work.c    Mon Aug  6 09:22:07 
2018        (r337375)
+++ head/sys/compat/linuxkpi/common/src/linux_work.c    Mon Aug  6 10:48:20 
2018        (r337376)
@@ -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) {
@@ -577,6 +584,12 @@ linux_init_delayed_work(struct delayed_work *dwork, wo
        mtx_init(&dwork->timer.mtx, spin_lock_name("lkpi-dwork"), NULL,
            MTX_DEF | MTX_NOWITNESS);
        callout_init_mtx(&dwork->timer.callout, &dwork->timer.mtx, 0);
+}
+
+struct work_struct *
+linux_current_work(void)
+{
+       return (current->work);
 }
 
 static void
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to