Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-12 Thread Rich Felker
On Sat, Mar 12, 2016 at 07:48:36PM +0100, Ingo Molnar wrote: > > * Rich Felker wrote: > > > On Sat, Mar 12, 2016 at 06:00:40PM +0100, Ingo Molnar wrote: > > > > > > * Linus Torvalds wrote: > > > > > > > [...] > > > > > > > > Because if that's the case, I wonder if what you really want is not

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-12 Thread Ingo Molnar
* Rich Felker wrote: > On Sat, Mar 12, 2016 at 06:00:40PM +0100, Ingo Molnar wrote: > > > > * Linus Torvalds wrote: > > > > > [...] > > > > > > Because if that's the case, I wonder if what you really want is not > > > "sticky > > > signals" as much as "synchronous signals" - ie the ability

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-12 Thread Rich Felker
On Sat, Mar 12, 2016 at 06:05:09PM +0100, Ingo Molnar wrote: > > * Linus Torvalds wrote: > > > On Fri, Mar 11, 2016 at 11:39 AM, Linus Torvalds > > wrote: > > > > > > "An implementation may also mark other functions not specified in the > > > standard as cancellation points" > > > > .. but t

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-12 Thread Rich Felker
On Sat, Mar 12, 2016 at 06:00:40PM +0100, Ingo Molnar wrote: > > * Linus Torvalds wrote: > > > [...] > > > > Because if that's the case, I wonder if what you really want is not "sticky > > signals" as much as "synchronous signals" - ie the ability to say that a > > signal > > shouldn't ever

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-12 Thread Ingo Molnar
(Argh: Mail-Followup-To spam your mailer sets up is nasty!) * Szabolcs Nagy wrote: > > 4. A calls cancellation point and syscall correctly executes > > 5. Once A enables cancellation again, the cancellation propagates. > > > > So I still see no problem. > > i think the sticky signal desig

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-12 Thread Ingo Molnar
* Linus Torvalds wrote: > On Fri, Mar 11, 2016 at 11:39 AM, Linus Torvalds > wrote: > > > > "An implementation may also mark other functions not specified in the > > standard as cancellation points" > > .. but that was from the Linux man-page. The open group has > > "An implementation shal

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-12 Thread Ingo Molnar
* Linus Torvalds wrote: > [...] > > Because if that's the case, I wonder if what you really want is not "sticky > signals" as much as "synchronous signals" - ie the ability to say that a > signal > shouldn't ever interrupt in random places, but only at well-defined points > (where a system

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-11 Thread Linus Torvalds
On Fri, Mar 11, 2016 at 11:39 AM, Linus Torvalds wrote: > > "An implementation may also mark other functions not specified in the > standard as cancellation points" .. but that was from the Linux man-page. The open group has "An implementation shall not introduce cancellation points into any

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-11 Thread Linus Torvalds
On Fri, Mar 11, 2016 at 11:30 AM, Andy Lutomirski wrote: > > I think that this would almost work for musl, except that musl would > still need to be able to tell whether the syscall that eventually gets > interrupted is a cancellation point, which still may require some > ability to unwind from th

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-11 Thread Andy Lutomirski
On Fri, Mar 11, 2016 at 11:27 AM, Linus Torvalds wrote: > On Fri, Mar 11, 2016 at 3:39 AM, Szabolcs Nagy wrote: >> >> i think the sticky signal design would work, but more >> complex than what we have and adds some atomic rmw ops >> into common code paths and not backward compatible. >> >> not us

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-11 Thread Linus Torvalds
On Fri, Mar 11, 2016 at 3:39 AM, Szabolcs Nagy wrote: > > i think the sticky signal design would work, but more > complex than what we have and adds some atomic rmw ops > into common code paths and not backward compatible. > > not using vsyscalls for cancellation-points sounds easier. Hmm. Ok, so

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-11 Thread Szabolcs Nagy
* Ingo Molnar [2016-03-11 10:33:47 +0100]: > * Rich Felker wrote: > > > No, it doesn't work. Cancellability of the target thread at the time > > of the cancellation request (when you would decide whether or not to > > send the signal) has no relation to cancellability at the time of > > calling

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-11 Thread Ingo Molnar
* Rich Felker wrote: > No, it doesn't work. Cancellability of the target thread at the time > of the cancellation request (when you would decide whether or not to > send the signal) has no relation to cancellability at the time of > calling the cancellation point. Consider 2 threads A and B and

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-10 Thread Rich Felker
On Fri, Mar 11, 2016 at 02:39:47AM +0100, Szabolcs Nagy wrote: > * Rich Felker [2016-03-10 19:48:59 -0500]: > > On Fri, Mar 11, 2016 at 01:18:54AM +0100, Szabolcs Nagy wrote: > > > * Rich Felker [2016-03-10 18:28:20 -0500]: > > > > On Thu, Mar 10, 2016 at 07:03:31PM +0100, Ingo Molnar wrote: > >

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-10 Thread Szabolcs Nagy
* Szabolcs Nagy [2016-03-11 02:39:47 +0100]: > * Rich Felker [2016-03-10 19:48:59 -0500]: > > On Fri, Mar 11, 2016 at 01:18:54AM +0100, Szabolcs Nagy wrote: > > > * Rich Felker [2016-03-10 18:28:20 -0500]: > > > > On Thu, Mar 10, 2016 at 07:03:31PM +0100, Ingo Molnar wrote: > > > > > > > > > >

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-10 Thread Szabolcs Nagy
* Rich Felker [2016-03-10 19:48:59 -0500]: > On Fri, Mar 11, 2016 at 01:18:54AM +0100, Szabolcs Nagy wrote: > > * Rich Felker [2016-03-10 18:28:20 -0500]: > > > On Thu, Mar 10, 2016 at 07:03:31PM +0100, Ingo Molnar wrote: > > > > > > > > The sticky signal is only ever sent when the thread is in

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-10 Thread Andy Lutomirski
On Thu, Mar 10, 2016 at 4:48 PM, Rich Felker wrote: > On Fri, Mar 11, 2016 at 01:18:54AM +0100, Szabolcs Nagy wrote: >> * Rich Felker [2016-03-10 18:28:20 -0500]: >> > On Thu, Mar 10, 2016 at 07:03:31PM +0100, Ingo Molnar wrote: >> > > >> > > * Rich Felker wrote: >> > > >> > > > > So instead of

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-10 Thread Rich Felker
On Fri, Mar 11, 2016 at 01:18:54AM +0100, Szabolcs Nagy wrote: > * Rich Felker [2016-03-10 18:28:20 -0500]: > > On Thu, Mar 10, 2016 at 07:03:31PM +0100, Ingo Molnar wrote: > > > > > > * Rich Felker wrote: > > > > > > > > So instead of a sticky cancellation flag, we could introduce a sticky >

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-10 Thread Szabolcs Nagy
* Rich Felker [2016-03-10 18:28:20 -0500]: > On Thu, Mar 10, 2016 at 07:03:31PM +0100, Ingo Molnar wrote: > > > > * Rich Felker wrote: > > > > > > So instead of a sticky cancellation flag, we could introduce a sticky > > > > cancellation signal. > > > > > > > > A 'sticky signal' is not cleare

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-10 Thread Rich Felker
On Thu, Mar 10, 2016 at 07:03:31PM +0100, Ingo Molnar wrote: > > * Rich Felker wrote: > > > > So instead of a sticky cancellation flag, we could introduce a sticky > > > cancellation signal. > > > > > > A 'sticky signal' is not cleared from signal_pending() when the signal > > > handler > >

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-10 Thread Ingo Molnar
* Rich Felker wrote: > > So instead of a sticky cancellation flag, we could introduce a sticky > > cancellation signal. > > > > A 'sticky signal' is not cleared from signal_pending() when the signal > > handler > > executes, but it's automatically blocked so no signal handler recursion > >

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-10 Thread Rich Felker
On Thu, Mar 10, 2016 at 12:16:46PM +0100, Ingo Molnar wrote: > > * Rich Felker wrote: > > > [...] > > > > I believe a new kernel cancellation API with a sticky cancellation flag > > (rather > > than a signal), and a flag or'd onto the syscall number to make it > > cancellable > > at the call

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-10 Thread Ingo Molnar
* Rich Felker wrote: > [...] > > I believe a new kernel cancellation API with a sticky cancellation flag > (rather > than a signal), and a flag or'd onto the syscall number to make it > cancellable > at the call point, could work, but then userspace needs to support fairly > different old a

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-10 Thread Ingo Molnar
* Andy Lutomirski wrote: > Let me try to summarize my understanding of the semantics. > > Thread A sends thread B a signal. Thread B wants to ignore the signal and > defer > handling unless it's either in a particular syscall and returns -EINTR or > unless > the thread is about to do the s

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-09 Thread Rich Felker
On Wed, Mar 09, 2016 at 11:47:30AM -0800, Linus Torvalds wrote: > On Wed, Mar 9, 2016 at 3:34 AM, Szabolcs Nagy wrote: > >> > >> Could someone remind me why cancellation points matter to user-space? > > > > because of standards. > > So quite frankly, if we have to do kernel support for this, then

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-09 Thread Linus Torvalds
On Wed, Mar 9, 2016 at 12:57 PM, Andy Lutomirski wrote: > > How safe would this be in a multithreaded process? For example, if > open() gets canceled in the "killable" sense, is it guaranteed that no > file descriptor will be allocated? Not all system calls can be killed, we only do the usual ca

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-09 Thread Andy Lutomirski
On Wed, Mar 9, 2016 at 11:47 AM, Linus Torvalds wrote: > On Wed, Mar 9, 2016 at 3:34 AM, Szabolcs Nagy wrote: >>> >>> Could someone remind me why cancellation points matter to user-space? >> >> because of standards. > > So quite frankly, if we have to do kernel support for this, then let's > do i

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-09 Thread Linus Torvalds
On Wed, Mar 9, 2016 at 3:34 AM, Szabolcs Nagy wrote: >> >> Could someone remind me why cancellation points matter to user-space? > > because of standards. So quite frankly, if we have to do kernel support for this, then let's do it right, instead of just perpetuating a hack that was done in user

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-09 Thread Szabolcs Nagy
* Szabolcs Nagy [2016-03-09 12:34:50 +0100]: > * Ingo Molnar [2016-03-09 09:56:31 +0100]: > > Why is so much complexity added to avoid a ~3 instructions window where > > calcellation is tested? Cancellation at work atom boundaries is a > > fundamentally > > 'polling' model anyway, and signal d

Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers

2016-03-09 Thread Szabolcs Nagy
* Ingo Molnar [2016-03-09 09:56:31 +0100]: > * Andy Lutomirski wrote: > > > musl implements system call cancellation in an unusual but clever way. > > So I'm sceptical about the concept. > > Could someone remind me why cancellation points matter to user-space? > because of standards. > I kn