aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/signal.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-06-02 05:14:00 -0400
committerOleg Nesterov <oleg@redhat.com>2011-06-04 12:17:10 -0400
commit3759a0d94c18764247b66511d1038f2b93aa95de (patch)
treeec56295fc1bd252bcbe1cb8552102deeef03bbb7 /kernel/signal.c
parent81be24b8cdeb69e62f9d1b6b425fd9ffdd37f581 (diff)
job control: introduce JOBCTL_PENDING_MASK and task_clear_jobctl_pending()
This patch introduces JOBCTL_PENDING_MASK and replaces task_clear_jobctl_stop_pending() with task_clear_jobctl_pending() which takes an extra @mask argument. JOBCTL_PENDING_MASK is currently equal to JOBCTL_STOP_PENDING but future patches will add more bits. recalc_sigpending_tsk() is updated to use JOBCTL_PENDING_MASK instead. task_clear_jobctl_pending() takes @mask which in subset of JOBCTL_PENDING_MASK and clears the relevant jobctl bits. If JOBCTL_STOP_PENDING is set, other STOP bits are cleared together. All task_clear_jobctl_stop_pending() users are updated to call task_clear_jobctl_pending() with JOBCTL_STOP_PENDING which is functionally identical to task_clear_jobctl_stop_pending(). This patch doesn't cause any functional change. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Diffstat (limited to 'kernel/signal.c')
-rw-r--r--kernel/signal.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index 62a6c3bb9f0d..288d952fa3b8 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -124,7 +124,7 @@ static inline int has_pending_signals(sigset_t *signal, sigset_t *blocked)
124 124
125static int recalc_sigpending_tsk(struct task_struct *t) 125static int recalc_sigpending_tsk(struct task_struct *t)
126{ 126{
127 if ((t->jobctl & JOBCTL_STOP_PENDING) || 127 if ((t->jobctl & JOBCTL_PENDING_MASK) ||
128 PENDING(&t->pending, &t->blocked) || 128 PENDING(&t->pending, &t->blocked) ||
129 PENDING(&t->signal->shared_pending, &t->blocked)) { 129 PENDING(&t->signal->shared_pending, &t->blocked)) {
130 set_tsk_thread_flag(t, TIF_SIGPENDING); 130 set_tsk_thread_flag(t, TIF_SIGPENDING);
@@ -245,18 +245,25 @@ static void task_clear_jobctl_trapping(struct task_struct *task)
245} 245}
246 246
247/** 247/**
248 * task_clear_jobctl_stop_pending - clear pending group stop 248 * task_clear_jobctl_pending - clear jobctl pending bits
249 * @task: target task 249 * @task: target task
250 * @mask: pending bits to clear
250 * 251 *
251 * Clear group stop states for @task. 252 * Clear @mask from @task->jobctl. @mask must be subset of
253 * %JOBCTL_PENDING_MASK. If %JOBCTL_STOP_PENDING is being cleared, other
254 * STOP bits are cleared together.
252 * 255 *
253 * CONTEXT: 256 * CONTEXT:
254 * Must be called with @task->sighand->siglock held. 257 * Must be called with @task->sighand->siglock held.
255 */ 258 */
256void task_clear_jobctl_stop_pending(struct task_struct *task) 259void task_clear_jobctl_pending(struct task_struct *task, unsigned int mask)
257{ 260{
258 task->jobctl &= ~(JOBCTL_STOP_PENDING | JOBCTL_STOP_CONSUME | 261 BUG_ON(mask & ~JOBCTL_PENDING_MASK);
259 JOBCTL_STOP_DEQUEUED); 262
263 if (mask & JOBCTL_STOP_PENDING)
264 mask |= JOBCTL_STOP_CONSUME | JOBCTL_STOP_DEQUEUED;
265
266 task->jobctl &= ~mask;
260} 267}
261 268
262/** 269/**
@@ -282,7 +289,7 @@ static bool task_participate_group_stop(struct task_struct *task)
282 289
283 WARN_ON_ONCE(!(task->jobctl & JOBCTL_STOP_PENDING)); 290 WARN_ON_ONCE(!(task->jobctl & JOBCTL_STOP_PENDING));
284 291
285 task_clear_jobctl_stop_pending(task); 292 task_clear_jobctl_pending(task, JOBCTL_STOP_PENDING);
286 293
287 if (!consume) 294 if (!consume)
288 return false; 295 return false;
@@ -810,7 +817,7 @@ static int prepare_signal(int sig, struct task_struct *p, int from_ancestor_ns)
810 rm_from_queue(SIG_KERNEL_STOP_MASK, &signal->shared_pending); 817 rm_from_queue(SIG_KERNEL_STOP_MASK, &signal->shared_pending);
811 t = p; 818 t = p;
812 do { 819 do {
813 task_clear_jobctl_stop_pending(t); 820 task_clear_jobctl_pending(t, JOBCTL_STOP_PENDING);
814 rm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending); 821 rm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending);
815 wake_up_state(t, __TASK_STOPPED); 822 wake_up_state(t, __TASK_STOPPED);
816 } while_each_thread(p, t); 823 } while_each_thread(p, t);
@@ -926,7 +933,7 @@ static void complete_signal(int sig, struct task_struct *p, int group)
926 signal->group_stop_count = 0; 933 signal->group_stop_count = 0;
927 t = p; 934 t = p;
928 do { 935 do {
929 task_clear_jobctl_stop_pending(t); 936 task_clear_jobctl_pending(t, JOBCTL_STOP_PENDING);
930 sigaddset(&t->pending.signal, SIGKILL); 937 sigaddset(&t->pending.signal, SIGKILL);
931 signal_wake_up(t, 1); 938 signal_wake_up(t, 1);
932 } while_each_thread(p, t); 939 } while_each_thread(p, t);
@@ -1161,7 +1168,7 @@ int zap_other_threads(struct task_struct *p)
1161 p->signal->group_stop_count = 0; 1168 p->signal->group_stop_count = 0;
1162 1169
1163 while_each_thread(p, t) { 1170 while_each_thread(p, t) {
1164 task_clear_jobctl_stop_pending(t); 1171 task_clear_jobctl_pending(t, JOBCTL_STOP_PENDING);
1165 count++; 1172 count++;
1166 1173
1167 /* Don't bother with already dead threads */ 1174 /* Don't bother with already dead threads */