mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/5] exec: simplify ->sighand switching
@ 2007-08-18 17:39 Oleg Nesterov
  2007-08-18 23:10 ` Roland McGrath
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2007-08-18 17:39 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Roland McGrath, linux-kernel

There is no any reason to do recalc_sigpending() after changing ->sighand.
To begin with, recalc_sigpending() does not take ->sighand into account.

This means we don't need to take newsighand->siglock while changing sighands.
rcu_assign_pointer() provides a necessary barrier, and if another process
reads the new ->sighand it should either take tasklist_lock or it should use
lock_task_sighand() which has a corresponding smp_read_barrier_depends().

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- t/fs/exec.c~2_SWITCH	2007-08-18 18:19:41.000000000 +0400
+++ t/fs/exec.c	2007-08-18 18:26:48.000000000 +0400
@@ -945,12 +945,7 @@ no_thread_group:
 
 		write_lock_irq(&tasklist_lock);
 		spin_lock(&oldsighand->siglock);
-		spin_lock_nested(&newsighand->siglock, SINGLE_DEPTH_NESTING);
-
 		rcu_assign_pointer(tsk->sighand, newsighand);
-		recalc_sigpending();
-
-		spin_unlock(&newsighand->siglock);
 		spin_unlock(&oldsighand->siglock);
 		write_unlock_irq(&tasklist_lock);
 
@@ -960,12 +955,11 @@ no_thread_group:
 	BUG_ON(!thread_group_leader(tsk));
 	return 0;
 }
-	
+
 /*
  * These functions flushes out all traces of the currently running executable
  * so that a new one can be started
  */
-
 static void flush_old_files(struct files_struct * files)
 {
 	long j = -1;


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/5] exec: simplify ->sighand switching
  2007-08-18 17:39 [PATCH 2/5] exec: simplify ->sighand switching Oleg Nesterov
@ 2007-08-18 23:10 ` Roland McGrath
  0 siblings, 0 replies; 2+ messages in thread
From: Roland McGrath @ 2007-08-18 23:10 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Andrew Morton, linux-kernel

> There is no any reason to do recalc_sigpending() after changing ->sighand.
> To begin with, recalc_sigpending() does not take ->sighand into account.

I agree.  I think that call dates from before some other cleanups in that
code, when ->signal was changed there.  At the time, it was the most
conservative change to leave recalc_sigpending in case the side effects it
used to have were desireable (we've since decided to change those anyway).


Thanks,
Roland

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-18 23:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-18 17:39 [PATCH 2/5] exec: simplify ->sighand switching Oleg Nesterov
2007-08-18 23:10 ` Roland McGrath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®