diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-10-09 03:02:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-10-09 03:02:35 -0400 |
commit | 1236d6bb6e19fc72ffc6bbcdeb1bfefe450e54ee (patch) | |
tree | 47da3feee8e263e8c9352c85cf518e624be3c211 /include/linux/sched.h | |
parent | 750b1a6894ecc9b178c6e3d0a1170122971b2036 (diff) | |
parent | 8a5776a5f49812d29fe4b2d0a2d71675c3facf3f (diff) |
Merge 4.14-rc4 into staging-next
We want the staging/iio fixes in here as well to handle merge issues.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r-- | include/linux/sched.h | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 92fb8dd5a9e4..26a7df4e558c 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -65,25 +65,23 @@ struct task_group; | |||
65 | */ | 65 | */ |
66 | 66 | ||
67 | /* Used in tsk->state: */ | 67 | /* Used in tsk->state: */ |
68 | #define TASK_RUNNING 0 | 68 | #define TASK_RUNNING 0x0000 |
69 | #define TASK_INTERRUPTIBLE 1 | 69 | #define TASK_INTERRUPTIBLE 0x0001 |
70 | #define TASK_UNINTERRUPTIBLE 2 | 70 | #define TASK_UNINTERRUPTIBLE 0x0002 |
71 | #define __TASK_STOPPED 4 | 71 | #define __TASK_STOPPED 0x0004 |
72 | #define __TASK_TRACED 8 | 72 | #define __TASK_TRACED 0x0008 |
73 | /* Used in tsk->exit_state: */ | 73 | /* Used in tsk->exit_state: */ |
74 | #define EXIT_DEAD 16 | 74 | #define EXIT_DEAD 0x0010 |
75 | #define EXIT_ZOMBIE 32 | 75 | #define EXIT_ZOMBIE 0x0020 |
76 | #define EXIT_TRACE (EXIT_ZOMBIE | EXIT_DEAD) | 76 | #define EXIT_TRACE (EXIT_ZOMBIE | EXIT_DEAD) |
77 | /* Used in tsk->state again: */ | 77 | /* Used in tsk->state again: */ |
78 | #define TASK_DEAD 64 | 78 | #define TASK_PARKED 0x0040 |
79 | #define TASK_WAKEKILL 128 | 79 | #define TASK_DEAD 0x0080 |
80 | #define TASK_WAKING 256 | 80 | #define TASK_WAKEKILL 0x0100 |
81 | #define TASK_PARKED 512 | 81 | #define TASK_WAKING 0x0200 |
82 | #define TASK_NOLOAD 1024 | 82 | #define TASK_NOLOAD 0x0400 |
83 | #define TASK_NEW 2048 | 83 | #define TASK_NEW 0x0800 |
84 | #define TASK_STATE_MAX 4096 | 84 | #define TASK_STATE_MAX 0x1000 |
85 | |||
86 | #define TASK_STATE_TO_CHAR_STR "RSDTtXZxKWPNn" | ||
87 | 85 | ||
88 | /* Convenience macros for the sake of set_current_state: */ | 86 | /* Convenience macros for the sake of set_current_state: */ |
89 | #define TASK_KILLABLE (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE) | 87 | #define TASK_KILLABLE (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE) |
@@ -99,7 +97,8 @@ struct task_group; | |||
99 | /* get_task_state(): */ | 97 | /* get_task_state(): */ |
100 | #define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \ | 98 | #define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \ |
101 | TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \ | 99 | TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \ |
102 | __TASK_TRACED | EXIT_ZOMBIE | EXIT_DEAD) | 100 | __TASK_TRACED | EXIT_DEAD | EXIT_ZOMBIE | \ |
101 | TASK_PARKED) | ||
103 | 102 | ||
104 | #define task_is_traced(task) ((task->state & __TASK_TRACED) != 0) | 103 | #define task_is_traced(task) ((task->state & __TASK_TRACED) != 0) |
105 | 104 | ||
@@ -1243,17 +1242,34 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk) | |||
1243 | return task_pgrp_nr_ns(tsk, &init_pid_ns); | 1242 | return task_pgrp_nr_ns(tsk, &init_pid_ns); |
1244 | } | 1243 | } |
1245 | 1244 | ||
1246 | static inline char task_state_to_char(struct task_struct *task) | 1245 | #define TASK_REPORT_IDLE (TASK_REPORT + 1) |
1246 | #define TASK_REPORT_MAX (TASK_REPORT_IDLE << 1) | ||
1247 | |||
1248 | static inline unsigned int __get_task_state(struct task_struct *tsk) | ||
1249 | { | ||
1250 | unsigned int tsk_state = READ_ONCE(tsk->state); | ||
1251 | unsigned int state = (tsk_state | tsk->exit_state) & TASK_REPORT; | ||
1252 | |||
1253 | BUILD_BUG_ON_NOT_POWER_OF_2(TASK_REPORT_MAX); | ||
1254 | |||
1255 | if (tsk_state == TASK_IDLE) | ||
1256 | state = TASK_REPORT_IDLE; | ||
1257 | |||
1258 | return fls(state); | ||
1259 | } | ||
1260 | |||
1261 | static inline char __task_state_to_char(unsigned int state) | ||
1247 | { | 1262 | { |
1248 | const char stat_nam[] = TASK_STATE_TO_CHAR_STR; | 1263 | static const char state_char[] = "RSDTtXZPI"; |
1249 | unsigned long state = task->state; | ||
1250 | 1264 | ||
1251 | state = state ? __ffs(state) + 1 : 0; | 1265 | BUILD_BUG_ON(1 + ilog2(TASK_REPORT_MAX) != sizeof(state_char) - 1); |
1252 | 1266 | ||
1253 | /* Make sure the string lines up properly with the number of task states: */ | 1267 | return state_char[state]; |
1254 | BUILD_BUG_ON(sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1); | 1268 | } |
1255 | 1269 | ||
1256 | return state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?'; | 1270 | static inline char task_state_to_char(struct task_struct *tsk) |
1271 | { | ||
1272 | return __task_state_to_char(__get_task_state(tsk)); | ||
1257 | } | 1273 | } |
1258 | 1274 | ||
1259 | /** | 1275 | /** |