aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-06-14 05:20:14 -0400
committerOleg Nesterov <oleg@redhat.com>2011-06-16 15:41:52 -0400
commit73ddff2bee159ffb580bd24faf625cd5e628f5ec (patch)
tree218cf5101b67c98ef99814e59706976d3ad245c2 /include/linux/sched.h
parentdd1d6772692316fe35094085c5e4d9a370ad3462 (diff)
job control: introduce JOBCTL_TRAP_STOP and use it for group stop trap
do_signal_stop() implemented both normal group stop and trap for group stop while ptraced. This approach has been enough but scheduled changes require trap mechanism which can be used in more generic manner and using group stop trap for generic trap site simplifies both userland visible interface and implementation. This patch adds a new jobctl flag - JOBCTL_TRAP_STOP. When set, it triggers a trap site, which behaves like group stop trap, in get_signal_to_deliver() after checking for pending signals. While ptraced, do_signal_stop() doesn't stop itself. It initiates group stop if requested and schedules JOBCTL_TRAP_STOP and returns. The caller - get_signal_to_deliver() - is responsible for checking whether TRAP_STOP is pending afterwards and handling it. ptrace_attach() is updated to use JOBCTL_TRAP_STOP instead of JOBCTL_STOP_PENDING and __ptrace_unlink() to clear all pending trap bits and TRAPPING so that TRAP_STOP and future trap bits don't linger after detach. While at it, add proper function comment to do_signal_stop() and make it return bool. -v2: __ptrace_unlink() updated to clear JOBCTL_TRAP_MASK and TRAPPING instead of JOBCTL_PENDING_MASK. This avoids accidentally clearing JOBCTL_STOP_CONSUME. Spotted by Oleg. -v3: do_signal_stop() updated to return %false without dropping siglock while ptraced and TRAP_STOP check moved inside for(;;) loop after group stop participation. This avoids unnecessary relocking and also will help avoiding unnecessary traps by consuming group stop before handling pending traps. -v4: Jobctl trap handling moved into a separate function - do_jobctl_trap(). Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Oleg Nesterov <oleg@redhat.com>
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 5157bd9eee37..8bd84b83a35b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1810,17 +1810,21 @@ extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *
1810#define JOBCTL_STOP_DEQUEUED_BIT 16 /* stop signal dequeued */ 1810#define JOBCTL_STOP_DEQUEUED_BIT 16 /* stop signal dequeued */
1811#define JOBCTL_STOP_PENDING_BIT 17 /* task should stop for group stop */ 1811#define JOBCTL_STOP_PENDING_BIT 17 /* task should stop for group stop */
1812#define JOBCTL_STOP_CONSUME_BIT 18 /* consume group stop count */ 1812#define JOBCTL_STOP_CONSUME_BIT 18 /* consume group stop count */
1813#define JOBCTL_TRAP_STOP_BIT 19 /* trap for STOP */
1813#define JOBCTL_TRAPPING_BIT 21 /* switching to TRACED */ 1814#define JOBCTL_TRAPPING_BIT 21 /* switching to TRACED */
1814 1815
1815#define JOBCTL_STOP_DEQUEUED (1 << JOBCTL_STOP_DEQUEUED_BIT) 1816#define JOBCTL_STOP_DEQUEUED (1 << JOBCTL_STOP_DEQUEUED_BIT)
1816#define JOBCTL_STOP_PENDING (1 << JOBCTL_STOP_PENDING_BIT) 1817#define JOBCTL_STOP_PENDING (1 << JOBCTL_STOP_PENDING_BIT)
1817#define JOBCTL_STOP_CONSUME (1 << JOBCTL_STOP_CONSUME_BIT) 1818#define JOBCTL_STOP_CONSUME (1 << JOBCTL_STOP_CONSUME_BIT)
1819#define JOBCTL_TRAP_STOP (1 << JOBCTL_TRAP_STOP_BIT)
1818#define JOBCTL_TRAPPING (1 << JOBCTL_TRAPPING_BIT) 1820#define JOBCTL_TRAPPING (1 << JOBCTL_TRAPPING_BIT)
1819 1821
1820#define JOBCTL_PENDING_MASK JOBCTL_STOP_PENDING 1822#define JOBCTL_TRAP_MASK JOBCTL_TRAP_STOP
1823#define JOBCTL_PENDING_MASK (JOBCTL_STOP_PENDING | JOBCTL_TRAP_MASK)
1821 1824
1822extern bool task_set_jobctl_pending(struct task_struct *task, 1825extern bool task_set_jobctl_pending(struct task_struct *task,
1823 unsigned int mask); 1826 unsigned int mask);
1827extern void task_clear_jobctl_trapping(struct task_struct *task);
1824extern void task_clear_jobctl_pending(struct task_struct *task, 1828extern void task_clear_jobctl_pending(struct task_struct *task,
1825 unsigned int mask); 1829 unsigned int mask);
1826 1830