Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F176581616
D11904.id31681.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D11904.id31681.diff
View Options
Index: sys/compat/linuxkpi/common/src/linux_work.c
===================================================================
--- sys/compat/linuxkpi/common/src/linux_work.c
+++ sys/compat/linuxkpi/common/src/linux_work.c
@@ -214,7 +214,7 @@
[WORK_ST_TIMER] = WORK_ST_EXEC, /* delayed work w/o timeout */
[WORK_ST_TASK] = WORK_ST_EXEC, /* call callback */
[WORK_ST_EXEC] = WORK_ST_IDLE, /* complete callback */
- [WORK_ST_CANCEL] = WORK_ST_IDLE, /* complete cancel */
+ [WORK_ST_CANCEL] = WORK_ST_EXEC, /* failed to cancel */
};
struct work_struct *work;
struct workqueue_struct *wq;
@@ -236,6 +236,7 @@
switch (linux_update_state(&work->state, states)) {
case WORK_ST_TIMER:
case WORK_ST_TASK:
+ case WORK_ST_CANCEL:
WQ_EXEC_UNLOCK(wq);
/* call work function */
@@ -266,13 +267,14 @@
[WORK_ST_IDLE] = WORK_ST_IDLE, /* NOP */
[WORK_ST_TIMER] = WORK_ST_TASK, /* start queueing task */
[WORK_ST_TASK] = WORK_ST_TASK, /* NOP */
- [WORK_ST_EXEC] = WORK_ST_TASK, /* queue task another time */
- [WORK_ST_CANCEL] = WORK_ST_IDLE, /* complete cancel */
+ [WORK_ST_EXEC] = WORK_ST_EXEC, /* NOP */
+ [WORK_ST_CANCEL] = WORK_ST_TASK, /* failed to cancel */
};
struct delayed_work *dwork = arg;
switch (linux_update_state(&dwork->work.state, states)) {
case WORK_ST_TIMER:
+ case WORK_ST_CANCEL:
linux_delayed_work_enqueue(dwork);
break;
default:
@@ -290,10 +292,10 @@
{
static const uint8_t states[WORK_ST_MAX] __aligned(8) = {
[WORK_ST_IDLE] = WORK_ST_IDLE, /* NOP */
- [WORK_ST_TIMER] = WORK_ST_IDLE, /* idle */
- [WORK_ST_TASK] = WORK_ST_IDLE, /* idle */
- [WORK_ST_EXEC] = WORK_ST_IDLE, /* idle */
- [WORK_ST_CANCEL] = WORK_ST_IDLE, /* idle */
+ [WORK_ST_TIMER] = WORK_ST_TIMER, /* can't happen */
+ [WORK_ST_TASK] = WORK_ST_IDLE, /* cancel and drain */
+ [WORK_ST_EXEC] = WORK_ST_IDLE, /* too late, drain */
+ [WORK_ST_CANCEL] = WORK_ST_IDLE, /* cancel and drain */
};
struct taskqueue *tq;
@@ -302,6 +304,12 @@
switch (linux_update_state(&work->state, states)) {
case WORK_ST_IDLE:
+ case WORK_ST_TIMER:
+ return (0);
+ case WORK_ST_EXEC:
+ tq = work->work_queue->taskqueue;
+ if (taskqueue_cancel(tq, &work->work_task, NULL) != 0)
+ taskqueue_drain(tq, &work->work_task);
return (0);
default:
tq = work->work_queue->taskqueue;
@@ -343,10 +351,10 @@
{
static const uint8_t states[WORK_ST_MAX] __aligned(8) = {
[WORK_ST_IDLE] = WORK_ST_IDLE, /* NOP */
- [WORK_ST_TIMER] = WORK_ST_CANCEL, /* cancel */
- [WORK_ST_TASK] = WORK_ST_CANCEL, /* cancel */
- [WORK_ST_EXEC] = WORK_ST_CANCEL, /* cancel */
- [WORK_ST_CANCEL] = WORK_ST_CANCEL, /* cancel */
+ [WORK_ST_TIMER] = WORK_ST_CANCEL, /* try to cancel */
+ [WORK_ST_TASK] = WORK_ST_CANCEL, /* try to cancel */
+ [WORK_ST_EXEC] = WORK_ST_EXEC, /* NOP */
+ [WORK_ST_CANCEL] = WORK_ST_CANCEL, /* NOP */
};
struct taskqueue *tq;
@@ -356,7 +364,6 @@
return (1);
/* FALLTHROUGH */
case WORK_ST_TASK:
- case WORK_ST_EXEC:
tq = dwork->work.work_queue->taskqueue;
if (taskqueue_cancel(tq, &dwork->work.work_task, NULL) == 0)
return (1);
@@ -376,10 +383,10 @@
{
static const uint8_t states[WORK_ST_MAX] __aligned(8) = {
[WORK_ST_IDLE] = WORK_ST_IDLE, /* NOP */
- [WORK_ST_TIMER] = WORK_ST_IDLE, /* idle */
- [WORK_ST_TASK] = WORK_ST_IDLE, /* idle */
- [WORK_ST_EXEC] = WORK_ST_IDLE, /* idle */
- [WORK_ST_CANCEL] = WORK_ST_IDLE, /* idle */
+ [WORK_ST_TIMER] = WORK_ST_IDLE, /* cancel and drain */
+ [WORK_ST_TASK] = WORK_ST_IDLE, /* cancel and drain */
+ [WORK_ST_EXEC] = WORK_ST_IDLE, /* too late, drain */
+ [WORK_ST_CANCEL] = WORK_ST_IDLE, /* cancel and drain */
};
struct taskqueue *tq;
@@ -389,7 +396,13 @@
switch (linux_update_state(&dwork->work.state, states)) {
case WORK_ST_IDLE:
return (0);
+ case WORK_ST_EXEC:
+ tq = dwork->work.work_queue->taskqueue;
+ if (taskqueue_cancel(tq, &dwork->work.work_task, NULL) != 0)
+ taskqueue_drain(tq, &dwork->work.work_task);
+ return (0);
case WORK_ST_TIMER:
+ case WORK_ST_CANCEL:
if (linux_cancel_timer(dwork, 1)) {
/*
* Make sure taskqueue is also drained before
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 21, 12:23 AM (7 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41138174
Default Alt Text
D11904.id31681.diff (4 KB)
Attached To
Mode
D11904: Fix few issues of LinuxKPI workqueue
Attached
Detach File
Event Timeline
Log In to Comment