|
Message-ID: <20160311093347.GA17749@gmail.com> Date: Fri, 11 Mar 2016 10:33:47 +0100 From: Ingo Molnar <mingo@...nel.org> To: Rich Felker <dalias@...c.org> Cc: Linus Torvalds <torvalds@...ux-foundation.org>, Andy Lutomirski <luto@...nel.org>, the arch/x86 maintainers <x86@...nel.org>, Linux Kernel Mailing List <linux-kernel@...r.kernel.org>, Borislav Petkov <bp@...en8.de>, "musl@...ts.openwall.com" <musl@...ts.openwall.com>, Andrew Morton <akpm@...ux-foundation.org>, Thomas Gleixner <tglx@...utronix.de>, Peter Zijlstra <a.p.zijlstra@...llo.nl> Subject: Re: Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers * Rich Felker <dalias@...c.org> 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 the > following sequence of events: > > 1. A has cancellation enabled > 2. B calls pthread_cancel(A) and sets sticky pending signal > 3. A disables cancellation > 4. A calls cancellation point and syscall wrongly gets interrupted As I (tried to!) describe it when describing the cancellation signal, if a cancellation signal is in flight, it must be waited for in the unlikely event of cancellation being disabled in the small window where the signal is sent. So in your above example, it would do: > 1. A has cancellation enabled > 2. B calls pthread_cancel(A) and sets sticky pending signal > 3. A disables cancellation 3b. Notices that cancellation request is pending and waits for it and clears the sticky signal. 4. A calls cancellation point and syscall correctly executes 5. Once A enables cancellation again, the cancellation propagates. So I still see no problem. > This can be solved with more synchronization in pthread_cancel and > pthread_setcancelstate, but it seems costly. [...] An active signal round trip in itself is very costly (thousands of cycles), a thread exit is tens of thousands of cycles, and this is a 'slow path' anyway, and the window is small in any case. It's just a correctness synchronization to make sure no sticky signal is pending, not a real performance concern in practice. Thanks, Ingo
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.