main: force enabling of I/O thread
PATCH 1/1 main: force enabling of I/O thread
Enabling the I/O thread by default seems like an important part of declaring 1.0. Besides allowing true SMP support with KVM, the I/O thread means that the TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which currently requires a (racey) signal based alarm system.
I know there have been concerns about performance. I think so far the ones that have come up (virtio-net) are most likely due to secondary reasons like decreased batching.
I think we ought to force enabling I/O thread early in 1.0 development and commit to resolving any lingering issues.
--- configure | 13 ----- cpus.c | 143 ---------------------------------------------------------- hw/qxl.c | 4 -- kvm-all.c | 2 +- qemu-timer.c | 53 --------------------- vl.c | 17 ------- 6 files changed, 1 insertions(+), 231 deletions(-)
configure +0 -13
@@ -165,7 +165,6 @@ darwin_user="no" bsd_user="no" guest_base="" uname_release="" -io_thread="no" mixemu="no" aix="no" blobs="yes"
@@ -722,8 +721,6 @@ for opt do ;; --enable-attr) attr="yes" ;; - --enable-io-thread) io_thread="yes" - ;; --disable-blobs) blobs="no" ;; --with-pkgversion=*) pkgversion=" ($optarg)"
@@ -2159,12 +2156,6 @@ EOF if compile_prog "" "" ; then signalfd=yes -elif test "$kvm" = "yes" -a "$io_thread" != "yes"; then - echo - echo "ERROR: Host kernel lacks signalfd() support," - echo "but KVM depends on it when the IO thread is disabled." - echo - exit 1 fi # check if eventfd is supported
@@ -2711,7 +2702,6 @@ echo "NPTL support $nptl" echo "GUEST_BASE $guest_base" echo "PIE user targets $user_pie" echo "vde support $vde" -echo "IO thread $io_thread" echo "Linux AIO support $linux_aio" echo "ATTR/XATTR support $attr" echo "Install blobs $blobs"
@@ -2969,9 +2959,6 @@ if test "$xen" = "yes" ; then echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak fi -if test "$io_thread" = "yes" ; then - echo "CONFIG_IOTHREAD=y" >> $config_host_mak -fi if test "$linux_aio" = "yes" ; then echo "CONFIG_LINUX_AIO=y" >> $config_host_mak fi
cpus.c +0 -143
219 lines not on this page · raw message
hw/qxl.c +0 -4
@@ -1388,11 +1388,7 @@ static void init_pipe_signaling(PCIQXLDevice *d)dprint (d,1 ,"%s: pipe creation failed\n" , __FUNCTION__);return ; } -#ifdef CONFIG_IOTHREAD fcntl (d->pipe[0 ],F_SETFL ,O_NONBLOCK ); -#else -fcntl (d->pipe[0 ],F_SETFL ,O_NONBLOCK /* | O_ASYNC */ ); -#endif fcntl (d->pipe[1 ],F_SETFL ,O_NONBLOCK );fcntl (d->pipe[0 ],F_SETOWN ,getpid ());
kvm-all.c +1 -1
@@ -479,7 +479,7 @@ static int kvm_check_many_ioeventfds(void)* Older kernels have a 6 device limit on the KVM io bus. Find out so we * can avoid creating too many ioeventfds. */ -#if defined(CONFIG_EVENTFD ) && defined(CONFIG_IOTHREAD ) +#if defined(CONFIG_EVENTFD )int ioeventfds[7 ];int i, ret =0 ;for (i =0 ; i <ARRAY_SIZE (ioeventfds); i++) {
qemu-timer.c +0 -53
72 lines not on this page · raw message
vl.c +0 -17
@@ -1438,17 +1438,6 @@ void main_loop_wait(int nonblocking) } -#ifndef CONFIG_IOTHREAD -static int vm_request_pending (void ) -{ -return powerdown_requested || - reset_requested || - shutdown_requested || - debug_requested || - vmstop_requested; -} -#endif -qemu_irq qemu_system_powerdown;static void main_loop (void )
@@ -1462,12 +1451,6 @@ static void main_loop(void)qemu_main_loop_start ();for (;;) { -#ifndef CONFIG_IOTHREAD - nonblocking =cpu_exec_all (); -if (vm_request_pending ()) { - nonblocking = true; - } -#endif #ifdef CONFIG_PROFILER ti =profile_getclock ();#endif
Signature · 1 line
1.7.4.1
Quoted 8 lines · Anthony Liguori
Enabling the I/O thread by default seems like an important part of declaring 1.0. Besides allowing true SMP support with KVM, the I/O thread means that the TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which currently requires a (racey) signal based alarm system.
I know there have been concerns about performance. I think so far the ones that have come up (virtio-net) are most likely due to secondary reasons like decreased batching.
iothread enabled without [1] gives unacceptable performance for ARM emulation (Musicpal board) here. With that series applied, the host CPU load is measurably higher, but no longer excessively.
As that series demonstrates, a major issue for TCG is that the iothread and the VCPU thread run in lock-step, almost nothing is parallelized. At least so far. Paolo and Peter (and to some degree /me) discussed some better TCG treading last Thursday.
Jan
[1] http://thread.gmane.org/gmane.comp.emulators.qemu/99658
Quoted 444 lines
I think we ought to force enabling I/O thread early in 1.0 development and commit to resolving any lingering issues.
Signed-off-by Anthony Liguori <[email protected]>--- configure | 13 ----- cpus.c | 143 ---------------------------------------------------------- hw/qxl.c | 4 -- kvm-all.c | 2 +- qemu-timer.c | 53 --------------------- vl.c | 17 ------- 6 files changed, 1 insertions(+), 231 deletions(-)configure +0
-13@@ -165,7 +165,6 @@ darwin_user="no" bsd_user="no" guest_base="" uname_release="" -io_thread="no" mixemu="no" aix="no" blobs="yes"@@ -722,8 +721,6 @@ for opt do ;; --enable-attr) attr="yes" ;; - --enable-io-thread) io_thread="yes" - ;; --disable-blobs) blobs="no" ;; --with-pkgversion=*) pkgversion=" ($optarg)"@@ -2159,12 +2156,6 @@ EOF if compile_prog "" "" ; then signalfd=yes -elif test "$kvm" = "yes" -a "$io_thread" != "yes"; then - echo - echo "ERROR: Host kernel lacks signalfd() support," - echo "but KVM depends on it when the IO thread is disabled." - echo - exit 1 fi # check if eventfd is supported@@ -2711,7 +2702,6 @@ echo "NPTL support $nptl" echo "GUEST_BASE $guest_base" echo "PIE user targets $user_pie" echo "vde support $vde" -echo "IO thread $io_thread" echo "Linux AIO support $linux_aio" echo "ATTR/XATTR support $attr" echo "Install blobs $blobs"@@ -2969,9 +2959,6 @@ if test "$xen" = "yes" ; then echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak fi -if test "$io_thread" = "yes" ; then - echo "CONFIG_IOTHREAD=y" >> $config_host_mak -fi if test "$linux_aio" = "yes" ; then echo "CONFIG_LINUX_AIO=y" >> $config_host_mak ficpus.c +0
-143@@ -173,12 +173,9 @@ static void cpu_handle_guest_debug(CPUState *env) {gdb_set_stop_cpu (env);qemu_system_debug_request (); -#ifdef CONFIG_IOTHREAD env->stopped =1 ; -#endif } -#ifdef CONFIG_IOTHREAD static void cpu_signal (int sig) {if (cpu_single_env) {@@ -186,7 +183,6 @@ static void cpu_signal(int sig) } exit_request =1 ; } -#endif #ifdef CONFIG_LINUX static void sigbus_reraise (void )@@ -262,12 +258,6 @@ static void qemu_kvm_eat_signals(CPUState *env) exit(1); } }while (sigismember (&chkset,SIG_IPI ) ||sigismember (&chkset,SIGBUS )); - -#ifndef CONFIG_IOTHREAD -if (sigismember (&chkset,SIGIO ) ||sigismember (&chkset,SIGALRM )) { -qemu_notify_event (); - } -#endif }#else /* !CONFIG_LINUX */ @@ -390,7 +380,6 @@ static int qemu_signal_init(void)int sigfd;sigset_t set; -#ifdef CONFIG_IOTHREAD /* SIGUSR2 used by posix-aio-compat.c */ sigemptyset (&set);sigaddset (&set,SIGUSR2 );@@ -409,18 +398,6 @@ static int qemu_signal_init(void)sigaddset (&set,SIGIO );sigaddset (&set,SIGALRM );sigaddset (&set,SIGBUS ); -#else -sigemptyset (&set); -sigaddset (&set,SIGBUS ); -if (kvm_enabled ()) { -/* -* We need to process timer signals synchronously to avoid a race -* between exit_request check and KVM vcpu entry. -*/ -sigaddset (&set,SIGIO ); -sigaddset (&set,SIGALRM ); - } -#endif pthread_sigmask (SIG_BLOCK , &set,NULL ); sigfd =qemu_signalfd (&set);@@ -447,7 +424,6 @@ static void qemu_kvm_init_cpu_signals(CPUState *env) sigact.sa_handler = dummy_signal;sigaction (SIG_IPI , &sigact,NULL ); -#ifdef CONFIG_IOTHREAD pthread_sigmask (SIG_BLOCK ,NULL , &set);sigdelset (&set,SIG_IPI );sigdelset (&set,SIGBUS );@@ -456,17 +432,7 @@ static void qemu_kvm_init_cpu_signals(CPUState *env)fprintf (stderr,"kvm_set_signal_mask: %s\n" ,strerror (-r));exit (1 ); } -#else -sigemptyset (&set); -sigaddset (&set,SIG_IPI ); -sigaddset (&set,SIGIO ); -sigaddset (&set,SIGALRM ); -pthread_sigmask (SIG_BLOCK , &set,NULL ); -pthread_sigmask (SIG_BLOCK ,NULL , &set); -sigdelset (&set,SIGIO ); -sigdelset (&set,SIGALRM ); -#endif sigdelset (&set,SIG_IPI );sigdelset (&set,SIGBUS ); r =kvm_set_signal_mask (env, &set);@@ -478,7 +444,6 @@ static void qemu_kvm_init_cpu_signals(CPUState *env)static void qemu_tcg_init_cpu_signals (void ) { -#ifdef CONFIG_IOTHREAD sigset_t set;struct sigaction sigact;@@ -489,7 +454,6 @@ static void qemu_tcg_init_cpu_signals(void)sigemptyset (&set);sigaddset (&set,SIG_IPI ); pthread_sigmask(SIG_UNBLOCK, &set, NULL); -#endif }#else /* _WIN32 */ @@ -535,106 +499,6 @@ static void qemu_tcg_init_cpu_signals(void) }#endif /* _WIN32 */ -#ifndef CONFIG_IOTHREAD -int qemu_init_main_loop (void ) -{ -int ret; - - ret =qemu_signal_init (); -if (ret) { -return ret; - } - -qemu_init_sigbus (); - -return qemu_event_init (); -} - -void qemu_main_loop_start (void ) -{ -} - -void qemu_init_vcpu (void *_env) -{ -CPUState *env = _env; -int r; - - env->nr_cores = smp_cores; - env->nr_threads = smp_threads; - -if (kvm_enabled ()) { - r =kvm_init_vcpu (env); -if (r <0 ) { -fprintf (stderr,"kvm_init_vcpu failed: %s\n" ,strerror (-r)); -exit (1 ); - } -qemu_kvm_init_cpu_signals (env); - }else { -qemu_tcg_init_cpu_signals (); - } -} - -int qemu_cpu_is_self (void *env) -{ -return 1 ; -} - -void run_on_cpu (CPUState *env,void (*func)(void *data),void *data) -{ -func (data); -} - -void resume_all_vcpus (void ) -{ -} - -void pause_all_vcpus (void ) -{ -} - -void qemu_cpu_kick (void *env) -{ -} - -void qemu_cpu_kick_self (void ) -{ -#ifndef _WIN32 -assert (cpu_single_env); - -raise (SIG_IPI ); -#else -abort (); -#endif -} - -void qemu_notify_event (void ) -{ -CPUState *env = cpu_single_env; - -qemu_event_increment (); -if (env) { -cpu_exit (env); - } -if (next_cpu && env != next_cpu) { -cpu_exit (next_cpu); - } - exit_request =1 ; -} - -void qemu_mutex_lock_iothread (void ) {} -void qemu_mutex_unlock_iothread (void ) {} - -void cpu_stop_current (void ) -{ -} - -void vm_stop (int reason) -{ -do_vm_stop (reason); -} - -#else /* CONFIG_IOTHREAD */ -QemuMutex qemu_global_mutex;static QemuCond qemu_io_proceeded_cond;static bool iothread_requesting_mutex;@@ -1036,8 +900,6 @@ void vm_stop(int reason)do_vm_stop (reason); } -#endif -static int tcg_cpu_exec (CPUState *env) {int ret;@@ -1092,11 +954,6 @@ bool cpu_exec_all(void)qemu_clock_enable (vm_clock, (env->singlestep_enabled &SSTEP_NOTIMER ) ==0 ); -#ifndef CONFIG_IOTHREAD -if (qemu_alarm_pending ()) { -break ; - } -#endif if (cpu_can_run (env)) {if (kvm_enabled ()) { r =kvm_cpu_exec (env);hw/qxl.c +0
-4@@ -1388,11 +1388,7 @@ static void init_pipe_signaling(PCIQXLDevice *d)dprint (d,1 ,"%s: pipe creation failed\n" , __FUNCTION__);return ; } -#ifdef CONFIG_IOTHREAD fcntl (d->pipe[0 ],F_SETFL ,O_NONBLOCK ); -#else -fcntl (d->pipe[0 ],F_SETFL ,O_NONBLOCK /* | O_ASYNC */ ); -#endif fcntl (d->pipe[1 ],F_SETFL ,O_NONBLOCK );fcntl (d->pipe[0 ],F_SETOWN ,getpid ());kvm-all.c +1
-1@@ -479,7 +479,7 @@ static int kvm_check_many_ioeventfds(void)* Older kernels have a 6 device limit on the KVM io bus. Find out so we * can avoid creating too many ioeventfds. */ -#if defined(CONFIG_EVENTFD ) && defined(CONFIG_IOTHREAD ) +#if defined(CONFIG_EVENTFD )int ioeventfds[7 ];int i, ret =0 ;for (i =0 ; i <ARRAY_SIZE (ioeventfds); i++) {qemu-timer.c +0
-53@@ -101,22 +101,6 @@ static int64_t cpu_get_clock(void) } } -#ifndef CONFIG_IOTHREAD -static int64_t qemu_icount_delta (void ) -{ -if (!use_icount) { -return 5000 * (int64_t )1000000 ; - }else if (use_icount ==1 ) { -/* When not using an adaptive execution frequency -we tend to get badly out of sync with real time, -so just delay for a reasonable amount of time. */ -return 0 ; - }else { -return cpu_get_icount () -cpu_get_clock (); - } -} -#endif -/* enable cpu_get_ticks() */ void cpu_enable_ticks (void ) {@@ -688,9 +672,7 @@ void configure_icount(const char *option)if (!option)return ; -#ifdef CONFIG_IOTHREAD vm_clock->warp_timer =qemu_new_timer_ns (rt_clock, icount_warp_rt,NULL ); -#endif if (strcmp (option,"auto" ) !=0 ) { icount_time_shift =strtol (option,NULL ,0 );@@ -1178,41 +1160,6 @@ void quit_timers(void)int qemu_calculate_timeout (void ) { -#ifndef CONFIG_IOTHREAD -int timeout; - -if (!vm_running) - timeout =5000 ; -else { -/* XXX: use timeout computed from timers */ -int64_t add; -int64_t delta; -/* Advance virtual time to the next event. */ - delta =qemu_icount_delta (); -if (delta >0 ) { -/* If virtual time is ahead of real time then just -wait for IO. */ - timeout = (delta +999999 ) /1000000 ; - }else { -/* Wait for either IO to occur or the next -timer event. */ - add =qemu_next_icount_deadline (); -/* We advance the timer before checking for IO. -Limit the amount we advance so that early IO -activity won't get the guest too far ahead. */ -if (add >10000000 ) - add =10000000 ; - delta += add; - qemu_icount +=qemu_icount_round (add); - timeout = delta /1000000 ; -if (timeout <0 ) - timeout =0 ; - } - } - -return timeout; -#else /* CONFIG_IOTHREAD */ return 1000 ; -#endif }vl.c +0
-17@@ -1438,17 +1438,6 @@ void main_loop_wait(int nonblocking) } -#ifndef CONFIG_IOTHREAD -static int vm_request_pending (void ) -{ -return powerdown_requested || - reset_requested || - shutdown_requested || - debug_requested || - vmstop_requested; -} -#endif -qemu_irq qemu_system_powerdown;static void main_loop (void )@@ -1462,12 +1451,6 @@ static void main_loop(void)qemu_main_loop_start ();for (;;) { -#ifndef CONFIG_IOTHREAD - nonblocking =cpu_exec_all (); -if (vm_request_pending ()) { - nonblocking = true; - } -#endif #ifdef CONFIG_PROFILER ti =profile_getclock ();#endif
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 6 lines · Jan Kiszka
Quoted 5 lines · Anthony Liguori
Enabling the I/O thread by default seems like an important part of declaring 1.0. Besides allowing true SMP support with KVM, the I/O thread means that the TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which currently requires a (racey) signal based alarm system.
Quoted 7 lines
Quoted 3 lines
I know there have been concerns about performance. I think so far the ones that have come up (virtio-net) are most likely due to secondary reasons like decreased batching.
iothread enabled without [1] gives unacceptable performance for ARM emulation (Musicpal board) here. With that series applied, the host CPU load is measurably higher, but no longer excessively.
Can you rebase and resubmit? I think there was confusion about which tree they were supposed to go through. I'll apply them directly.
Quoted 5 lines
As that series demonstrates, a major issue for TCG is that the iothread and the VCPU thread run in lock-step, almost nothing is parallelized. At least so far. Paolo and Peter (and to some degree /me) discussed some better TCG treading last Thursday.
I still think we should enable unconditionally. We have a few months to try and improve the situation further.
Fundamentally, using a dedicated VCPU thread is the Right Architecture for TCG so I think we are just delaying the inevitable by leaving it disabled.
Regards,
Anthony Liguori
Quoted 450 lines
Jan
[1] http://thread.gmane.org/gmane.comp.emulators.qemu/99658
Quoted 444 lines
I think we ought to force enabling I/O thread early in 1.0 development and commit to resolving any lingering issues.
Signed-off-by Anthony Liguori<[email protected]>--- configure | 13 ----- cpus.c | 143 ---------------------------------------------------------- hw/qxl.c | 4 -- kvm-all.c | 2 +- qemu-timer.c | 53 --------------------- vl.c | 17 ------- 6 files changed, 1 insertions(+), 231 deletions(-)configure +0
-13@@ -165,7 +165,6 @@ darwin_user="no" bsd_user="no" guest_base="" uname_release="" -io_thread="no" mixemu="no" aix="no" blobs="yes"@@ -722,8 +721,6 @@ for opt do ;; --enable-attr) attr="yes" ;; - --enable-io-thread) io_thread="yes" - ;; --disable-blobs) blobs="no" ;; --with-pkgversion=*) pkgversion=" ($optarg)"@@ -2159,12 +2156,6 @@ EOF if compile_prog "" "" ; then signalfd=yes -elif test "$kvm" = "yes" -a "$io_thread" != "yes"; then - echo - echo "ERROR: Host kernel lacks signalfd() support," - echo "but KVM depends on it when the IO thread is disabled." - echo - exit 1 fi # check if eventfd is supported@@ -2711,7 +2702,6 @@ echo "NPTL support $nptl" echo "GUEST_BASE $guest_base" echo "PIE user targets $user_pie" echo "vde support $vde" -echo "IO thread $io_thread" echo "Linux AIO support $linux_aio" echo "ATTR/XATTR support $attr" echo "Install blobs $blobs"@@ -2969,9 +2959,6 @@ if test "$xen" = "yes" ; then echo "CONFIG_XEN_BACKEND=y">> $config_host_mak echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version">> $config_host_mak fi -if test "$io_thread" = "yes" ; then - echo "CONFIG_IOTHREAD=y">> $config_host_mak -fi if test "$linux_aio" = "yes" ; then echo "CONFIG_LINUX_AIO=y">> $config_host_mak ficpus.c +0
-143@@ -173,12 +173,9 @@ static void cpu_handle_guest_debug(CPUState *env) {gdb_set_stop_cpu (env);qemu_system_debug_request (); -#ifdef CONFIG_IOTHREAD env->stopped =1 ; -#endif } -#ifdef CONFIG_IOTHREAD static void cpu_signal (int sig) {if (cpu_single_env) {@@ -186,7 +183,6 @@ static void cpu_signal(int sig) } exit_request =1 ; } -#endif #ifdef CONFIG_LINUX static void sigbus_reraise (void )@@ -262,12 +258,6 @@ static void qemu_kvm_eat_signals(CPUState *env) exit(1); } }while (sigismember (&chkset,SIG_IPI ) ||sigismember (&chkset,SIGBUS )); - -#ifndef CONFIG_IOTHREAD -if (sigismember (&chkset,SIGIO ) ||sigismember (&chkset,SIGALRM )) { -qemu_notify_event (); - } -#endif }#else /* !CONFIG_LINUX */ @@ -390,7 +380,6 @@ static int qemu_signal_init(void)int sigfd;sigset_t set; -#ifdef CONFIG_IOTHREAD /* SIGUSR2 used by posix-aio-compat.c */ sigemptyset (&set);sigaddset (&set,SIGUSR2 );@@ -409,18 +398,6 @@ static int qemu_signal_init(void)sigaddset (&set,SIGIO );sigaddset (&set,SIGALRM );sigaddset (&set,SIGBUS ); -#else -sigemptyset (&set); -sigaddset (&set,SIGBUS ); -if (kvm_enabled ()) { -/* -* We need to process timer signals synchronously to avoid a race -* between exit_request check and KVM vcpu entry. -*/ -sigaddset (&set,SIGIO ); -sigaddset (&set,SIGALRM ); - } -#endif pthread_sigmask (SIG_BLOCK ,&set,NULL ); sigfd =qemu_signalfd (&set);@@ -447,7 +424,6 @@ static void qemu_kvm_init_cpu_signals(CPUState *env) sigact.sa_handler = dummy_signal;sigaction (SIG_IPI ,&sigact,NULL ); -#ifdef CONFIG_IOTHREAD pthread_sigmask (SIG_BLOCK ,NULL ,&set);sigdelset (&set,SIG_IPI );sigdelset (&set,SIGBUS );@@ -456,17 +432,7 @@ static void qemu_kvm_init_cpu_signals(CPUState *env)fprintf (stderr,"kvm_set_signal_mask: %s\n" ,strerror (-r));exit (1 ); } -#else -sigemptyset (&set); -sigaddset (&set,SIG_IPI ); -sigaddset (&set,SIGIO ); -sigaddset (&set,SIGALRM ); -pthread_sigmask (SIG_BLOCK ,&set,NULL ); -pthread_sigmask (SIG_BLOCK ,NULL ,&set); -sigdelset (&set,SIGIO ); -sigdelset (&set,SIGALRM ); -#endif sigdelset (&set,SIG_IPI );sigdelset (&set,SIGBUS ); r =kvm_set_signal_mask (env,&set);@@ -478,7 +444,6 @@ static void qemu_kvm_init_cpu_signals(CPUState *env)static void qemu_tcg_init_cpu_signals (void ) { -#ifdef CONFIG_IOTHREAD sigset_t set;struct sigaction sigact;@@ -489,7 +454,6 @@ static void qemu_tcg_init_cpu_signals(void)sigemptyset (&set);sigaddset (&set,SIG_IPI ); pthread_sigmask(SIG_UNBLOCK,&set, NULL); -#endif }#else /* _WIN32 */ @@ -535,106 +499,6 @@ static void qemu_tcg_init_cpu_signals(void) }#endif /* _WIN32 */ -#ifndef CONFIG_IOTHREAD -int qemu_init_main_loop (void ) -{ -int ret; - - ret =qemu_signal_init (); -if (ret) { -return ret; - } - -qemu_init_sigbus (); - -return qemu_event_init (); -} - -void qemu_main_loop_start (void ) -{ -} - -void qemu_init_vcpu (void *_env) -{ -CPUState *env = _env; -int r; - - env->nr_cores = smp_cores; - env->nr_threads = smp_threads; - -if (kvm_enabled ()) { - r =kvm_init_vcpu (env); -if (r<0 ) { -fprintf (stderr,"kvm_init_vcpu failed: %s\n" ,strerror (-r)); -exit (1 ); - } -qemu_kvm_init_cpu_signals (env); - }else { -qemu_tcg_init_cpu_signals (); - } -} - -int qemu_cpu_is_self (void *env) -{ -return 1 ; -} - -void run_on_cpu (CPUState *env,void (*func)(void *data),void *data) -{ -func (data); -} - -void resume_all_vcpus (void ) -{ -} - -void pause_all_vcpus (void ) -{ -} - -void qemu_cpu_kick (void *env) -{ -} - -void qemu_cpu_kick_self (void ) -{ -#ifndef _WIN32 -assert (cpu_single_env); - -raise (SIG_IPI ); -#else -abort (); -#endif -} - -void qemu_notify_event (void ) -{ -CPUState *env = cpu_single_env; - -qemu_event_increment (); -if (env) { -cpu_exit (env); - } -if (next_cpu&& env != next_cpu) { -cpu_exit (next_cpu); - } - exit_request =1 ; -} - -void qemu_mutex_lock_iothread (void ) {} -void qemu_mutex_unlock_iothread (void ) {} - -void cpu_stop_current (void ) -{ -} - -void vm_stop (int reason) -{ -do_vm_stop (reason); -} - -#else /* CONFIG_IOTHREAD */ -QemuMutex qemu_global_mutex;static QemuCond qemu_io_proceeded_cond;static bool iothread_requesting_mutex;@@ -1036,8 +900,6 @@ void vm_stop(int reason)do_vm_stop (reason); } -#endif -static int tcg_cpu_exec (CPUState *env) {int ret;@@ -1092,11 +954,6 @@ bool cpu_exec_all(void)qemu_clock_enable (vm_clock, (env->singlestep_enabled&SSTEP_NOTIMER ) ==0 ); -#ifndef CONFIG_IOTHREAD -if (qemu_alarm_pending ()) { -break ; - } -#endif if (cpu_can_run (env)) {if (kvm_enabled ()) { r =kvm_cpu_exec (env);hw/qxl.c +0
-4@@ -1388,11 +1388,7 @@ static void init_pipe_signaling(PCIQXLDevice *d)dprint (d,1 ,"%s: pipe creation failed\n" , __FUNCTION__);return ; } -#ifdef CONFIG_IOTHREAD fcntl (d->pipe[0 ],F_SETFL ,O_NONBLOCK ); -#else -fcntl (d->pipe[0 ],F_SETFL ,O_NONBLOCK /* | O_ASYNC */ ); -#endif fcntl (d->pipe[1 ],F_SETFL ,O_NONBLOCK );fcntl (d->pipe[0 ],F_SETOWN ,getpid ());kvm-all.c +1
-1@@ -479,7 +479,7 @@ static int kvm_check_many_ioeventfds(void)* Older kernels have a 6 device limit on the KVM io bus. Find out so we * can avoid creating too many ioeventfds. */ -#if defined(CONFIG_EVENTFD )&& defined(CONFIG_IOTHREAD ) +#if defined(CONFIG_EVENTFD )int ioeventfds[7 ];int i, ret =0 ;for (i =0 ; i<ARRAY_SIZE (ioeventfds); i++) {qemu-timer.c +0
-53@@ -101,22 +101,6 @@ static int64_t cpu_get_clock(void) } } -#ifndef CONFIG_IOTHREAD -static int64_t qemu_icount_delta (void ) -{ -if (!use_icount) { -return 5000 * (int64_t )1000000 ; - }else if (use_icount ==1 ) { -/* When not using an adaptive execution frequency -we tend to get badly out of sync with real time, -so just delay for a reasonable amount of time. */ -return 0 ; - }else { -return cpu_get_icount () -cpu_get_clock (); - } -} -#endif -/* enable cpu_get_ticks() */ void cpu_enable_ticks (void ) {@@ -688,9 +672,7 @@ void configure_icount(const char *option)if (!option)return ; -#ifdef CONFIG_IOTHREAD vm_clock->warp_timer =qemu_new_timer_ns (rt_clock, icount_warp_rt,NULL ); -#endif if (strcmp (option,"auto" ) !=0 ) { icount_time_shift =strtol (option,NULL ,0 );@@ -1178,41 +1160,6 @@ void quit_timers(void)int qemu_calculate_timeout (void ) { -#ifndef CONFIG_IOTHREAD -int timeout; - -if (!vm_running) - timeout =5000 ; -else { -/* XXX: use timeout computed from timers */ -int64_t add; -int64_t delta; -/* Advance virtual time to the next event. */ - delta =qemu_icount_delta (); -if (delta>0 ) { -/* If virtual time is ahead of real time then just -wait for IO. */ - timeout = (delta +999999 ) /1000000 ; - }else { -/* Wait for either IO to occur or the next -timer event. */ - add =qemu_next_icount_deadline (); -/* We advance the timer before checking for IO. -Limit the amount we advance so that early IO -activity won't get the guest too far ahead. */ -if (add>10000000 ) - add =10000000 ; - delta += add; - qemu_icount +=qemu_icount_round (add); - timeout = delta /1000000 ; -if (timeout<0 ) - timeout =0 ; - } - } - -return timeout; -#else /* CONFIG_IOTHREAD */ return 1000 ; -#endif }vl.c +0
-17@@ -1438,17 +1438,6 @@ void main_loop_wait(int nonblocking) } -#ifndef CONFIG_IOTHREAD -static int vm_request_pending (void ) -{ -return powerdown_requested || - reset_requested || - shutdown_requested || - debug_requested || - vmstop_requested; -} -#endif -qemu_irq qemu_system_powerdown;static void main_loop (void )@@ -1462,12 +1451,6 @@ static void main_loop(void)qemu_main_loop_start ();for (;;) { -#ifndef CONFIG_IOTHREAD - nonblocking =cpu_exec_all (); -if (vm_request_pending ()) { - nonblocking = true; - } -#endif #ifdef CONFIG_PROFILER ti =profile_getclock ();#endif
Quoted 6 lines · Jan Kiszka
Quoted 5 lines · Anthony Liguori
Enabling the I/O thread by default seems like an important part of declaring 1.0. Besides allowing true SMP support with KVM, the I/O thread means that the TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which currently requires a (racey) signal based alarm system.
Quoted 7 lines
Quoted 3 lines
I know there have been concerns about performance. I think so far the ones that have come up (virtio-net) are most likely due to secondary reasons like decreased batching.
iothread enabled without [1] gives unacceptable performance for ARM emulation (Musicpal board) here. With that series applied, the host CPU load is measurably higher, but no longer excessively.
Given that [1] has been applied now, is there any objections to this patch?
Blue, Aurelien?
Regards,
Anthony Liguori
Quoted 455 lines
As that series demonstrates, a major issue for TCG is that the iothread and the VCPU thread run in lock-step, almost nothing is parallelized. At least so far. Paolo and Peter (and to some degree /me) discussed some better TCG treading last Thursday.
Jan
[1] http://thread.gmane.org/gmane.comp.emulators.qemu/99658
Quoted 444 lines
I think we ought to force enabling I/O thread early in 1.0 development and commit to resolving any lingering issues.
Signed-off-by Anthony Liguori<[email protected]>--- configure | 13 ----- cpus.c | 143 ---------------------------------------------------------- hw/qxl.c | 4 -- kvm-all.c | 2 +- qemu-timer.c | 53 --------------------- vl.c | 17 ------- 6 files changed, 1 insertions(+), 231 deletions(-)configure +0
-13@@ -165,7 +165,6 @@ darwin_user="no" bsd_user="no" guest_base="" uname_release="" -io_thread="no" mixemu="no" aix="no" blobs="yes"@@ -722,8 +721,6 @@ for opt do ;; --enable-attr) attr="yes" ;; - --enable-io-thread) io_thread="yes" - ;; --disable-blobs) blobs="no" ;; --with-pkgversion=*) pkgversion=" ($optarg)"@@ -2159,12 +2156,6 @@ EOF if compile_prog "" "" ; then signalfd=yes -elif test "$kvm" = "yes" -a "$io_thread" != "yes"; then - echo - echo "ERROR: Host kernel lacks signalfd() support," - echo "but KVM depends on it when the IO thread is disabled." - echo - exit 1 fi # check if eventfd is supported@@ -2711,7 +2702,6 @@ echo "NPTL support $nptl" echo "GUEST_BASE $guest_base" echo "PIE user targets $user_pie" echo "vde support $vde" -echo "IO thread $io_thread" echo "Linux AIO support $linux_aio" echo "ATTR/XATTR support $attr" echo "Install blobs $blobs"@@ -2969,9 +2959,6 @@ if test "$xen" = "yes" ; then echo "CONFIG_XEN_BACKEND=y">> $config_host_mak echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version">> $config_host_mak fi -if test "$io_thread" = "yes" ; then - echo "CONFIG_IOTHREAD=y">> $config_host_mak -fi if test "$linux_aio" = "yes" ; then echo "CONFIG_LINUX_AIO=y">> $config_host_mak ficpus.c +0
-143@@ -173,12 +173,9 @@ static void cpu_handle_guest_debug(CPUState *env) {gdb_set_stop_cpu (env);qemu_system_debug_request (); -#ifdef CONFIG_IOTHREAD env->stopped =1 ; -#endif } -#ifdef CONFIG_IOTHREAD static void cpu_signal (int sig) {if (cpu_single_env) {@@ -186,7 +183,6 @@ static void cpu_signal(int sig) } exit_request =1 ; } -#endif #ifdef CONFIG_LINUX static void sigbus_reraise (void )@@ -262,12 +258,6 @@ static void qemu_kvm_eat_signals(CPUState *env) exit(1); } }while (sigismember (&chkset,SIG_IPI ) ||sigismember (&chkset,SIGBUS )); - -#ifndef CONFIG_IOTHREAD -if (sigismember (&chkset,SIGIO ) ||sigismember (&chkset,SIGALRM )) { -qemu_notify_event (); - } -#endif }#else /* !CONFIG_LINUX */ @@ -390,7 +380,6 @@ static int qemu_signal_init(void)int sigfd;sigset_t set; -#ifdef CONFIG_IOTHREAD /* SIGUSR2 used by posix-aio-compat.c */ sigemptyset (&set);sigaddset (&set,SIGUSR2 );@@ -409,18 +398,6 @@ static int qemu_signal_init(void)sigaddset (&set,SIGIO );sigaddset (&set,SIGALRM );sigaddset (&set,SIGBUS ); -#else -sigemptyset (&set); -sigaddset (&set,SIGBUS ); -if (kvm_enabled ()) { -/* -* We need to process timer signals synchronously to avoid a race -* between exit_request check and KVM vcpu entry. -*/ -sigaddset (&set,SIGIO ); -sigaddset (&set,SIGALRM ); - } -#endif pthread_sigmask (SIG_BLOCK ,&set,NULL ); sigfd =qemu_signalfd (&set);@@ -447,7 +424,6 @@ static void qemu_kvm_init_cpu_signals(CPUState *env) sigact.sa_handler = dummy_signal;sigaction (SIG_IPI ,&sigact,NULL ); -#ifdef CONFIG_IOTHREAD pthread_sigmask (SIG_BLOCK ,NULL ,&set);sigdelset (&set,SIG_IPI );sigdelset (&set,SIGBUS );@@ -456,17 +432,7 @@ static void qemu_kvm_init_cpu_signals(CPUState *env)fprintf (stderr,"kvm_set_signal_mask: %s\n" ,strerror (-r));exit (1 ); } -#else -sigemptyset (&set); -sigaddset (&set,SIG_IPI ); -sigaddset (&set,SIGIO ); -sigaddset (&set,SIGALRM ); -pthread_sigmask (SIG_BLOCK ,&set,NULL ); -pthread_sigmask (SIG_BLOCK ,NULL ,&set); -sigdelset (&set,SIGIO ); -sigdelset (&set,SIGALRM ); -#endif sigdelset (&set,SIG_IPI );sigdelset (&set,SIGBUS ); r =kvm_set_signal_mask (env,&set);@@ -478,7 +444,6 @@ static void qemu_kvm_init_cpu_signals(CPUState *env)static void qemu_tcg_init_cpu_signals (void ) { -#ifdef CONFIG_IOTHREAD sigset_t set;struct sigaction sigact;@@ -489,7 +454,6 @@ static void qemu_tcg_init_cpu_signals(void)sigemptyset (&set);sigaddset (&set,SIG_IPI ); pthread_sigmask(SIG_UNBLOCK,&set, NULL); -#endif }#else /* _WIN32 */ @@ -535,106 +499,6 @@ static void qemu_tcg_init_cpu_signals(void) }#endif /* _WIN32 */ -#ifndef CONFIG_IOTHREAD -int qemu_init_main_loop (void ) -{ -int ret; - - ret =qemu_signal_init (); -if (ret) { -return ret; - } - -qemu_init_sigbus (); - -return qemu_event_init (); -} - -void qemu_main_loop_start (void ) -{ -} - -void qemu_init_vcpu (void *_env) -{ -CPUState *env = _env; -int r; - - env->nr_cores = smp_cores; - env->nr_threads = smp_threads; - -if (kvm_enabled ()) { - r =kvm_init_vcpu (env); -if (r<0 ) { -fprintf (stderr,"kvm_init_vcpu failed: %s\n" ,strerror (-r)); -exit (1 ); - } -qemu_kvm_init_cpu_signals (env); - }else { -qemu_tcg_init_cpu_signals (); - } -} - -int qemu_cpu_is_self (void *env) -{ -return 1 ; -} - -void run_on_cpu (CPUState *env,void (*func)(void *data),void *data) -{ -func (data); -} - -void resume_all_vcpus (void ) -{ -} - -void pause_all_vcpus (void ) -{ -} - -void qemu_cpu_kick (void *env) -{ -} - -void qemu_cpu_kick_self (void ) -{ -#ifndef _WIN32 -assert (cpu_single_env); - -raise (SIG_IPI ); -#else -abort (); -#endif -} - -void qemu_notify_event (void ) -{ -CPUState *env = cpu_single_env; - -qemu_event_increment (); -if (env) { -cpu_exit (env); - } -if (next_cpu&& env != next_cpu) { -cpu_exit (next_cpu); - } - exit_request =1 ; -} - -void qemu_mutex_lock_iothread (void ) {} -void qemu_mutex_unlock_iothread (void ) {} - -void cpu_stop_current (void ) -{ -} - -void vm_stop (int reason) -{ -do_vm_stop (reason); -} - -#else /* CONFIG_IOTHREAD */ -QemuMutex qemu_global_mutex;static QemuCond qemu_io_proceeded_cond;static bool iothread_requesting_mutex;@@ -1036,8 +900,6 @@ void vm_stop(int reason)do_vm_stop (reason); } -#endif -static int tcg_cpu_exec (CPUState *env) {int ret;@@ -1092,11 +954,6 @@ bool cpu_exec_all(void)qemu_clock_enable (vm_clock, (env->singlestep_enabled&SSTEP_NOTIMER ) ==0 ); -#ifndef CONFIG_IOTHREAD -if (qemu_alarm_pending ()) { -break ; - } -#endif if (cpu_can_run (env)) {if (kvm_enabled ()) { r =kvm_cpu_exec (env);hw/qxl.c +0
-4@@ -1388,11 +1388,7 @@ static void init_pipe_signaling(PCIQXLDevice *d)dprint (d,1 ,"%s: pipe creation failed\n" , __FUNCTION__);return ; } -#ifdef CONFIG_IOTHREAD fcntl (d->pipe[0 ],F_SETFL ,O_NONBLOCK ); -#else -fcntl (d->pipe[0 ],F_SETFL ,O_NONBLOCK /* | O_ASYNC */ ); -#endif fcntl (d->pipe[1 ],F_SETFL ,O_NONBLOCK );fcntl (d->pipe[0 ],F_SETOWN ,getpid ());kvm-all.c +1
-1@@ -479,7 +479,7 @@ static int kvm_check_many_ioeventfds(void)* Older kernels have a 6 device limit on the KVM io bus. Find out so we * can avoid creating too many ioeventfds. */ -#if defined(CONFIG_EVENTFD )&& defined(CONFIG_IOTHREAD ) +#if defined(CONFIG_EVENTFD )int ioeventfds[7 ];int i, ret =0 ;for (i =0 ; i<ARRAY_SIZE (ioeventfds); i++) {qemu-timer.c +0
-53@@ -101,22 +101,6 @@ static int64_t cpu_get_clock(void) } } -#ifndef CONFIG_IOTHREAD -static int64_t qemu_icount_delta (void ) -{ -if (!use_icount) { -return 5000 * (int64_t )1000000 ; - }else if (use_icount ==1 ) { -/* When not using an adaptive execution frequency -we tend to get badly out of sync with real time, -so just delay for a reasonable amount of time. */ -return 0 ; - }else { -return cpu_get_icount () -cpu_get_clock (); - } -} -#endif -/* enable cpu_get_ticks() */ void cpu_enable_ticks (void ) {@@ -688,9 +672,7 @@ void configure_icount(const char *option)if (!option)return ; -#ifdef CONFIG_IOTHREAD vm_clock->warp_timer =qemu_new_timer_ns (rt_clock, icount_warp_rt,NULL ); -#endif if (strcmp (option,"auto" ) !=0 ) { icount_time_shift =strtol (option,NULL ,0 );@@ -1178,41 +1160,6 @@ void quit_timers(void)int qemu_calculate_timeout (void ) { -#ifndef CONFIG_IOTHREAD -int timeout; - -if (!vm_running) - timeout =5000 ; -else { -/* XXX: use timeout computed from timers */ -int64_t add; -int64_t delta; -/* Advance virtual time to the next event. */ - delta =qemu_icount_delta (); -if (delta>0 ) { -/* If virtual time is ahead of real time then just -wait for IO. */ - timeout = (delta +999999 ) /1000000 ; - }else { -/* Wait for either IO to occur or the next -timer event. */ - add =qemu_next_icount_deadline (); -/* We advance the timer before checking for IO. -Limit the amount we advance so that early IO -activity won't get the guest too far ahead. */ -if (add>10000000 ) - add =10000000 ; - delta += add; - qemu_icount +=qemu_icount_round (add); - timeout = delta /1000000 ; -if (timeout<0 ) - timeout =0 ; - } - } - -return timeout; -#else /* CONFIG_IOTHREAD */ return 1000 ; -#endif }vl.c +0
-17@@ -1438,17 +1438,6 @@ void main_loop_wait(int nonblocking) } -#ifndef CONFIG_IOTHREAD -static int vm_request_pending (void ) -{ -return powerdown_requested || - reset_requested || - shutdown_requested || - debug_requested || - vmstop_requested; -} -#endif -qemu_irq qemu_system_powerdown;static void main_loop (void )@@ -1462,12 +1451,6 @@ static void main_loop(void)qemu_main_loop_start ();for (;;) { -#ifndef CONFIG_IOTHREAD - nonblocking =cpu_exec_all (); -if (vm_request_pending ()) { - nonblocking = true; - } -#endif #ifdef CONFIG_PROFILER ti =profile_getclock ();#endif
Am 29.08.2011 um 20:03 schrieb Anthony Liguori:
Quoted 11 lines · Jan Kiszka
Quoted 10 lines · Anthony Liguori
Quoted 8 lines
Enabling the I/O thread by default seems like an important part of declaring 1.0. Besides allowing true SMP support with KVM, the I/O thread means that the TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which currently requires a (racey) signal based alarm system.
I know there have been concerns about performance. I think so far the ones that have come up (virtio-net) are most likely due to secondary reasons like decreased batching.
Quoted 5 lines
Quoted 3 lines
iothread enabled without [1] gives unacceptable performance for ARM emulation (Musicpal board) here. With that series applied, the host CPU load is measurably higher, but no longer excessively.
Given that [1] has been applied now, is there any objections to this patch?
There had been additional patches to fix I/O thread issues on Darwin, have any such fixes been applied the last few weeks?
The patches that I tested some time ago only fixed the non-iothread case reliably.
Andreas
Quoted 21 lines · Andreas Färber
Am 29.08.2011 um 20:03 schrieb Anthony Liguori:
Quoted 19 lines · Jan Kiszka
Quoted 17 lines · Anthony Liguori
Quoted 8 lines
Enabling the I/O thread by default seems like an important part of declaring
1.0. Besides allowing true SMP support with KVM, the I/O thread means that the
TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which
currently requires a (racey) signal based alarm system.Quoted 4 lines
I know there have been concerns about performance. I think so far the ones that
have come up (virtio-net) are most likely due to secondary reasons like decreased batching.iothread enabled without [1] gives unacceptable performance for ARM emulation (Musicpal board) here. With that series applied, the host CPU load is measurably higher, but no longer excessively.
Quoted 5 lines
Quoted 2 lines
Given that [1] has been applied now, is there any objections to this patch?
There had been additional patches to fix I/O thread issues on Darwin, have any such fixes been applied the last few weeks?
I don't see any outstanding Darwin patches in my queue so either they were applied or there were issues with them.
Regards,
Anthony Liguori
Quoted 6 lines
The patches that I tested some time ago only fixed the non-iothread case reliably.
Andreas
Am 29.08.2011 um 22:24 schrieb Anthony Liguori:
Quoted 9 lines · Andreas Färber
Quoted 8 lines
Am 29.08.2011 um 20:03 schrieb Anthony Liguori:
Quoted 6 lines · Jan Kiszka
Quoted 4 lines · Anthony Liguori
Quoted 3 lines
Enabling the I/O thread by default seems like an important part of declaring
1.0.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Given that [1] has been applied now, is there any objections to this patch?
There had been additional patches to fix I/O thread issues on Darwin, have any such fixes been applied the last few weeks?
I don't see any outstanding Darwin patches in my queue so either they were applied or there were issues with them.
Alexandre recalled his series on July 25, I spot neither explanation of what was wrong with it nor a v2. Hope he'll explain.
Andreas
Quoted 14 lines · Andreas Färber
Am 29.08.2011 um 22:24 schrieb Anthony Liguori:
Quoted 12 lines · Andreas Färber
Quoted 11 lines
Am 29.08.2011 um 20:03 schrieb Anthony Liguori:
Quoted 8 lines · Jan Kiszka
Quoted 4 lines · Anthony Liguori
Quoted 3 lines
Enabling the I/O thread by default seems like an important part of declaring
1.0.Given that [1] has been applied now, is there any objections to this patch?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
There had been additional patches to fix I/O thread issues on Darwin, have any such fixes been applied the last few weeks?
I don't see any outstanding Darwin patches in my queue so either they were applied or there were issues with them.
Alexandre recalled his series on July 25, I spot neither explanation of what was wrong with it nor a v2. Hope he'll explain.
If there's uncertainty, I'd prefer to enable it sooner than later. This is a key 1.0 feature IMHO and I'd prefer to have more time to work through any issues.
Regards,
Anthony Liguroi
Quoted 1 line
Andreas
Quoted 21 lines · Anthony Liguori
Quoted 20 lines · Andreas Färber
Am 29.08.2011 um 22:24 schrieb Anthony Liguori:
Quoted 17 lines · Andreas Färber
Quoted 8 lines
Am 29.08.2011 um 20:03 schrieb Anthony Liguori:
Quoted 6 lines · Jan Kiszka
Quoted 4 lines · Anthony Liguori
Quoted 3 lines
Enabling the I/O thread by default seems like an important part of declaring
1.0.Quoted 5 lines
Quoted 2 lines
Given that [1] has been applied now, is there any objections to this patch?
There had been additional patches to fix I/O thread issues on Darwin, have any such fixes been applied the last few weeks?
I don't see any outstanding Darwin patches in my queue so either they were applied or there were issues with them.
Quoted 6 lines
Quoted 2 lines
Alexandre recalled his series on July 25, I spot neither explanation of what was wrong with it nor a v2. Hope he'll explain.
If there's uncertainty, I'd prefer to enable it sooner than later. This is a key 1.0 feature IMHO and I'd prefer to have more time to work through any issues.
What about making --enable-io-thread default as an intermediate step? That would leave --disable-io-thread as temporary workaround until all issues are fixed. The latter could generate a big fat warning that this mode will be removed before 1.0.
Jan
Am 30.08.2011 um 00:42 schrieb Jan Kiszka:
Quoted 25 lines · Anthony Liguori
Quoted 24 lines · Andreas Färber
Quoted 22 lines
Am 29.08.2011 um 22:24 schrieb Anthony Liguori:
Quoted 9 lines · Andreas Färber
Quoted 8 lines
Am 29.08.2011 um 20:03 schrieb Anthony Liguori:
Quoted 6 lines · Jan Kiszka
Quoted 4 lines · Anthony Liguori
Quoted 3 lines
Enabling the I/O thread by default seems like an important part of declaring
1.0.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Given that [1] has been applied now, is there any objections to this patch?
There had been additional patches to fix I/O thread issues on Darwin, have any such fixes been applied the last few weeks?
I don't see any outstanding Darwin patches in my queue so either they were applied or there were issues with them.
Alexandre recalled his series on July 25, I spot neither explanation of what was wrong with it nor a v2. Hope he'll explain.
Quoted 8 lines
Quoted 3 lines
If there's uncertainty, I'd prefer to enable it sooner than later. This is a key 1.0 feature IMHO and I'd prefer to have more time to work through any issues.
What about making --enable-io-thread default as an intermediate step? That would leave --disable-io-thread as temporary workaround until all issues are fixed. The latter could generate a big fat warning that this mode will be removed before 1.0.
Yes please, that proposal sounds much better.
If http://wiki.qemu.org/Planning/1.0 is still up-to-date, we have about six weeks to make I/O thread work everywhere.
Andreas
Quoted 11 lines · Andreas Färber
Am 30.08.2011 um 00:42 schrieb Jan Kiszka:
Quoted 4 lines
What about making --enable-io-thread default as an intermediate step? That would leave --disable-io-thread as temporary workaround until all issues are fixed. The latter could generate a big fat warning that this mode will be removed before 1.0.
Yes please, that proposal sounds much better.
If http://wiki.qemu.org/Planning/1.0 is still up-to-date, we have about six weeks to make I/O thread work everywhere.
I'm not a big fan of just flipping the configure flag. There is other work being held up by disable-io-thread like the timer conversion.
If there aren't known issues, then I want to remove the non-I/O thread code. git history is still there for anyone that wants to test w/o it.
Regards,
Anthony Liguori
Quoted 2 lines
Andreas
Am 30.08.2011 um 21:28 schrieb Anthony Liguori:
Quoted 8 lines · Andreas Färber
Quoted 7 lines
Am 30.08.2011 um 00:42 schrieb Jan Kiszka:
Quoted 4 lines
What about making --enable-io-thread default as an intermediate step? That would leave --disable-io-thread as temporary workaround until all issues are fixed. The latter could generate a big fat warning that this mode will be removed before 1.0.
Quoted 8 lines
Quoted 4 lines
Yes please, that proposal sounds much better.
If http://wiki.qemu.org/Planning/1.0 is still up-to-date, we have about six weeks to make I/O thread work everywhere.
I'm not a big fan of just flipping the configure flag. There is other work being held up by disable-io-thread like the timer conversion.
If there aren't known issues, then I want to remove the non-I/O thread code. git history is still there for anyone that wants to test w/o it.
My problem is that at HEAD *none* of the i386,ppc,sparc guests that used to work about a month ago boot *at all* on my Darwin/ppc64 host.
Might be TCG, might be the new MemoryRegion API, might be (non-)I/O thread. Means a lot of git history testing despite little time. An ultimatum to make things even worse doesn't really help there... ;)
Andreas
Quoted 5 lines · Andreas Färber
Quoted 2 lines
If there aren't known issues, then I want to remove the non-I/O thread code. git history is still there for anyone that wants to test w/o it.
My problem is that at HEAD *none* of the i386,ppc,sparc guests that used to work about a month ago boot *at all* on my Darwin/ppc64 host.
At the moment, SPARC/PPC in HEAD invokes a crashing bug in OpenBIOS because of this commit:
commit c7b488721d6aafe32994ac63f8d690ae6d4729fa
Author: Paolo Bonzini <[email protected]> Date: Wed Aug 3 10:49:18 2011 +0200
scsi: report unit attention on reset
Blue (CC) committed an appropriate fix to OpenBIOS SVN as r1047 but hasn't yet updated the binaries in git which is why the crash still exists. Not sure about the i386 part, although a brief test on a PPC64 Mac running Linux boots the linux-0.2.img.bz2 test image fine here.
ATB,
Mark.
Signature · 7 lines
Mark Cave-Ayland - Senior Technical Architect PostgreSQL - PostGIS Sirius Corporation plc - control through freedom http://www.siriusit.co.uk t: +44 870 608 0063 Sirius Labs: http://www.siriusit.co.uk/labs
Quoted 21 lines · Andreas Färber
Am 30.08.2011 um 21:28 schrieb Anthony Liguori:
Quoted 10 lines · Andreas Färber
Quoted 9 lines
Am 30.08.2011 um 00:42 schrieb Jan Kiszka:
Quoted 4 lines
What about making --enable-io-thread default as an intermediate step? That would leave --disable-io-thread as temporary workaround until all issues are fixed. The latter could generate a big fat warning that this mode will be removed before 1.0.
Yes please, that proposal sounds much better.
Quoted 8 lines
Quoted 2 lines
If http://wiki.qemu.org/Planning/1.0 is still up-to-date, we have about six weeks to make I/O thread work everywhere.
I'm not a big fan of just flipping the configure flag. There is other work being held up by disable-io-thread like the timer conversion.
If there aren't known issues, then I want to remove the non-I/O thread code. git history is still there for anyone that wants to test w/o it.
Quoted 6 lines
My problem is that at HEAD *none* of the i386,ppc,sparc guests that used to work about a month ago boot *at all* on my Darwin/ppc64 host.
Might be TCG, might be the new MemoryRegion API, might be (non-)I/O thread. Means a lot of git history testing despite little time. An ultimatum to make things even worse doesn't really help there... ;)
For a platform to be supported, it needs to be actively maintained and fixed. If there aren't enough folks testing/fixing Darwin/ppc64, then it's not a platform we can reasonable support :-/
Regards,
Anthony Liguori
Quoted 2 lines
Andreas
Quoted 3 lines · Anthony Liguori
For a platform to be supported, it needs to be actively maintained and fixed. If there aren't enough folks testing/fixing Darwin/ppc64, then it's not a platform we can reasonable support :-/
I agree unfortunately. I think personally that Darwin is important (at least Darwin/VNC, I care zero about Cocoa and SDL) because it keeps us honest and avoids introducing unwanted Linux-isms. But if even Windows turns out to work better than Darwin, that is not a good sign.
Still, Andreas, please do try to get a report of how iothread works on Darwin with VNC graphics.
Paolo
Quoted 5 lines · Paolo Bonzini
Quoted 3 lines · Anthony Liguori
For a platform to be supported, it needs to be actively maintained and fixed. If there aren't enough folks testing/fixing Darwin/ppc64, then it's not a platform we can reasonable support :-/
Quoted 7 lines
I agree unfortunately. I think personally that Darwin is important (at least Darwin/VNC, I care zero about Cocoa and SDL) because it keeps us honest and avoids introducing unwanted Linux-isms. But if even Windows turns out to work better than Darwin, that is not a good sign.
Still, Andreas, please do try to get a report of how iothread works on Darwin with VNC graphics.
I've pushed this patch. Please do report how things behave and we can try to fix whatever we can.
Regards,
Anthony Liguori
Quoted 4 lines
Paolo
Quoted 4 lines · Anthony Liguori
Enabling the I/O thread by default seems like an important part of declaring 1.0. Besides allowing true SMP support with KVM, the I/O thread means that the TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which currently requires a (racey) signal based alarm system.
Even with iothread it's still signal based (and still racy) -- the only way to get a thread currently executing TCG code to stop doing so is to send it a signal.
-- PMM
Quoted 8 lines · Peter Maydell
Quoted 4 lines
Enabling the I/O thread by default seems like an important part of declaring 1.0. Besides allowing true SMP support with KVM, the I/O thread means that the TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which currently requires a (racey) signal based alarm system.
Even with iothread it's still signal based (and still racy) -- the only way to get a thread currently executing TCG code to stop doing so is to send it a signal.
It's signal-based, but I'm not sure it's racy when single-threaded. This:
/* ... tb_add_jump ... */
barrier();
if (likely(!env->exit_request)) {in cpu_exec, vs. this in the signal handler:
void cpu_exit(CPUState *env)
{
env->exit_request = 1;
cpu_unlink_tb(env);
}together will make sure that only a single basic block is executed after an exit request.
The problems with user-level emulation arise from multiple threads concurrently execute the tb_add_jump or cpu_unlink_tb operations. My knowledge of user-level emulation is approximately zero, but I think it should be possible to make the race outcome predictable. That's because (1) cpu_unlink_tb is idempotent; (2) you don't really need to do anything in cpu_unlink_tb if the other thread is running tb_add_jump, because setting env->exit_request will avoid entering the CPU.
Paolo
Quoted 27 lines · Paolo Bonzini
Quoted 8 lines · Peter Maydell
Quoted 4 lines
Enabling the I/O thread by default seems like an important part of declaring 1.0. Besides allowing true SMP support with KVM, the I/O thread means that the TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which currently requires a (racey) signal based alarm system.
Even with iothread it's still signal based (and still racy) -- the only way to get a thread currently executing TCG code to stop doing so is to send it a signal.
It's signal-based, but I'm not sure it's racy when single-threaded. This:
/* ... tb_add_jump ... */ barrier(); if (likely(!env->exit_request)) {in
cpu_exec, vs. this in the signal handler:void cpu_exit(CPUState *env) { env->exit_request = 1; cpu_unlink_tb(env); }together will make sure that only a single basic block is executed after an exit request.
Quoted 7 lines
The problems with user-level emulation arise from multiple threads concurrently execute the
tb_add_jumporcpu_unlink_tboperations. My knowledge of user-level emulation is approximately zero, but I think it should be possible to make the race outcome predictable. That's because
(1)cpu_unlink_tbis idempotent; (2) you don't really need to do anything incpu_unlink_tbif the other thread is runningtb_add_jump, because settingenv->exit_requestwill avoid entering the CPU.
Current multi-threaded user mode emulation is just (too) optimistically designed. But once VCPUs start to use their own TBs and/or TB chains (maybe it can be beneficial to decouple the translation buffer from the linking), this problem should go away.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 13 lines · Paolo Bonzini
Quoted 3 lines · Peter Maydell
Even with iothread it's still signal based (and still racy) -- the only way to get a thread currently executing TCG code to stop doing so is to send it a signal.
It's signal-based, but I'm not sure it's racy when single-threaded. This:
/* ...
tb_add_jump... */
barrier();
if (likely(!env->exit_request)) {in
cpu_exec, vs. this in the signal handler:
Quoted 8 lines
void
cpu_exit(CPUState *env)
{
env->exit_request = 1;
cpu_unlink_tb(env);
}together will make sure that only a single basic block is executed after an exit request.
If the cpu thread is in the middle of tb_add_jump() (updating the jmp_next[] circular list) when the signal fires, cpu_unlink_tb() will also try to modify the same list and corrupt things.
(Also an arbitrary number of basic blocks may be executed because it's (in theory) possible for the cpu thread to stay one jump ahead of the thread running cpu_unlink_tb(). This is why cpu_unlink_tb() has to traverse the entire tb graph from the current tb unlinking things rather than only operating on the current tb. In practice of course only one or two tbs will be executed.)
Quoted 7 lines
The problems with user-level emulation arise from multiple threads concurrently execute the
tb_add_jumporcpu_unlink_tboperations. My knowledge of user-level emulation is approximately zero, but I think it should be possible to make the race outcome predictable. That's because (1)cpu_unlink_tbis idempotent; (2) you don't really need to do anything incpu_unlink_tbif the other thread is runningtb_add_jump, because settingenv->exit_requestwill avoid entering the CPU.
Yeah, but we don't actually do enough locking or other cleverness at this point, which is why it's racy.
(I think that cpu_unlink_tb() is just fundamentally too much work to be doing in a signal handler...)
Anyway, dropping non-iothread will reduce the number of configurations we have to reason about in fixing this kind of thing, which is a good thing.
-- PMM
Quoted 9 lines · Peter Maydell
Quoted 4 lines · Anthony Liguori
Enabling the I/O thread by default seems like an important part of declaring 1.0. Besides allowing true SMP support with KVM, the I/O thread means that the TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which currently requires a (racey) signal based alarm system.
Even with iothread it's still signal based (and still racy) -- the only way to get a thread currently executing TCG code to stop doing so is to send it a signal.
What I meant is that we use SIGALRM to effectively do preemptive multiple tasking between the VCPU thread and the I/O thread.
We still need to use signals with the I/O thread because we run the two in lock step. The race I was referring to with SIGALRM has to do with a guest disabling timer interrupts and any other event source. It'll cause a live lock in TCG.
The only way to fix this is by moving to the I/O thread or setting SIGIO on every fd. Since every fd doesn't support SIGIO, I/O thread is really the only correct solution.
Regards,
Anthony Liguori
Quoted 3 lines
-- PMM