Skip to content

Commit fea9d17

Browse files
Oleg NesterovLinus Torvalds
authored andcommitted
ITIMER_REAL: convert to use struct pid
signal_struct->tsk points to the ->group_leader and thus we have the nasty code in de_thread() which has to change it and restart ->real_timer if the leader is changed. Use "struct pid *leader_pid" instead. This also allows us to kill now unneeded send_group_sig_info(). Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Davide Libenzi <davidel@xmailserver.org> Cc: Pavel Emelyanov <xemul@openvz.org> Acked-by: Roland McGrath <roland@redhat.com> Acked-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 46f382d commit fea9d17

5 files changed

Lines changed: 5 additions & 38 deletions

File tree

‎fs/exec.c‎

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -782,26 +782,8 @@ static int de_thread(struct task_struct *tsk)
782782
zap_other_threads(tsk);
783783
read_unlock(&tasklist_lock);
784784

785-
/*
786-
* Account for the thread group leader hanging around:
787-
*/
788-
count = 1;
789-
if (!thread_group_leader(tsk)) {
790-
count = 2;
791-
/*
792-
* The SIGALRM timer survives the exec, but needs to point
793-
* at us as the new group leader now. We have a race with
794-
* a timer firing now getting the old leader, so we need to
795-
* synchronize with any firing (by calling del_timer_sync)
796-
* before we can safely let the old group leader die.
797-
*/
798-
sig->tsk = tsk;
799-
spin_unlock_irq(lock);
800-
if (hrtimer_cancel(&sig->real_timer))
801-
hrtimer_restart(&sig->real_timer);
802-
spin_lock_irq(lock);
803-
}
804-
785+
/* Account for the thread group leader hanging around: */
786+
count = thread_group_leader(tsk) ? 1 : 2;
805787
sig->notify_count = count;
806788
while (atomic_read(&sig->count) > count) {
807789
__set_current_state(TASK_UNINTERRUPTIBLE);

‎include/linux/sched.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ struct signal_struct {
460460

461461
/* ITIMER_REAL timer for the process */
462462
struct hrtimer real_timer;
463-
struct task_struct *tsk;
463+
struct pid *leader_pid;
464464
ktime_t it_real_incr;
465465

466466
/* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */
@@ -1686,7 +1686,6 @@ extern void block_all_signals(int (*notifier)(void *priv), void *priv,
16861686
extern void unblock_all_signals(void);
16871687
extern void release_task(struct task_struct * p);
16881688
extern int send_sig_info(int, struct siginfo *, struct task_struct *);
1689-
extern int send_group_sig_info(int, struct siginfo *, struct task_struct *);
16901689
extern int force_sigsegv(int, struct task_struct *);
16911690
extern int force_sig_info(int, struct siginfo *, struct task_struct *);
16921691
extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);

‎kernel/fork.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,6 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
909909
hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
910910
sig->it_real_incr.tv64 = 0;
911911
sig->real_timer.function = it_real_fn;
912-
sig->tsk = tsk;
913912

914913
sig->it_virt_expires = cputime_zero;
915914
sig->it_virt_incr = cputime_zero;
@@ -1338,6 +1337,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
13381337
if (clone_flags & CLONE_NEWPID)
13391338
p->nsproxy->pid_ns->child_reaper = p;
13401339

1340+
p->signal->leader_pid = pid;
13411341
p->signal->tty = current->signal->tty;
13421342
set_task_pgrp(p, task_pgrp_nr(current));
13431343
set_task_session(p, task_session_nr(current));

‎kernel/itimer.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ enum hrtimer_restart it_real_fn(struct hrtimer *timer)
132132
struct signal_struct *sig =
133133
container_of(timer, struct signal_struct, real_timer);
134134

135-
send_group_sig_info(SIGALRM, SEND_SIG_PRIV, sig->tsk);
135+
kill_pid_info(SIGALRM, SEND_SIG_PRIV, sig->leader_pid);
136136

137137
return HRTIMER_NORESTART;
138138
}

‎kernel/signal.c‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,20 +1205,6 @@ send_sig(int sig, struct task_struct *p, int priv)
12051205
return send_sig_info(sig, __si_special(priv), p);
12061206
}
12071207

1208-
/*
1209-
* This is the entry point for "process-wide" signals.
1210-
* They will go to an appropriate thread in the thread group.
1211-
*/
1212-
int
1213-
send_group_sig_info(int sig, struct siginfo *info, struct task_struct *p)
1214-
{
1215-
int ret;
1216-
read_lock(&tasklist_lock);
1217-
ret = group_send_sig_info(sig, info, p);
1218-
read_unlock(&tasklist_lock);
1219-
return ret;
1220-
}
1221-
12221208
void
12231209
force_sig(int sig, struct task_struct *p)
12241210
{

0 commit comments

Comments
 (0)