Re: Fix signalfd interaction with thread-private signals

2007-06-23 Thread Nicholas Miell
On Sat, 2007-06-23 at 16:05 +1000, Benjamin Herrenschmidt wrote: > On Fri, 2007-06-22 at 17:12 -0700, Davide Libenzi wrote: > > Wasn't it you that bitched (just a few days ago) because multiple > > threads > > could not use the same signalfd and they (by your initial thought) had > > to > > creat

Re: Fix signalfd interaction with thread-private signals

2007-06-23 Thread Oleg Nesterov
On 06/22, Linus Torvalds wrote: > > On Sat, 23 Jun 2007, Benjamin Herrenschmidt wrote: > > > > > > > > It does exactly so, please note this chunk > > > > > > @@ -330,7 +339,7 @@ asmlinkage long sys_signalfd(int ufd, si > > > > > > init_waitqueue_head(&ctx->wqh); > > >

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Benjamin Herrenschmidt
On Fri, 2007-06-22 at 17:12 -0700, Davide Libenzi wrote: > Wasn't it you that bitched (just a few days ago) because multiple > threads > could not use the same signalfd and they (by your initial thought) had > to > create one per thread? He said multiple process and you say multiple threads...

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Nicholas Miell
On Fri, 2007-06-22 at 17:12 -0700, Davide Libenzi wrote: > On Fri, 22 Jun 2007, Nicholas Miell wrote: > > > You could just get rid of the process/sighand/whatever reference > > entirely and just make reads on a signalfd always dequeue signals for > > the current thread. > > Duh?! ... > > > You'd

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Davide Libenzi
On Fri, 22 Jun 2007, Nicholas Miell wrote: > You could just get rid of the process/sighand/whatever reference > entirely and just make reads on a signalfd always dequeue signals for > the current thread. Duh?! ... > You'd lose the ability to pass signalfds around to other processes, but > I'm n

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Nicholas Miell
On Sat, 2007-06-23 at 09:19 +1000, Benjamin Herrenschmidt wrote: > On Sat, 2007-06-23 at 09:16 +1000, Benjamin Herrenschmidt wrote: > > On Fri, 2007-06-22 at 15:47 -0700, Linus Torvalds wrote: > > > Quite frankly, it strikes me that if we want to do this, then we > > > shouldn't > > > save the _p

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Benjamin Herrenschmidt
On Sat, 2007-06-23 at 09:16 +1000, Benjamin Herrenschmidt wrote: > On Fri, 2007-06-22 at 15:47 -0700, Linus Torvalds wrote: > > Quite frankly, it strikes me that if we want to do this, then we shouldn't > > save the _process_ information at all, we should save the "sighand" > > instead. > > > >

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Benjamin Herrenschmidt
On Fri, 2007-06-22 at 15:47 -0700, Linus Torvalds wrote: > Quite frankly, it strikes me that if we want to do this, then we shouldn't > save the _process_ information at all, we should save the "sighand" > instead. > > So either we save the process info, or we save the sighand, but saving the >

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Davide Libenzi
On Fri, 22 Jun 2007, Linus Torvalds wrote: > Quite frankly, it strikes me that if we want to do this, then we shouldn't > save the _process_ information at all, we should save the "sighand" > instead. > > So either we save the process info, or we save the sighand, but saving the > "group_leade

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Linus Torvalds
On Sat, 23 Jun 2007, Benjamin Herrenschmidt wrote: > > > > > It does exactly so, please note this chunk > > > > @@ -330,7 +339,7 @@ asmlinkage long sys_signalfd(int ufd, si > > > > init_waitqueue_head(&ctx->wqh); > > ctx->sigmask = sigmask; > > -

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Benjamin Herrenschmidt
> > It does exactly so, please note this chunk > > @@ -330,7 +339,7 @@ asmlinkage long sys_signalfd(int ufd, si > > init_waitqueue_head(&ctx->wqh); > ctx->sigmask = sigmask; > - ctx->tsk = current; > + ctx->tsk = current->group_le

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Oleg Nesterov
On 06/22, Benjamin Herrenschmidt wrote: > > That is, it -does- make sense to be able to create a signal singalfd in > a process and have N threads reading from it and getting either shared > signals or their local private signals. Great. > I just don't like the actual implementation of it by cha

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Benjamin Herrenschmidt
> OK. But in that case I think we should go further, and make signalfd > "per process", not "per thread", see > > http://marc.info/?l=linux-kernel&m=118241815219430 > > Every thread gets its own local signals plus shared ones. > > (I promise, this is the last piece of spam from me on this

Re: Fix signalfd interaction with thread-private signals

2007-06-22 Thread Oleg Nesterov
On 06/22, Benjamin Herrenschmidt wrote: > > Yeah well... I wanted to have the least surprise path... that is, > without my patch, signalfd will "sometimes" steal the SIGSEGV depending > on who races to the lock first, thus causing the target thread to > re-execute the faulting instruction and takin

Re: Fix signalfd interaction with thread-private signals

2007-06-21 Thread Linus Torvalds
On Fri, 22 Jun 2007, Benjamin Herrenschmidt wrote: > > Yeah well... I wanted to have the least surprise path... that is, > without my patch, signalfd will "sometimes" steal the SIGSEGV depending > on who races to the lock first Oh, absolutely. I thought we all agreed that Ben's patch was the ri

Re: Fix signalfd interaction with thread-private signals

2007-06-21 Thread Benjamin Herrenschmidt
On Thu, 2007-06-21 at 22:58 +0400, Oleg Nesterov wrote: > > > No "stealing". No signalfd, no *nothing*. Just normal signal > behaviour. > > _Another_ thread could steal SIGSEGV via read(signalfd) without Ben's patch. > This is what Ben and Davide are worried about. I think we should not worry, >

Re: Fix signalfd interaction with thread-private signals

2007-06-21 Thread Oleg Nesterov
On 06/21, Linus Torvalds wrote: > > On Thu, 21 Jun 2007, Oleg Nesterov wrote: > > > > Yes, the target thread is the one that caused the SIGSEGV, it sends the > > signal > > to itself. entry.S:ret_from_exception should notice this signal and > > _dequeue_ > > it, no? This signal could be stealed

Re: Fix signalfd interaction with thread-private signals

2007-06-21 Thread Linus Torvalds
On Thu, 21 Jun 2007, Oleg Nesterov wrote: > > Yes, the target thread is the one that caused the SIGSEGV, it sends the signal > to itself. entry.S:ret_from_exception should notice this signal and _dequeue_ > it, no? This signal could be stealed by signal(SIG_IGN) which runs after it > was deliver

Re: Fix signalfd interaction with thread-private signals

2007-06-21 Thread Oleg Nesterov
On 06/21, Linus Torvalds wrote: > > On Thu, 21 Jun 2007, Oleg Nesterov wrote: > > > > Yes, force_sig() unblocks and un-ignores the signal. However, unlike > > group-wide > > signals, thread-specific signals do not convert themselves to SIGKILL on > > delivery. > > The target thread should dequeu

Re: Fix signalfd interaction with thread-private signals

2007-06-21 Thread Linus Torvalds
On Thu, 21 Jun 2007, Oleg Nesterov wrote: > > Yes, force_sig() unblocks and un-ignores the signal. However, unlike > group-wide > signals, thread-specific signals do not convert themselves to SIGKILL on > delivery. > The target thread should dequeue SIGSEGV and then it calls do_group_exit().

Re: Fix signalfd interaction with thread-private signals

2007-06-21 Thread Oleg Nesterov
On 06/20, Linus Torvalds wrote: > > On Wed, 20 Jun 2007, Oleg Nesterov wrote: > > > > Also, suppose that some thread does > > > > for (;;) > > signal(SIGSEGV, SIG_IGN); > > > > Now we have the same situation. do_sigaction() can steal SIGSEGV from > > another thread. > > Actuall

Re: Fix signalfd interaction with thread-private signals

2007-06-20 Thread Linus Torvalds
On Wed, 20 Jun 2007, Oleg Nesterov wrote: > > Also, suppose that some thread does > > for (;;) > signal(SIGSEGV, SIG_IGN); > > Now we have the same situation. do_sigaction() can steal SIGSEGV from > another thread. Actually, that shouldn't be possible. See "force_sig_info

Re: Fix signalfd interaction with thread-private signals

2007-06-20 Thread Davide Libenzi
On Wed, 20 Jun 2007, Benjamin Herrenschmidt wrote: > On Tue, 2007-06-19 at 19:15 -0700, Davide Libenzi wrote: > > > Ok, why instead don't we go for something like the attached patch? > > We exclude sync signals from signalfd, but we don't limit signalfd to > > shared signals. Ie, we should be ab

Re: Fix signalfd interaction with thread-private signals

2007-06-20 Thread Oleg Nesterov
On 06/20, Benjamin Herrenschmidt wrote: > > On Tue, 2007-06-19 at 18:06 +0400, Oleg Nesterov wrote: > > On 06/19, Benjamin Herrenschmidt wrote: > > > > > > On Tue, 2007-06-19 at 13:14 +0400, Oleg Nesterov wrote: > > > > > > > The commited &q

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Benjamin Herrenschmidt
On Tue, 2007-06-19 at 19:15 -0700, Davide Libenzi wrote: > Ok, why instead don't we go for something like the attached patch? > We exclude sync signals from signalfd, but we don't limit signalfd to > shared signals. Ie, we should be able to fetch a signal sent with > sys_tkill() to threads diffe

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Davide Libenzi
On Wed, 20 Jun 2007, Benjamin Herrenschmidt wrote: > On Tue, 2007-06-19 at 16:49 -0700, Davide Libenzi wrote: > > > Actually, I think signalfd is fine as is, with Ben's patch applied. > > Signalfd should only fetch shared signals, not specific ones (in any > > case). > > The only advantage of

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Benjamin Herrenschmidt
On Tue, 2007-06-19 at 16:49 -0700, Davide Libenzi wrote: > Actually, I think signalfd is fine as is, with Ben's patch applied. > Signalfd should only fetch shared signals, not specific ones (in any > case). The only advantage of that additional patch is that it will allow any thread to fetch it

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Davide Libenzi
On Tue, 19 Jun 2007, Oleg Nesterov wrote: > The commited "Fix signalfd interaction with thread-private signals" > (commit caec4e8dc85e0644ec24aeb36285e1ba02da58cc) doesn't implement > this. > > We can do something like > > int signalfd_dequeue_sign

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Benjamin Herrenschmidt
On Tue, 2007-06-19 at 18:06 +0400, Oleg Nesterov wrote: > On 06/19, Benjamin Herrenschmidt wrote: > > > > On Tue, 2007-06-19 at 13:14 +0400, Oleg Nesterov wrote: > > > > > The commited "Fix signalfd interaction with thread-private signals" > > >

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Davide Libenzi
On Wed, 20 Jun 2007, Oleg Nesterov wrote: > Well, I think the kernel doesn't make any assumptions on that. It can't > guarantee the signal will be actually dequeued, to begin with. > > (That said, I probably missed something, in that case I'd like to be > educated. This is the real reason why I

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Oleg Nesterov
On 06/19, Davide Libenzi wrote: > > On Tue, 19 Jun 2007, Oleg Nesterov wrote: > > > On 06/19, Benjamin Herrenschmidt wrote: > > > > > > On Tue, 2007-06-19 at 13:14 +0400, Oleg Nesterov wrote: > > > > > > > The commited "Fix signal

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Oleg Nesterov
On 06/19, Davide Libenzi wrote: > > On Tue, 19 Jun 2007, Oleg Nesterov wrote: > > > The commited "Fix signalfd interaction with thread-private signals" > > (commit caec4e8dc85e0644ec24aeb36285e1ba02da58cc) doesn't implement > > this. > >

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Davide Libenzi
On Tue, 19 Jun 2007, Oleg Nesterov wrote: > On 06/19, Benjamin Herrenschmidt wrote: > > > > On Tue, 2007-06-19 at 13:14 +0400, Oleg Nesterov wrote: > > > > > The commited "Fix signalfd interaction with thread-private signals" > > > (commit

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Davide Libenzi
On Tue, 19 Jun 2007, Oleg Nesterov wrote: > The commited "Fix signalfd interaction with thread-private signals" > (commit caec4e8dc85e0644ec24aeb36285e1ba02da58cc) doesn't implement > this. > > We can do something like > > int signalfd_dequeue_sign

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Oleg Nesterov
On 06/19, Benjamin Herrenschmidt wrote: > > On Tue, 2007-06-19 at 13:14 +0400, Oleg Nesterov wrote: > > > The commited "Fix signalfd interaction with thread-private signals" > > (commit caec4e8dc85e0644ec24aeb36285e1ba02da58cc) doesn't implement > >

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Benjamin Herrenschmidt
On Tue, 2007-06-19 at 13:14 +0400, Oleg Nesterov wrote: > The commited "Fix signalfd interaction with thread-private signals" > (commit caec4e8dc85e0644ec24aeb36285e1ba02da58cc) doesn't implement > this. Indeed, if you want what Davide described, you need to also change

Re: Fix signalfd interaction with thread-private signals

2007-06-19 Thread Oleg Nesterov
or the process shared ones > (tsk->signal->shared_pending). This will be the behaviour once Ben's patch > is applied. The commited "Fix signalfd interaction with thread-private signals" (commit caec4e8dc85e0644ec24aeb36285e1ba02da58cc) doesn't