Revert "posix-aio-compat: avoid signal race when spawning a thread"
PATCH 1/1 Revert "posix-aio-compat: avoid signal race when spawning a thread"
This reverts commit ee3993069ff55fa6f1c64daf1e09963e340db8e4.
With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".
---
malc, care to describe what the problem you
are solving here is?
All, could everyone please start being nice and post patches and give time for review before applying?
Thanks!
posix-aio-compat.c | 14 +++++--------- 1 files changed, 5 insertions(+), 9 deletions(-)
posix-aio-compat.c +5 -9
@@ -301,9 +301,14 @@ static size_t handle_aiocb_rw(struct qemu_paiocb *aiocb)static void *aio_thread (void *unused) {pid_t pid; +sigset_t set; pid =getpid (); +/* block all signals */ +if (sigfillset (&set))die ("sigfillset" ); +if (sigprocmask (SIG_BLOCK , &set,NULL ))die ("sigprocmask" ); +while (1 ) {struct qemu_paiocb *aiocb;size_t ret =0 ;
@@ -364,18 +369,9 @@ static void *aio_thread(void *unused)static void spawn_thread (void ) { -sigset_t set, oldset; - cur_threads++; idle_threads++; - -/* block all signals */ -if (sigfillset (&set))die ("sigfillset" ); -if (sigprocmask (SIG_SETMASK , &set, &oldset))die ("sigprocmask" ); -thread_create (&thread_id, &attr, aio_thread,NULL ); - -if (sigprocmask (SIG_SETMASK , &oldset,NULL ))die ("sigprocmask restore" ); }static void qemu_paio_submit (struct qemu_paiocb *aiocb)
Signature · 1 line
1.6.5.rc2
Quoted 7 lines · Michael S. Tsirkin
This reverts commit
ee3993069ff55fa6f1c64daf1e09963e340db8e4.With commit
ee3993069ff55fa6f1c64daf1e09963e340db8e4, winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".
Quoted 6 lines
Signed-off-by Michael S. Tsirkin <[email protected]>Cc malc <[email protected]>---
malc, care to describe what the problem you
are solving here is?
New thread is spawned, SIGALRM arrives, kernel picks up this new thread since it's mask allows it - bad thigs happen.
Quoted 4 lines
All, could everyone please start being nice and post patches and give time for review before applying?
Thanks!
There's nothing to review in this particular case, the thing was plain broken, besides same thing was already discussed between me and Andrzej, see for instance:
http://www.mail-archive.com/[email protected]/msg09542.html
Needless to say the revert is broken also.
Signature · 1 line
mailto:[email protected]
Quoted 8 lines
There's nothing to review in this particular case, the thing was plain broken, besides same thing was already discussed between me and Andrzej, see for instance:
http://www.mail-archive.com/[email protected]/msg09542.htmlNeedless to say the revert is broken also.
Yeah, I understand the race the original commit fixes but I don't understand how the original commit broke WinXP.
Do you have further insight Michael? Blindly reverting something that appears right because of a regression is likely just papering over a bigger problem.
Regards,
Anthony Liguori
Quoted 6 lines · Anthony Liguori
Quoted 6 lines
There's nothing to review in this particular case, the thing was plain broken, besides same thing was already discussed between me and Andrzej, see for instance:
http://www.mail-archive.com/[email protected]/msg09542.html
Quoted 7 lines
Quoted 2 lines
Needless to say the revert is broken also.
Yeah, I understand the race the original commit fixes but I don't understand how the original commit broke WinXP.
Do you have further insight Michael?
Nope, I just bisected and then reverted and tested that this helps.
Quoted 8 lines
Blindly reverting something that
appears right because of a regression is likely just papering over a bigger problem.Regards,
Anthony Liguori
Quoted 6 lines · Anthony Liguori
Quoted 6 lines
There's nothing to review in this particular case, the thing was plain broken, besides same thing was already discussed between me and Andrzej, see for instance:
http://www.mail-archive.com/[email protected]/msg09542.html
Quoted 7 lines
Quoted 2 lines
Needless to say the revert is broken also.
Yeah, I understand the race the original commit fixes but I don't understand how the original commit broke WinXP.
Do you have further insight Michael?
My guess is that SIGALARM gets lost, this somehow leads to disk request to timeout. Possible?
Quoted 7 lines
Blindly reverting something that appears right because of a regression is likely just papering over a bigger problem.
Regards,
Anthony Liguori
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Anthony Liguori
Quoted 8 lines
There's nothing to review in this particular case, the thing was plain broken, besides same thing was already discussed between me and Andrzej, see for instance:
http://www.mail-archive.com/[email protected]/msg09542.htmlNeedless to say the revert is broken also.
Quoted 7 lines
Quoted 4 lines
Yeah, I understand the race the original commit fixes but I don't understand how the original commit broke WinXP.
Do you have further insight Michael?
My guess is that SIGALARM gets lost, this somehow leads to disk request to timeout. Possible?
Being delayed - possible, being lost - violation of the spec.
Quoted 9 lines
Quoted 8 lines
Blindly reverting something that appears right because of a regression is likely just papering over a bigger problem.
Regards,
Anthony Liguori
Signature · 1 line
mailto:[email protected]
Quoted 15 lines · malc
Quoted 13 lines · Michael S. Tsirkin
Quoted 12 lines · Anthony Liguori
Quoted 8 lines
There's nothing to review in this particular case, the thing was plain broken, besides same thing was already discussed between me and Andrzej, see for instance:
http://www.mail-archive.com/[email protected]/msg09542.htmlNeedless to say the revert is broken also.
Yeah, I understand the race the original commit fixes but I don't understand how the original commit broke WinXP.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Do you have further insight Michael?
My guess is that SIGALARM gets lost, this somehow leads to disk request to timeout. Possible?
Being delayed - possible, being lost - violation of the spec.
I see this:
The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3).
Does it matter?
Quoted 12 lines
Quoted 9 lines
Quoted 8 lines
Blindly reverting something that appears right because of a regression is likely just papering over a bigger problem.
Regards,
Anthony Liguori
Signature · 1 line
mailto:[email protected]
Quoted 21 lines · Michael S. Tsirkin
Quoted 20 lines · malc
Quoted 17 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony Liguori
Quoted 6 lines
There's nothing to review in this particular case, the thing was plain broken, besides same thing was already discussed between me and Andrzej, see for instance:
http://www.mail-archive.com/[email protected]/msg09542.htmlQuoted 7 lines
Quoted 2 lines
Needless to say the revert is broken also.
Yeah, I understand the race the original commit fixes but I don't understand how the original commit broke WinXP.
Do you have further insight Michael?
My guess is that SIGALARM gets lost, this somehow leads to disk request to timeout. Possible?
Quoted 8 lines
Quoted 1 line
Being delayed - possible, being lost - violation of the spec.
I see this:
The use of
sigprocmask()is unspecified in a multithreaded process; seepthread_sigmask(3).Does it matter?
One of the patches i've asked you to try today replaced sigprocmask with pthread_sigmask, you've said it did nothing. In any case, strictly speaking, the code is wrong, so yes it does matter in theory.
[..snip..]
Signature · 1 line
mailto:[email protected]
Quoted 8 lines · malc
Quoted 4 lines
The use of
sigprocmask()is unspecified in a multithreaded process; seepthread_sigmask(3).Does it matter?
One of the patches i've asked you to try today replaced sigprocmask with
pthread_sigmask, you've said it did nothing. In any case, strictly speaking, the code is wrong, so yes it does matter in theory.
It won't matter on a Linux host (they are the same), but pthread_sigmask should be used because it's Right(tm) and it could make a difference on some other host.
-- Jamie
Quoted 6 lines · Jamie Lokier
Quoted 5 lines · malc
Quoted 4 lines
The use of
sigprocmask()is unspecified in a multithreaded process; seepthread_sigmask(3).Does it matter?
Quoted 7 lines
Quoted 3 lines
One of the patches i've asked you to try today replaced sigprocmask with
pthread_sigmask, you've said it did nothing. In any case, strictly speaking, the code is wrong, so yes it does matter in theory.It won't matter on a Linux host (they are the same), but
pthread_sigmaskshould be used because it's Right(tm) and it could make a difference on some other host.
What made you think i'm of a different opinion?
Signature · 1 line
mailto:[email protected]
Quoted 12 lines · malc
Quoted 10 lines · Jamie Lokier
Quoted 8 lines · malc
Quoted 4 lines
The use of
sigprocmask()is unspecified in a multithreaded process; seepthread_sigmask(3).Does it matter?
One of the patches i've asked you to try today replaced sigprocmask with
pthread_sigmask, you've said it did nothing. In any case, strictly speaking, the code is wrong, so yes it does matter in theory.
Quoted 5 lines
Quoted 3 lines
It won't matter on a Linux host (they are the same), but
pthread_sigmaskshould be used because it's Right(tm) and it could make a difference on some other host.What made you think i'm of a different opinion?
The fact you asked Michael to test a patch which replaced sigprocmask with pthread_sigmask.
-- Jamie
Quoted 13 lines · Jamie Lokier
Quoted 12 lines · malc
Quoted 10 lines · Jamie Lokier
Quoted 8 lines · malc
Quoted 4 lines
The use of
sigprocmask()is unspecified in a multithreaded process; seepthread_sigmask(3).Does it matter?
One of the patches i've asked you to try today replaced sigprocmask with
pthread_sigmask, you've said it did nothing. In any case, strictly speaking, the code is wrong, so yes it does matter in theory.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
It won't matter on a Linux host (they are the same), but
pthread_sigmaskshould be used because it's Right(tm) and it could make a difference on some other host.What made you think i'm of a different opinion?
The fact you asked Michael to test a patch which replaced sigprocmask with
pthread_sigmask.
That made you think i'm somehow in favour of sigprocmask? I'm confused.
Signature · 1 line
mailto:[email protected]
Quoted 19 lines · malc
Quoted 17 lines · Jamie Lokier
Quoted 16 lines · malc
Quoted 13 lines · Jamie Lokier
Quoted 8 lines · malc
Quoted 4 lines
The use of
sigprocmask()is unspecified in a multithreaded process; seepthread_sigmask(3).Does it matter?
One of the patches i've asked you to try today replaced sigprocmask with
pthread_sigmask, you've said it did nothing. In any case, strictly speaking, the code is wrong, so yes it does matter in theory.It won't matter on a Linux host (they are the same), but
pthread_sigmaskshould be used because it's Right(tm) and it could make a difference on some other host.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
What made you think i'm of a different opinion?
The fact you asked Michael to test a patch which replaced sigprocmask with
pthread_sigmask.That made you think i'm somehow in favour of sigprocmask? I'm confused.
It didn't make me think you're in favour of sigprocmask.
It made me think you thought there was a difference between them that would affect the bug.
Anyways, I think we're done with this subthread :-)
-- Jamie
Quoted 25 lines · Jamie Lokier
Quoted 24 lines · malc
Quoted 21 lines · Jamie Lokier
Quoted 12 lines · malc
Quoted 10 lines · Jamie Lokier
Quoted 8 lines · malc
Quoted 4 lines
The use of
sigprocmask()is unspecified in a multithreaded process; seepthread_sigmask(3).Does it matter?
One of the patches i've asked you to try today replaced sigprocmask with
pthread_sigmask, you've said it did nothing. In any case, strictly speaking, the code is wrong, so yes it does matter in theory.Quoted 5 lines
Quoted 3 lines
It won't matter on a Linux host (they are the same), but
pthread_sigmaskshould be used because it's Right(tm) and it could make a difference on some other host.What made you think i'm of a different opinion?
The fact you asked Michael to test a patch which replaced sigprocmask with
pthread_sigmask.
Quoted 8 lines
Quoted 1 line
That made you think i'm somehow in favour of sigprocmask? I'm confused.
It didn't make me think you're in favour of sigprocmask.
It made me think you thought there was a difference between them that would affect the bug.
Anyways, I think we're done with this subthread :-)
Goooood :)
Signature · 1 line
mailto:[email protected]
Quoted 4 lines · Jamie Lokier
Quoted 3 lines · malc
Quoted 1 line · Jamie Lokier
malc wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
The use of
sigprocmask()is unspecified in a multithreaded process; seepthread_sigmask(3).Does it matter?
One of the patches i've asked you to try today replaced sigprocmask with
pthread_sigmask, you've said it did nothing. In any case, strictly speaking, the code is wrong, so yes it does matter in theory.
BTW, tried looking at the code.
I saw some (unrelated) issues:
static void aio_signal_handler(int signum)
{
if (posix_aio_state) {
char byte = 0;
write(posix_aio_state->wfd, &byte, sizeof(byte));
}
qemu_service_io();
}And qemu_service_io does a *ton* of things. Questions:
- Do we need the call to qemu_service_io? Seems to behave the same with and without it.
- Are all of the data structures touched by qemu_service_io protected by blocking signals before access?
Also:
- let's use signalfd on linux, if available?
- for SIGALARM, maybe timerfd?
Thanks,
Signature · 1 line
MST
Quoted 14 lines · Michael S. Tsirkin
BTW, tried looking at the code.
I saw some (unrelated) issues:static void
aio_signal_handler(int signum){ if (posix_aio_state) { char byte = 0; write(posix_aio_state->wfd, &byte, sizeof(byte)); } qemu_service_io(); }
Quoted 2 lines
And
qemu_service_iodoes a *ton* of things.
It just does a cpu_exit().
Quoted 4 lines
Questions:
- Do we need the call toqemu_service_io? Seems to behave the same with and without it.
Where you run into trouble is when you have a guest that has no periodic timer and needs a mechanism to break out of the tcg loop whenever an IO operation completes. See
Author: aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> Date: Wed Oct 8 19:50:24 2008 +0000
Fix IO performance regression in sparc
Quoted 3 lines
- Are all of the data structures touched by
qemu_service_ioprotected by blocking signals before access?
cpu_exit is pretty careful to not do anything that could be racey.
Quoted 3 lines
Also:
- let's use signalfd on linux, if available?
signalfd doesn't help. In fact, we originally used signalfd and it caused a regression.
Quoted 2 lines
- for SIGALARM, maybe timerfd?
Or just get rid of SIGALARM...
Regards,
Anthony Liguori
Quoted 14 lines · Michael S. Tsirkin
BTW, tried looking at the code.
I saw some (unrelated) issues:static void
aio_signal_handler(int signum){ if (posix_aio_state) { char byte = 0; write(posix_aio_state->wfd, &byte, sizeof(byte)); } qemu_service_io(); }
Quoted 2 lines
And
qemu_service_iodoes a *ton* of things.
It just does a cpu_exit().
Quoted 4 lines
Questions:
- Do we need the call toqemu_service_io? Seems to behave the same with and without it.
Where you run into trouble is when you have a guest that has no periodic timer and needs a mechanism to break out of the tcg loop whenever an IO operation completes. See
Author: aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> Date: Wed Oct 8 19:50:24 2008 +0000
Fix IO performance regression in sparc
Quoted 3 lines
- Are all of the data structures touched by
qemu_service_ioprotected by blocking signals before access?
cpu_exit is pretty careful to not do anything that could be racey.
Quoted 3 lines
Also:
- let's use signalfd on linux, if available?
signalfd doesn't help. In fact, we originally used signalfd and it caused a regression.
Quoted 2 lines
- for SIGALARM, maybe timerfd?
Or just get rid of SIGALARM...
Regards,
Anthony Liguori
Review
Quoted 6 lines · Michael S. Tsirkin
And
qemu_service_iodoes a *ton* of things.
Questions:(quoted diff) +0
-2- Do we need the call to qemu_service_io? Seems to behave the same with and without it. - Are all of the data structures touched by qemu_service_io protected by blocking signals before access?
Plus:
- Are all the things done by qemu_service_io async-signal-safe? E.g. any use of pthread primitives is not async-signal-safe. I don't know if thread-local storage is.
-- Jamie