aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/taskqueue.h
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2020-02-11 18:48:07 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2020-02-11 18:48:07 +0000
commit4426b2e64bd6ff5b05997d985140323b3db67085 (patch)
treea460831d490a3103fdf3f5c457409cbc5b67766f /sys/sys/taskqueue.h
parent57349a4f415fdcf38d1d668072c9c455eff665fc (diff)
downloadsrc-4426b2e64bd6ff5b05997d985140323b3db67085.tar.gz
src-4426b2e64bd6ff5b05997d985140323b3db67085.zip
Add flag to struct task to mark the task as requiring network epoch.
When processing a taskqueue and a task has associated epoch, then enter for duration of the task. If consecutive tasks belong to the same epoch, batch them. Now we are talking about the network epoch only. Shrink the ta_priority size to 8-bits. No current consumers use a priority that won't fit into 8 bits. Also complexity of taskqueue_enqueue() is a square of maximum value of priority, so we unlikely ever want to go over UCHAR_MAX here. Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D23518
Notes
Notes: svn path=/head/; revision=357771
Diffstat (limited to 'sys/sys/taskqueue.h')
-rw-r--r--sys/sys/taskqueue.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/sys/sys/taskqueue.h b/sys/sys/taskqueue.h
index 3f7ff1f529a7..2be3c96bdae4 100644
--- a/sys/sys/taskqueue.h
+++ b/sys/sys/taskqueue.h
@@ -107,8 +107,7 @@ void taskqueue_set_callback(struct taskqueue *queue,
taskqueue_callback_fn callback, void *context);
#define TASK_INITIALIZER(priority, func, context) \
- { .ta_pending = 0, \
- .ta_priority = (priority), \
+ { .ta_priority = (priority), \
.ta_func = (func), \
.ta_context = (context) }
@@ -121,18 +120,25 @@ void taskqueue_thread_enqueue(void *context);
/*
* Initialise a task structure.
*/
-#define TASK_INIT(task, priority, func, context) do { \
- (task)->ta_pending = 0; \
- (task)->ta_priority = (priority); \
- (task)->ta_func = (func); \
- (task)->ta_context = (context); \
+#define TASK_INIT_FLAGS(task, priority, func, context, flags) do { \
+ MPASS((priority) >= 0 && (priority) <= 255); \
+ (task)->ta_pending = 0; \
+ (task)->ta_priority = (priority); \
+ (task)->ta_flags = (flags); \
+ (task)->ta_func = (func); \
+ (task)->ta_context = (context); \
} while (0)
+#define TASK_INIT(t, p, f, c) TASK_INIT_FLAGS(t, p, f, c, 0)
+
void _timeout_task_init(struct taskqueue *queue,
struct timeout_task *timeout_task, int priority, task_fn_t func,
void *context);
-#define TIMEOUT_TASK_INIT(queue, timeout_task, priority, func, context) \
- _timeout_task_init(queue, timeout_task, priority, func, context);
+#define TIMEOUT_TASK_INIT(queue, timeout_task, priority, func, context) do { \
+ _Static_assert((priority) >= 0 && (priority) <= 255, \
+ "struct task priority is 8 bit in size"); \
+ _timeout_task_init(queue, timeout_task, priority, func, context); \
+} while (0)
/*
* Declare a reference to a taskqueue.