Skip to contentSkip to conversation

Use SIGIO with caution

PATCH In review Andreas Färber 7 participants 15 messages May 29, 2011 – Jun 1, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use SIGIO with caution

BeOS and Haiku don't define SIGIO. When undefined, it won't arrive and doesn't need to be blocked.

---
 cpus.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
cpus.c +8 -0
index 1fc34b7..42af291 100644
@@ -395,7 +395,9 @@ static int qemu_signal_init(void)
     pthread_sigmask(SIG_UNBLOCK, &set, NULL);
 
     sigemptyset(&set);
+#ifdef SIGIO
     sigaddset(&set, SIGIO);
+#endif
     sigaddset(&set, SIGALRM);
     sigaddset(&set, SIG_IPI);
     sigaddset(&set, SIGBUS);
@@ -408,7 +410,9 @@ static int qemu_signal_init(void)
          * We need to process timer signals synchronously to avoid a race
          * between exit_request check and KVM vcpu entry.
          */
+#ifdef SIGIO
         sigaddset(&set, SIGIO);
+#endif
         sigaddset(&set, SIGALRM);
     }
 #endif
@@ -449,12 +453,16 @@ static void qemu_kvm_init_cpu_signals(CPUState *env)
 #else
     sigemptyset(&set);
     sigaddset(&set, SIG_IPI);
+#ifdef SIGIO
     sigaddset(&set, SIGIO);
+#endif
     sigaddset(&set, SIGALRM);
     pthread_sigmask(SIG_BLOCK, &set, NULL);
 
     pthread_sigmask(SIG_BLOCK, NULL, &set);
+#ifdef SIGIO
     sigdelset(&set, SIGIO);
+#endif
     sigdelset(&set, SIGALRM);
 #endif
     sigdelset(&set, SIG_IPI);
Signature · 1 line
1.7.5.3
#1 lore raw
Quoted 4 lines · Andreas Färber

BeOS and Haiku don't define SIGIO. When undefined, it won't arrive and doesn't need to be blocked.

Anything to do with signal masks is never a trivial patch BTW...

But I actually think explicit handling of SIGIO is unneeded. I think this is a hold over from the pre-I/O thread days where we selectively set SIGIO on certain file descriptors to make sure that when an IO fd became readable, we received a signal to break out of the KVM emulation loop.

Can the folks on CC confirm/deny?

I can't see any use of SIGIO in the current source tree.

Regards,

Anthony Liguori

Quoted 45 lines
---
  cpus.c |    8 ++++++++
  1 files changed, 8 insertions(+), 0 deletions(-)
cpus.c +8 -0
index 1fc34b7..42af291 100644
@@ -395,7 +395,9 @@ static int qemu_signal_init(void)
      pthread_sigmask(SIG_UNBLOCK,&set, NULL);
 
      sigemptyset(&set);
+#ifdef SIGIO
      sigaddset(&set, SIGIO);
+#endif
      sigaddset(&set, SIGALRM);
      sigaddset(&set, SIG_IPI);
      sigaddset(&set, SIGBUS);
@@ -408,7 +410,9 @@ static int qemu_signal_init(void)
           * We need to process timer signals synchronously to avoid a race
           * between exit_request check and KVM vcpu entry.
           */
+#ifdef SIGIO
          sigaddset(&set, SIGIO);
+#endif
          sigaddset(&set, SIGALRM);
      }
  #endif
@@ -449,12 +453,16 @@ static void qemu_kvm_init_cpu_signals(CPUState *env)
  #else
      sigemptyset(&set);
      sigaddset(&set, SIG_IPI);
+#ifdef SIGIO
      sigaddset(&set, SIGIO);
+#endif
      sigaddset(&set, SIGALRM);
      pthread_sigmask(SIG_BLOCK,&set, NULL);
 
      pthread_sigmask(SIG_BLOCK, NULL,&set);
+#ifdef SIGIO
      sigdelset(&set, SIGIO);
+#endif
      sigdelset(&set, SIGALRM);
  #endif
      sigdelset(&set, SIG_IPI);
#2 lore raw
Quoted 14 lines · Anthony Liguori
Quoted 4 lines · Andreas Färber

BeOS and Haiku don't define SIGIO. When undefined, it won't arrive and doesn't need to be blocked.

Anything to do with signal masks is never a trivial patch BTW...

But I actually think explicit handling of SIGIO is unneeded. I think this is a hold over from the pre-I/O thread days where we selectively set SIGIO on certain file descriptors to make sure that when an IO fd became readable, we received a signal to break out of the KVM emulation loop.

Quoted 3 lines

Can the folks on CC confirm/deny?

I can't see any use of SIGIO in the current source tree.

At least qemu-timer.c uses SIGIO in HPET mode. That only applies to Linux hosts, though.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#3 lore raw
Quoted 15 lines · Jan Kiszka
Quoted 14 lines · Anthony Liguori
Quoted 4 lines · Andreas Färber

BeOS and Haiku don't define SIGIO. When undefined, it won't arrive and doesn't need to be blocked.

Anything to do with signal masks is never a trivial patch BTW...

But I actually think explicit handling of SIGIO is unneeded. I think this is a hold over from the pre-I/O thread days where we selectively set SIGIO on certain file descriptors to make sure that when an IO fd became readable, we received a signal to break out of the KVM emulation loop.

Quoted 6 lines
Quoted 3 lines

Can the folks on CC confirm/deny?

I can't see any use of SIGIO in the current source tree.

At least qemu-timer.c uses SIGIO in HPET mode. That only applies to Linux hosts, though.

Is there any reason we still carry multiple timer implementations these days?

HPET shouldn't be any better than dynticks.

Regards,

Anthony Liguori

Quoted 3 lines

Jan

#4 lore raw
Quoted 20 lines · Anthony Liguori
Quoted 19 lines · Jan Kiszka
Quoted 17 lines · Anthony Liguori
Quoted 4 lines · Andreas Färber

BeOS and Haiku don't define SIGIO. When undefined, it won't arrive and doesn't need to be blocked.

Anything to do with signal masks is never a trivial patch BTW...

But I actually think explicit handling of SIGIO is unneeded. I think this is a hold over from the pre-I/O thread days where we selectively set SIGIO on certain file descriptors to make sure that when an IO fd became readable, we received a signal to break out of the KVM emulation loop.

Can the folks on CC confirm/deny?

I can't see any use of SIGIO in the current source tree.

Quoted 7 lines
Quoted 2 lines

At least qemu-timer.c uses SIGIO in HPET mode. That only applies to Linux hosts, though.

Is there any reason we still carry multiple timer implementations these days?

HPET shouldn't be any better than dynticks.

On any recent kernel, for sure. BTW, the same applies to the RTC timer.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#5 lore raw
Quoted 24 lines · Jan Kiszka
Quoted 23 lines · Anthony Liguori
Quoted 21 lines · Jan Kiszka
Quoted 14 lines · Anthony Liguori
Quoted 4 lines · Andreas Färber

BeOS and Haiku don't define SIGIO. When undefined, it won't arrive and doesn't need to be blocked.

Anything to do with signal masks is never a trivial patch BTW...

But I actually think explicit handling of SIGIO is unneeded. I think this is a hold over from the pre-I/O thread days where we selectively set SIGIO on certain file descriptors to make sure that when an IO fd became readable, we received a signal to break out of the KVM emulation loop.

Quoted 3 lines

Can the folks on CC confirm/deny?

I can't see any use of SIGIO in the current source tree.

At least qemu-timer.c uses SIGIO in HPET mode. That only applies to Linux hosts, though.

Quoted 6 lines
Quoted 4 lines

Is there any reason we still carry multiple timer implementations these days?

HPET shouldn't be any better than dynticks.

On any recent kernel, for sure. BTW, the same applies to the RTC timer.

So the obvious change would be to introduce CONFIG_HPET, ifdef the SIGIO handling on that and also ifdef the host hpet handling code on it? That way it's documented well and can preferably even be turned off with --disable-host-hpet during configure time, which we can then slowly turn to the default.

Alex

#6 lore raw
Quoted 27 lines · Alexander Graf
Quoted 24 lines · Jan Kiszka
Quoted 23 lines · Anthony Liguori
Quoted 21 lines · Jan Kiszka
Quoted 14 lines · Anthony Liguori
Quoted 4 lines · Andreas Färber

BeOS and Haiku don't define SIGIO. When undefined, it won't arrive and doesn't need to be blocked.

Anything to do with signal masks is never a trivial patch BTW...

But I actually think explicit handling of SIGIO is unneeded. I think this is a hold over from the pre-I/O thread days where we selectively set SIGIO on certain file descriptors to make sure that when an IO fd became readable, we received a signal to break out of the KVM emulation loop.

Quoted 3 lines

Can the folks on CC confirm/deny?

I can't see any use of SIGIO in the current source tree.

At least qemu-timer.c uses SIGIO in HPET mode. That only applies to Linux hosts, though.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Is there any reason we still carry multiple timer implementations these days?

HPET shouldn't be any better than dynticks.

On any recent kernel, for sure. BTW, the same applies to the RTC timer.

So the obvious change would be to introduce CONFIG_HPET, ifdef the SIGIO handling on that and also ifdef the host hpet handling code on it? That way it's documented well and can preferably even be turned off with --disable-host-hpet during configure time, which we can then slowly turn to the default.

Or just remove hpet and rtc.

Does anyone really object to that?

Regards,

Anthony Liguori

Quoted 4 lines

Alex

#7 lore raw
Quoted 33 lines · Anthony Liguori
Quoted 32 lines · Alexander Graf
Quoted 29 lines · Jan Kiszka
Quoted 27 lines · Anthony Liguori
Quoted 15 lines · Jan Kiszka
Quoted 14 lines · Anthony Liguori
Quoted 4 lines · Andreas Färber

BeOS and Haiku don't define SIGIO. When undefined, it won't arrive and doesn't need to be blocked.

Anything to do with signal masks is never a trivial patch BTW...

But I actually think explicit handling of SIGIO is unneeded. I think this is a hold over from the pre-I/O thread days where we selectively set SIGIO on certain file descriptors to make sure that when an IO fd became readable, we received a signal to break out of the KVM emulation loop.

Quoted 6 lines
Quoted 3 lines

Can the folks on CC confirm/deny?

I can't see any use of SIGIO in the current source tree.

At least qemu-timer.c uses SIGIO in HPET mode. That only applies to Linux hosts, though.

Is there any reason we still carry multiple timer implementations these days?

HPET shouldn't be any better than dynticks.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

On any recent kernel, for sure. BTW, the same applies to the RTC timer.

So the obvious change would be to introduce CONFIG_HPET, ifdef the SIGIO handling on that and also ifdef the host hpet handling code on it? That way it's documented well and can preferably even be turned off with --disable-host-hpet during configure time, which we can then slowly turn to the default.

Or just remove hpet and rtc.

Does anyone really object to that?

Do RHEL5 and SLES10 support dynticks? If yes, no objections. They're the oldest really supported distros we should possibly remotely even care about.

Alex

#8 lore raw
Quoted 38 lines · Alexander Graf
Quoted 35 lines · Anthony Liguori
Quoted 34 lines · Alexander Graf
Quoted 30 lines · Jan Kiszka
Quoted 20 lines · Anthony Liguori
Quoted 19 lines · Jan Kiszka
Quoted 17 lines · Anthony Liguori
Quoted 4 lines · Andreas Färber

BeOS and Haiku don't define SIGIO. When undefined, it won't arrive and doesn't need to be blocked.

Anything to do with signal masks is never a trivial patch BTW...

But I actually think explicit handling of SIGIO is unneeded. I think this is a hold over from the pre-I/O thread days where we selectively set SIGIO on certain file descriptors to make sure that when an IO fd became readable, we received a signal to break out of the KVM emulation loop.

Can the folks on CC confirm/deny?

I can't see any use of SIGIO in the current source tree.

Quoted 7 lines
Quoted 2 lines

At least qemu-timer.c uses SIGIO in HPET mode. That only applies to Linux hosts, though.

Is there any reason we still carry multiple timer implementations these days?

HPET shouldn't be any better than dynticks.

On any recent kernel, for sure. BTW, the same applies to the RTC timer.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

So the obvious change would be to introduce CONFIG_HPET, ifdef the SIGIO handling on that and also ifdef the host hpet handling code on it? That way it's documented well and can preferably even be turned off with --disable-host-hpet during configure time, which we can then slowly turn to the default.

Or just remove hpet and rtc.

Does anyone really object to that?

Do RHEL5 and SLES10 support dynticks? If yes, no objections. They're the oldest really supported distros we should possibly remotely even care about.

Yes, they do. But it's not as accurate as RTC/HPET because there is no CONFIG_HRTIMERS.

But the problem with RTC/HPET is that there is only one /dev/rtc and one /dev/hpet so only one guest can use it at any given time. It's really not a generally useful solution.

At one point in time, it was the only way to get a high res clock. Now, it Just Works provided you don't have an ancient kernel.

Regards,

Anthony Liguori

#9 lore raw

Am 31.05.2011 um 21:49 schrieb Anthony Liguori:

Quoted 14 lines · Alexander Graf
Quoted 13 lines · Anthony Liguori
Quoted 11 lines · Alexander Graf
Quoted 9 lines · Jan Kiszka
Quoted 7 lines · Anthony Liguori
Quoted 4 lines

Is there any reason we still carry multiple timer implementations these days?

HPET shouldn't be any better than dynticks.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

On any recent kernel, for sure. BTW, the same applies to the RTC timer.

So the obvious change would be to introduce CONFIG_HPET, ifdef the SIGIO handling on that and also ifdef the host hpet handling code on it? That way it's documented well and can preferably even be turned off with --disable-host-hpet during configure time, which we can then slowly turn to the default.

Or just remove hpet and rtc.

Does anyone really object to that?

--verbose please: We're not talking about "removal" of emulation of such acronyms for i386 guests, but about ceasing to use some Linux-only host facilities, right?

Quoted 7 lines
Quoted 1 line

Do RHEL5 and SLES10 support dynticks? If yes, no objections. They're the oldest really supported distros we should possibly remotely even care about.

Yes, they do. But it's not as accurate as RTC/HPET because there is no CONFIG_HRTIMERS.

But the problem with RTC/HPET is that there is only one /dev/rtc and one /dev/hpet so only one guest can use it at any given time. It's really not a generally useful solution.

At one point in time, it was the only way to get a high res clock. Now, it Just Works provided you don't have an ancient kernel.

I'm curious, what's ancient these days? 2.6.29 or more like 2.4.x?

Andreas

#10 lore raw
Quoted 26 lines · Andreas Färber

Am 31.05.2011 um 21:49 schrieb Anthony Liguori:

Quoted 24 lines · Alexander Graf
Quoted 23 lines · Anthony Liguori
Quoted 21 lines · Alexander Graf
Quoted 18 lines · Jan Kiszka
Quoted 10 lines · Anthony Liguori
Quoted 5 lines

Is there any reason we still carry multiple timer implementations these
days?

HPET shouldn't be any better than dynticks.

On any recent kernel, for sure. BTW, the same applies to the RTC timer.

So the obvious change would be to introduce CONFIG_HPET, ifdef the SIGIO handling on that and also ifdef the host hpet handling code on it? That way it's documented well and can preferably even be turned off with --disable-host-hpet during configure time, which we can then slowly turn to the default.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Or just remove hpet and rtc.

Does anyone really object to that?

--verbose please: We're not talking about "removal" of emulation of such acronyms for i386 guests, but about ceasing to use some Linux-only host facilities, right?

Right.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

Do RHEL5 and SLES10 support dynticks? If yes, no objections. They're the oldest really supported distros we should possibly remotely even care about.

Yes, they do. But it's not as accurate as RTC/HPET because there is no CONFIG_HRTIMERS.

Quoted 8 lines
Quoted 6 lines

But the problem with RTC/HPET is that there is only one /dev/rtc and one /dev/hpet so only one guest can use it at any given time. It's really not a generally useful solution.

At one point in time, it was the only way to get a high res clock. Now, it Just Works provided you don't have an ancient kernel.

I'm curious, what's ancient these days? 2.6.29 or more like 2.4.x?

IIRC, highres timers started to work around 2.6.24 on x86. Anyone on such an old kernel is likely also not interested in updating QEMU.

Jan

#11 lore raw
Quoted 9 lines · Jan Kiszka
Quoted 5 lines · Andreas Färber

Am 31.05.2011 um 21:49 schrieb Anthony Liguori:

Quoted 2 lines

At one point in time, it was the only way to get a high res clock. Now, it Just Works provided you don't have an ancient kernel.

I'm curious, what's ancient these days? 2.6.29 or more like 2.4.x?

IIRC, highres timers started to work around 2.6.24 on x86. Anyone on such an old kernel is likely also not interested in updating QEMU.

Yeah, 2.6.24 is ancient now that we're in the 3.0 world ;-)

Regards,

Anthony Liguori

Quoted 3 lines

Jan

#12 lore raw
In reply to Anthony Liguori
Quoted 6 lines · Anthony Liguori
Quoted 4 lines · Andreas Färber

BeOS and Haiku don't define SIGIO. When undefined, it won't arrive and doesn't need to be blocked.

Quoted 8 lines

Anything to do with signal masks is never a trivial patch BTW...

But I actually think explicit handling of SIGIO is unneeded. I think this is a hold over from the pre-I/O thread days where we selectively set SIGIO on certain file descriptors to make sure that when an IO fd became readable, we received a signal to break out of the KVM emulation loop.

Can the folks on CC confirm/deny?

I can't see any use of SIGIO in the current source tree.

We have O_ASYNC in enable_sigio_timer(). That's only used with HPET host timers, which should be very rare.

To be on the safe side I think we should take in the patch, and drop SIGIO support completely only if we decide the hpet host timer is not worth supporting.

Signature · 1 line
error compiling committee.c: too many arguments to function
#13 lore raw
In reply to Anthony Liguori

Am 31.05.2011 um 15:47 schrieb Anthony Liguori:

Quoted 7 lines · Andreas Färber
Quoted 4 lines

BeOS and Haiku don't define SIGIO. When undefined, it won't arrive and doesn't need to be blocked.

Anything to do with signal masks is never a trivial patch BTW...

The way I saw it, it didn't change signal behavior on Linux, Darwin, BSD, etc. hosts (where SIGIO must've been defined) and trivially unbroke not-yet-fully-supported Haiku host.

Andreas