@@ -123,39 +123,31 @@ struct task_group;
123
123
124
124
#define task_is_stopped_or_traced (task ) ((READ_ONCE(task->__state) & (__TASK_STOPPED | __TASK_TRACED)) != 0)
125
125
126
- #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
127
-
128
126
/*
129
127
* Special states are those that do not use the normal wait-loop pattern. See
130
128
* the comment with set_special_state().
131
129
*/
132
130
#define is_special_task_state (state ) \
133
131
((state) & (__TASK_STOPPED | __TASK_TRACED | TASK_PARKED | TASK_DEAD))
134
132
135
- #define __set_current_state (state_value ) \
136
- do { \
137
- WARN_ON_ONCE(is_special_task_state(state_value));\
138
- current->task_state_change = _THIS_IP_; \
139
- WRITE_ONCE(current->__state, (state_value)); \
140
- } while (0)
141
-
142
- #define set_current_state (state_value ) \
143
- do { \
144
- WARN_ON_ONCE(is_special_task_state(state_value));\
145
- current->task_state_change = _THIS_IP_; \
146
- smp_store_mb(current->__state, (state_value)); \
133
+ #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
134
+ # define debug_normal_state_change (state_value ) \
135
+ do { \
136
+ WARN_ON_ONCE(is_special_task_state(state_value)); \
137
+ current->task_state_change = _THIS_IP_; \
147
138
} while (0)
148
139
149
- #define set_special_state (state_value ) \
140
+ # define debug_special_state_change (state_value ) \
150
141
do { \
151
- unsigned long flags; /* may shadow */ \
152
142
WARN_ON_ONCE(!is_special_task_state(state_value)); \
153
- raw_spin_lock_irqsave (& current -> pi_lock , flags ); \
154
143
current->task_state_change = _THIS_IP_; \
155
- WRITE_ONCE (current -> __state , (state_value )); \
156
- raw_spin_unlock_irqrestore (& current -> pi_lock , flags ); \
157
144
} while (0)
145
+
158
146
#else
147
+ # define debug_normal_state_change (cond ) do { } while (0)
148
+ # define debug_special_state_change (cond ) do { } while (0)
149
+ #endif
150
+
159
151
/*
160
152
* set_current_state() includes a barrier so that the write of current->state
161
153
* is correctly serialised wrt the caller's subsequent test of whether to
@@ -194,27 +186,33 @@ struct task_group;
194
186
* Also see the comments of try_to_wake_up().
195
187
*/
196
188
#define __set_current_state (state_value ) \
197
- WRITE_ONCE(current->__state, (state_value))
189
+ do { \
190
+ debug_normal_state_change((state_value)); \
191
+ WRITE_ONCE(current->__state, (state_value)); \
192
+ } while (0)
198
193
199
194
#define set_current_state (state_value ) \
200
- smp_store_mb(current->__state, (state_value))
195
+ do { \
196
+ debug_normal_state_change((state_value)); \
197
+ smp_store_mb(current->__state, (state_value)); \
198
+ } while (0)
201
199
202
200
/*
203
201
* set_special_state() should be used for those states when the blocking task
204
202
* can not use the regular condition based wait-loop. In that case we must
205
- * serialize against wakeups such that any possible in-flight TASK_RUNNING stores
206
- * will not collide with our state change.
203
+ * serialize against wakeups such that any possible in-flight TASK_RUNNING
204
+ * stores will not collide with our state change.
207
205
*/
208
206
#define set_special_state (state_value ) \
209
207
do { \
210
208
unsigned long flags; /* may shadow */ \
209
+ \
211
210
raw_spin_lock_irqsave (& current -> pi_lock , flags ); \
211
+ debug_special_state_change ((state_value )); \
212
212
WRITE_ONCE (current -> __state , (state_value )); \
213
213
raw_spin_unlock_irqrestore (& current -> pi_lock , flags ); \
214
214
} while (0 )
215
215
216
- #endif
217
-
218
216
#define get_current_state () READ_ONCE(current->__state)
219
217
220
218
/* Task command name length: */
0 commit comments