Skip to contentSkip to conversation

coredump: speedup SIGKILL sending

PATCH In review Oleg Nesterov 3 participants 7 messages Apr 6, 2006 – Apr 10, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/4 coredump: speedup SIGKILL sending

With this patch a thread group is killed atomically under ->siglock. This is faster because we can use sigaddset() instead of force_sig_info() and this is used in further patches.

fs/exec.c renamed from fs/exec.c~2_KILL +8 -1
@@ -1387,17 +1387,24 @@ static void format_corename(char *corena
 static void zap_process(struct task_struct *start, int *ptraced)
 {
 	struct task_struct *t;
+	unsigned long flags;
+
+	spin_lock_irqsave(&start->sighand->siglock, flags);
 
 	t = start;
 	do {
 		if (t != current && t->mm) {
 			t->mm->core_waiters++;
-			force_sig_specific(SIGKILL, t);
+			sigaddset(&t->pending.signal, SIGKILL);
+			signal_wake_up(t, 1);
+
 			if (unlikely(t->ptrace) &&
 			    unlikely(t->parent->mm == t->mm))
 				*ptraced = 1;
 		}
 	} while ((t = next_thread(t)) != start);
+
+	spin_unlock_irqrestore(&start->sighand->siglock, flags);
 }
 
 static void zap_threads (struct mm_struct *mm)
#1 lore raw
Quoted 5 lines · Oleg Nesterov

With this patch a thread group is killed atomically under ->siglock. This is faster because we can use sigaddset() instead of force_sig_info() and this is used in further patches.

Won't this cause huge latencies when a process with lots of threads is killed?

Lee

#2 lore raw
Quoted 9 lines · Lee Revell
Quoted 5 lines · Oleg Nesterov

With this patch a thread group is killed atomically under ->siglock. This is faster because we can use sigaddset() instead of force_sig_info() and this is used in further patches.

Won't this cause huge latencies when a process with lots of threads is killed?

Yes, irqs are disabled. But this is not worse than 'kill -9 pid', note that __group_complete_signal() or zap_other_threads() do the same.

Oleg.

#3 lore raw
Quoted 6 lines · Oleg Nesterov
Quoted 5 lines · Lee Revell
Quoted 4 lines · Oleg Nesterov

With this patch a thread group is killed atomically under ->siglock. This is faster because we can use sigaddset() instead of force_sig_info() and this is used in further patches.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Won't this cause huge latencies when a process with lots of threads is killed?

Yes, irqs are disabled. But this is not worse than 'kill -9 pid', note that __group_complete_signal() or zap_other_threads() do the same.

Those have been problematic in the past. I am just wondering if this will be a latency regression, or if changes elsewhere in your patch negate the effect.

I'm just concerned because it was a lot of work over ~2 years to get 2.6 to perform decently in this area, and we have regressed since 2.6.14 (VM issue).

Lee

#4 lore raw
Quoted 12 lines · Lee Revell
Quoted 11 lines · Oleg Nesterov
Quoted 9 lines · Lee Revell
Quoted 5 lines · Oleg Nesterov

With this patch a thread group is killed atomically under ->siglock. This is faster because we can use sigaddset() instead of force_sig_info() and this is used in further patches.

Won't this cause huge latencies when a process with lots of threads is killed?

Quoted 6 lines
Quoted 2 lines

Yes, irqs are disabled. But this is not worse than 'kill -9 pid', note that __group_complete_signal() or zap_other_threads() do the same.

Those have been problematic in the past. I am just wondering if this will be a latency regression, or if changes elsewhere in your patch negate the effect.

zap_process() disables irqs while traversing ->thread_group list. So yes, if a process has a lot of threads it will be a latency regression. (but again, __group_complete_signal() does the same while delivering this signal, so I don't think this change can make things worse).

However this allows us to avoid tasklist_lock in zap_threads() so I think it is worth it. Please note that tasklist_lock was held while iterating over _all_ threads in system, not only current's thread group.

Oleg.

#5 lore raw
Quoted 9 lines · Oleg Nesterov

zap_process() disables irqs while traversing ->thread_group list. So yes, if a process has a lot of threads it will be a latency regression. (but again, __group_complete_signal() does the same while delivering this signal, so I don't think this change can make things worse).

However this allows us to avoid tasklist_lock in zap_threads() so I think it is worth it. Please note that tasklist_lock was held while iterating over _all_ threads in system, not only current's thread group.

OK sounds good.

Lee