diff options
Diffstat (limited to 'include/linux/slow-work.h')
| -rw-r--r-- | include/linux/slow-work.h | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/include/linux/slow-work.h b/include/linux/slow-work.h index b65c8881f07a..13337bf6c3f5 100644 --- a/include/linux/slow-work.h +++ b/include/linux/slow-work.h | |||
| @@ -17,13 +17,20 @@ | |||
| 17 | #ifdef CONFIG_SLOW_WORK | 17 | #ifdef CONFIG_SLOW_WORK |
| 18 | 18 | ||
| 19 | #include <linux/sysctl.h> | 19 | #include <linux/sysctl.h> |
| 20 | #include <linux/timer.h> | ||
| 20 | 21 | ||
| 21 | struct slow_work; | 22 | struct slow_work; |
| 23 | #ifdef CONFIG_SLOW_WORK_DEBUG | ||
| 24 | struct seq_file; | ||
| 25 | #endif | ||
| 22 | 26 | ||
| 23 | /* | 27 | /* |
| 24 | * The operations used to support slow work items | 28 | * The operations used to support slow work items |
| 25 | */ | 29 | */ |
| 26 | struct slow_work_ops { | 30 | struct slow_work_ops { |
| 31 | /* owner */ | ||
| 32 | struct module *owner; | ||
| 33 | |||
| 27 | /* get a ref on a work item | 34 | /* get a ref on a work item |
| 28 | * - return 0 if successful, -ve if not | 35 | * - return 0 if successful, -ve if not |
| 29 | */ | 36 | */ |
| @@ -34,6 +41,11 @@ struct slow_work_ops { | |||
| 34 | 41 | ||
| 35 | /* execute a work item */ | 42 | /* execute a work item */ |
| 36 | void (*execute)(struct slow_work *work); | 43 | void (*execute)(struct slow_work *work); |
| 44 | |||
| 45 | #ifdef CONFIG_SLOW_WORK_DEBUG | ||
| 46 | /* describe a work item for debugfs */ | ||
| 47 | void (*desc)(struct slow_work *work, struct seq_file *m); | ||
| 48 | #endif | ||
| 37 | }; | 49 | }; |
| 38 | 50 | ||
| 39 | /* | 51 | /* |
| @@ -42,13 +54,24 @@ struct slow_work_ops { | |||
| 42 | * queued | 54 | * queued |
| 43 | */ | 55 | */ |
| 44 | struct slow_work { | 56 | struct slow_work { |
| 57 | struct module *owner; /* the owning module */ | ||
| 45 | unsigned long flags; | 58 | unsigned long flags; |
| 46 | #define SLOW_WORK_PENDING 0 /* item pending (further) execution */ | 59 | #define SLOW_WORK_PENDING 0 /* item pending (further) execution */ |
| 47 | #define SLOW_WORK_EXECUTING 1 /* item currently executing */ | 60 | #define SLOW_WORK_EXECUTING 1 /* item currently executing */ |
| 48 | #define SLOW_WORK_ENQ_DEFERRED 2 /* item enqueue deferred */ | 61 | #define SLOW_WORK_ENQ_DEFERRED 2 /* item enqueue deferred */ |
| 49 | #define SLOW_WORK_VERY_SLOW 3 /* item is very slow */ | 62 | #define SLOW_WORK_VERY_SLOW 3 /* item is very slow */ |
| 63 | #define SLOW_WORK_CANCELLING 4 /* item is being cancelled, don't enqueue */ | ||
| 64 | #define SLOW_WORK_DELAYED 5 /* item is struct delayed_slow_work with active timer */ | ||
| 50 | const struct slow_work_ops *ops; /* operations table for this item */ | 65 | const struct slow_work_ops *ops; /* operations table for this item */ |
| 51 | struct list_head link; /* link in queue */ | 66 | struct list_head link; /* link in queue */ |
| 67 | #ifdef CONFIG_SLOW_WORK_DEBUG | ||
| 68 | struct timespec mark; /* jiffies at which queued or exec begun */ | ||
| 69 | #endif | ||
| 70 | }; | ||
| 71 | |||
| 72 | struct delayed_slow_work { | ||
| 73 | struct slow_work work; | ||
| 74 | struct timer_list timer; | ||
| 52 | }; | 75 | }; |
| 53 | 76 | ||
| 54 | /** | 77 | /** |
| @@ -67,6 +90,20 @@ static inline void slow_work_init(struct slow_work *work, | |||
| 67 | } | 90 | } |
| 68 | 91 | ||
| 69 | /** | 92 | /** |
| 93 | * slow_work_init - Initialise a delayed slow work item | ||
| 94 | * @work: The work item to initialise | ||
| 95 | * @ops: The operations to use to handle the slow work item | ||
| 96 | * | ||
| 97 | * Initialise a delayed slow work item. | ||
| 98 | */ | ||
| 99 | static inline void delayed_slow_work_init(struct delayed_slow_work *dwork, | ||
| 100 | const struct slow_work_ops *ops) | ||
| 101 | { | ||
| 102 | init_timer(&dwork->timer); | ||
| 103 | slow_work_init(&dwork->work, ops); | ||
| 104 | } | ||
| 105 | |||
| 106 | /** | ||
| 70 | * vslow_work_init - Initialise a very slow work item | 107 | * vslow_work_init - Initialise a very slow work item |
| 71 | * @work: The work item to initialise | 108 | * @work: The work item to initialise |
| 72 | * @ops: The operations to use to handle the slow work item | 109 | * @ops: The operations to use to handle the slow work item |
| @@ -83,9 +120,40 @@ static inline void vslow_work_init(struct slow_work *work, | |||
| 83 | INIT_LIST_HEAD(&work->link); | 120 | INIT_LIST_HEAD(&work->link); |
| 84 | } | 121 | } |
| 85 | 122 | ||
| 123 | /** | ||
| 124 | * slow_work_is_queued - Determine if a slow work item is on the work queue | ||
| 125 | * work: The work item to test | ||
| 126 | * | ||
| 127 | * Determine if the specified slow-work item is on the work queue. This | ||
| 128 | * returns true if it is actually on the queue. | ||
| 129 | * | ||
| 130 | * If the item is executing and has been marked for requeue when execution | ||
| 131 | * finishes, then false will be returned. | ||
| 132 | * | ||
| 133 | * Anyone wishing to wait for completion of execution can wait on the | ||
| 134 | * SLOW_WORK_EXECUTING bit. | ||
| 135 | */ | ||
| 136 | static inline bool slow_work_is_queued(struct slow_work *work) | ||
| 137 | { | ||
| 138 | unsigned long flags = work->flags; | ||
| 139 | return flags & SLOW_WORK_PENDING && !(flags & SLOW_WORK_EXECUTING); | ||
| 140 | } | ||
| 141 | |||
| 86 | extern int slow_work_enqueue(struct slow_work *work); | 142 | extern int slow_work_enqueue(struct slow_work *work); |
| 87 | extern int slow_work_register_user(void); | 143 | extern void slow_work_cancel(struct slow_work *work); |
| 88 | extern void slow_work_unregister_user(void); | 144 | extern int slow_work_register_user(struct module *owner); |
| 145 | extern void slow_work_unregister_user(struct module *owner); | ||
| 146 | |||
| 147 | extern int delayed_slow_work_enqueue(struct delayed_slow_work *dwork, | ||
| 148 | unsigned long delay); | ||
| 149 | |||
| 150 | static inline void delayed_slow_work_cancel(struct delayed_slow_work *dwork) | ||
| 151 | { | ||
| 152 | slow_work_cancel(&dwork->work); | ||
| 153 | } | ||
| 154 | |||
| 155 | extern bool slow_work_sleep_till_thread_needed(struct slow_work *work, | ||
| 156 | signed long *_timeout); | ||
| 89 | 157 | ||
| 90 | #ifdef CONFIG_SYSCTL | 158 | #ifdef CONFIG_SYSCTL |
| 91 | extern ctl_table slow_work_sysctls[]; | 159 | extern ctl_table slow_work_sysctls[]; |
