From owner-svn-src-stable@freebsd.org Thu Aug 16 08:11:19 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4BA29108183E; Thu, 16 Aug 2018 08:11:19 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 01C8973794; Thu, 16 Aug 2018 08:11:19 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D716916B99; Thu, 16 Aug 2018 08:11:18 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7G8BIf6017859; Thu, 16 Aug 2018 08:11:18 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7G8BIBN017856; Thu, 16 Aug 2018 08:11:18 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201808160811.w7G8BIBN017856@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 16 Aug 2018 08:11:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r337897 - in stable/11/sys/compat/linuxkpi/common: include/linux src X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/11/sys/compat/linuxkpi/common: include/linux src X-SVN-Commit-Revision: 337897 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Aug 2018 08:11:19 -0000 Author: hselasky Date: Thu Aug 16 08:11:17 2018 New Revision: 337897 URL: https://svnweb.freebsd.org/changeset/base/337897 Log: MFC r337376: Implement current_work() function in the LinuxKPI. Tested by: Johannes Lundberg Sponsored by: Mellanox Technologies Modified: stable/11/sys/compat/linuxkpi/common/include/linux/sched.h stable/11/sys/compat/linuxkpi/common/include/linux/workqueue.h stable/11/sys/compat/linuxkpi/common/src/linux_work.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/sched.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/sched.h Thu Aug 16 08:10:11 2018 (r337896) +++ stable/11/sys/compat/linuxkpi/common/include/linux/sched.h Thu Aug 16 08:11:17 2018 (r337897) @@ -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: stable/11/sys/compat/linuxkpi/common/include/linux/workqueue.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/workqueue.h Thu Aug 16 08:10:11 2018 (r337896) +++ stable/11/sys/compat/linuxkpi/common/include/linux/workqueue.h Thu Aug 16 08:11:17 2018 (r337897) @@ -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: stable/11/sys/compat/linuxkpi/common/src/linux_work.c ============================================================================== --- stable/11/sys/compat/linuxkpi/common/src/linux_work.c Thu Aug 16 08:10:11 2018 (r337896) +++ stable/11/sys/compat/linuxkpi/common/src/linux_work.c Thu Aug 16 08:11:17 2018 (r337897) @@ -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