Re: [Qemu-devel] [RFC PATCH v0] spapr: Disable CPU unplug in TCG mode

2016-09-29 Thread Bharata B Rao
On Wed, Sep 21, 2016 at 03:31:00PM +1000, David Gibson wrote:
> On Wed, Sep 21, 2016 at 10:18:00AM +0530, Bharata B Rao wrote:
> > CPU unplug doesn't work in TCG mode currently and causes frequent system
> > freeze. In addition to other potential problems, the main problem arises
> > of out the requirement to support synchronous removal of a CPU thread.
> > The CPU thread that performs the cleanup of the unplugged CPU, kicks and
> > waits for the unplugged CPU thread to finish. This wait never finishes in
> > TCG mode when the waiting thread and the unplugged CPU thread are one and
> > the same.
> > 
> > So wait till proper MTTCG support is available before enabling
> > CPU unplug in TCG mode.
> 
> MTTCG seems like a very big hammer to fix this with.  Surely we could
> come up with a simpler interlock that would work for TCG in the
> meantime.

The following hack fixes the issue mostly. I still see some occasional
hangs which points to other potential problems.

diff --git a/cpus.c b/cpus.c
index 8ad1eb4..7dc7d09 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1526,8 +1526,13 @@ void cpu_remove(CPUState *cpu)
 void cpu_remove_sync(CPUState *cpu)
 {
 cpu_remove(cpu);
-while (cpu->created) {
-qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
+if (!kvm_enabled()) {
+qemu_tcg_destroy_vcpu(cpu);
+cpu->created = false;
+} else {
+while (cpu->created) {
+qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
+}
 }
 }
 
@@ -1573,6 +1578,9 @@ static void qemu_tcg_init_vcpu(CPUState *cpu)
 /* For non-MTTCG cases we share the thread */
 cpu->thread = single_tcg_cpu_thread;
 cpu->halt_cond = single_tcg_halt_cond;
+cpu->thread_id = first_cpu->thread_id;
+cpu->created = true;
+cpu->can_do_io = 1;
 }
 }
 
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index dc058e5..9558fc9 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -244,6 +244,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, 
sPAPRMachineState *spapr,
 CPUPPCState *env = &cpu->env;
 
 cs->halted = 1;
+cs->stop = true;
 qemu_cpu_kick(cs);
 /*
  * While stopping a CPU, the guest calls H_CPPR which

This is however on Alex's MTTCG tree, I need to figure out which are
the fixes that are relavent from Alex's tree to get CPU unplug working
in TCG mode.

Regards,
Bharata.




Re: [Qemu-devel] [RFC PATCH v0] spapr: Disable CPU unplug in TCG mode

2016-09-20 Thread David Gibson
On Wed, Sep 21, 2016 at 10:18:00AM +0530, Bharata B Rao wrote:
> CPU unplug doesn't work in TCG mode currently and causes frequent system
> freeze. In addition to other potential problems, the main problem arises
> of out the requirement to support synchronous removal of a CPU thread.
> The CPU thread that performs the cleanup of the unplugged CPU, kicks and
> waits for the unplugged CPU thread to finish. This wait never finishes in
> TCG mode when the waiting thread and the unplugged CPU thread are one and
> the same.
> 
> So wait till proper MTTCG support is available before enabling
> CPU unplug in TCG mode.

MTTCG seems like a very big hammer to fix this with.  Surely we could
come up with a simpler interlock that would work for TCG in the
meantime.

> 
> Signed-off-by: Bharata B Rao 
> ---
>  hw/ppc/spapr.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index ca77bb0..d7864c6 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2300,6 +2300,10 @@ static void spapr_machine_device_unplug(HotplugHandler 
> *hotplug_dev,
>  error_setg(errp, "CPU hot unplug not supported on this machine");
>  return;
>  }
> +if (!kvm_enabled()) {
> +error_setg(errp, "CPU hot unplug not supported in TCG mode");
> +return;
> +}
>  spapr_core_unplug(hotplug_dev, dev, errp);
>  }
>  }

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [Qemu-devel] [RFC PATCH v0] spapr: Disable CPU unplug in TCG mode

2016-09-20 Thread Fam Zheng
On Tue, 09/20 22:02, no-re...@ec2-52-6-146-230.compute-1.amazonaws.com wrote:
>   BUILD fedora
>   ARCHIVE qemu.tgz
>   ARCHIVE dtc.tgz
>   COPY RUNNER
>   RUN test-mingw in fedora
> tests/docker/Makefile.include:107: recipe for target 
> 'docker-run-test-mingw@fedora' failed
> make: *** [docker-run-test-mingw@fedora] Error 137

Sorry for the false alarm, I think this is a test server problem.

Fam



Re: [Qemu-devel] [RFC PATCH v0] spapr: Disable CPU unplug in TCG mode

2016-09-20 Thread no-reply
Hi,

Your series failed automatic build test. Please find the testing commands and
their output below. If you have docker installed, you can probably reproduce it
locally.

Type: series
Message-id: 1474433280-25652-1-git-send-email-bhar...@linux.vnet.ibm.com
Subject: [Qemu-devel] [RFC PATCH v0] spapr: Disable CPU unplug in TCG mode

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
make J=8 docker-test-quick@centos6
make J=8 docker-test-mingw@fedora
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
4bcbc83 spapr: Disable CPU unplug in TCG mode

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into 'dtc'...
Submodule path 'dtc': checked out '65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf'
  BUILD centos6
  ARCHIVE qemu.tgz
  ARCHIVE dtc.tgz
  COPY RUNNER
  RUN test-quick in centos6
No C++ compiler available; disabling C++ specific optional code
Install prefix/tmp/qemu-test/src/tests/docker/install
BIOS directory/tmp/qemu-test/src/tests/docker/install/share/qemu
binary directory  /tmp/qemu-test/src/tests/docker/install/bin
library directory /tmp/qemu-test/src/tests/docker/install/lib
module directory  /tmp/qemu-test/src/tests/docker/install/lib/qemu
libexec directory /tmp/qemu-test/src/tests/docker/install/libexec
include directory /tmp/qemu-test/src/tests/docker/install/include
config directory  /tmp/qemu-test/src/tests/docker/install/etc
local state directory   /tmp/qemu-test/src/tests/docker/install/var
Manual directory  /tmp/qemu-test/src/tests/docker/install/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path   /tmp/qemu-test/src
C compilercc
Host C compiler   cc
C++ compiler  
Objective-C compiler cc
ARFLAGS   rv
CFLAGS-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -pthread 
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -g 
QEMU_CFLAGS   -I/usr/include/pixman-1-fPIE -DPIE -m64 -D_GNU_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes 
-Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes 
-fno-strict-aliasing -fno-common -fwrapv  -Wendif-labels -Wmissing-include-dirs 
-Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self 
-Wignored-qualifiers -Wold-style-declaration -Wold-style-definition 
-Wtype-limits -fstack-protector-all
LDFLAGS   -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g 
make  make
install   install
pythonpython -B
smbd  /usr/sbin/smbd
module supportno
host CPU  x86_64
host big endian   no
target list   x86_64-softmmu aarch64-softmmu
tcg debug enabled no
gprof enabled no
sparse enabledno
strip binariesyes
profiler  no
static build  no
pixmansystem
SDL support   yes (1.2.14)
GTK support   no 
GTK GL supportno
VTE support   no 
TLS priority  NORMAL
GNUTLS supportno
GNUTLS rndno
libgcrypt no
libgcrypt kdf no
nettleno 
nettle kdfno
libtasn1  no
curses supportno
virgl support no
curl support  no
mingw32 support   no
Audio drivers oss
Block whitelist (rw) 
Block whitelist (ro) 
VirtFS supportno
VNC support   yes
VNC SASL support  no
VNC JPEG support  no
VNC PNG support   no
xen support   no
brlapi supportno
bluez  supportno
Documentation no
PIE   yes
vde support   no
netmap supportno
Linux AIO support no
ATTR/XATTR support yes
Install blobs yes
KVM support   yes
RDMA support  no
TCG interpreter   no
fdt support   yes
preadv supportyes
fdatasync yes
madvise   yes
posix_madvise yes
uuid support  no
libcap-ng support no
vhost-net support yes
vhost-scsi support yes
vhost-vsock support yes
Trace backendslog
spice support no 
rbd support   no
xfsctl supportno
smartcard support no
libusbno
usb net redir no
OpenGL supportno
OpenGL dmabufsno
libiscsi support  no
libnfs supportno
build guest agent yes
QGA VSS support   no
QGA w32 disk info no
QGA MSI support   no
seccomp support   no
coroutine backend ucontext
coroutine poolyes
GlusterFS support no
Archipelago support no
gcov  gcov
gcov enabled  no
TPM support   yes
libssh2 support   no
TPM passthrough   yes
QOM debugging yes
vhdx  no
lzo support   no
snappy supportno
bzip2 support no
NUMA host support no
tcmalloc support  no
jemalloc support  no
avx2 optimization no
replication support yes
  GEN   x86_64-softmmu/config-devices.mak.tmp
  GEN   aarch64-softmmu/config-devices.mak.tmp
  GEN   config-host.h
  GEN   qemu-options.def
  GEN   qmp-commands.h
  GEN   qapi-types.h
  GEN   qapi-visit.h
  GEN   qapi-event.h
  GEN   x86_64-softmmu/config-devices.mak
  GEN   aarch

[Qemu-devel] [RFC PATCH v0] spapr: Disable CPU unplug in TCG mode

2016-09-20 Thread Bharata B Rao
CPU unplug doesn't work in TCG mode currently and causes frequent system
freeze. In addition to other potential problems, the main problem arises
of out the requirement to support synchronous removal of a CPU thread.
The CPU thread that performs the cleanup of the unplugged CPU, kicks and
waits for the unplugged CPU thread to finish. This wait never finishes in
TCG mode when the waiting thread and the unplugged CPU thread are one and
the same.

So wait till proper MTTCG support is available before enabling
CPU unplug in TCG mode.

Signed-off-by: Bharata B Rao 
---
 hw/ppc/spapr.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index ca77bb0..d7864c6 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2300,6 +2300,10 @@ static void spapr_machine_device_unplug(HotplugHandler 
*hotplug_dev,
 error_setg(errp, "CPU hot unplug not supported on this machine");
 return;
 }
+if (!kvm_enabled()) {
+error_setg(errp, "CPU hot unplug not supported in TCG mode");
+return;
+}
 spapr_core_unplug(hotplug_dev, dev, errp);
 }
 }
-- 
2.7.4