Skip to contentSkip to conversation

async: Using current_work() to implement current_is_async()

PATCH Superseded Yunfeng Ye 1 participant 2 messages Sep 27, 2019 – Oct 26, 2019

lore
Share & tools
lore

Yunfeng Ye

author
#0 lore raw

PATCH v2 1/1 async: Using current_work() to implement current_is_async()

current_is_async() can be implemented using current_work(), it's better not to be aware of the workqueue's internal information.

---
v1 -> v2:
- add "Reviewed-by"

 kernel/async.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/async.c +2 -4
index 1de270d..a849f98 100644
@@ -53,8 +53,6 @@ asynchronous and synchronous parts of the kernel.
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 
-#include "workqueue_internal.h"
-
 static async_cookie_t next_cookie = 1;
 
 #define MAX_WORK		32768
@@ -327,8 +325,8 @@ EXPORT_SYMBOL_GPL(async_synchronize_cookie);
  */
 bool current_is_async(void)
 {
-	struct worker *worker = current_wq_worker();
+	struct work_struct *work = current_work();
 
-	return worker && worker->current_func == async_run_entry_fn;
+	return work && work->func == async_run_entry_fn;
 }
 EXPORT_SYMBOL_GPL(current_is_async);
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/1 async: Using current_work() to implement current_is_async()

current_is_async() can be implemented using current_work(), it's better not to be aware of the workqueue's internal information.

---
v1 -> v2:
- add "Reviewed-by"

 kernel/async.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/async.c +2 -4
index 1de270d..a849f98 100644
@@ -53,8 +53,6 @@ asynchronous and synchronous parts of the kernel.
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 
-#include "workqueue_internal.h"
-
 static async_cookie_t next_cookie = 1;
 
 #define MAX_WORK		32768
@@ -327,8 +325,8 @@ EXPORT_SYMBOL_GPL(async_synchronize_cookie);
  */
 bool current_is_async(void)
 {
-	struct worker *worker = current_wq_worker();
+	struct work_struct *work = current_work();
 
-	return worker && worker->current_func == async_run_entry_fn;
+	return work && work->func == async_run_entry_fn;
 }
 EXPORT_SYMBOL_GPL(current_is_async);
Signature · 1 line
2.7.4