Skip to contentSkip to conversation

kvm tools: Move -O2 back to CFLAGS

PATCH In review Asias He 2 participants 3 messages Sep 12, 2012 KVM

lore
Share & tools
lore

Asias He

author
#0 lore raw

PATCH 1/2 kvm tools: Move -O2 back to CFLAGS

commit 06e66483d54e58eca70abc52ca74f1489226cdbe
chagned to -O0 accidentally. Change it back.

---
 tools/kvm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/kvm/Makefile +1 -1
index efa3d4f..0e2fa66 100644
@@ -243,7 +243,7 @@ DEFINES	+= -DKVMTOOLS_VERSION='"$(KVMTOOLS_VERSION)"'
 DEFINES	+= -DBUILD_ARCH='"$(ARCH)"'
 
 KVM_INCLUDE := include
-CFLAGS	+= $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I$(ARCH_INCLUDE) -I$(KINCL_PATH)/include -I$(KINCL_PATH)/arch/$(ARCH)/include/ -O0 -fno-strict-aliasing -g -flto
+CFLAGS	+= $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I$(ARCH_INCLUDE) -I$(KINCL_PATH)/include -I$(KINCL_PATH)/arch/$(ARCH)/include/ -O2 -fno-strict-aliasing -g -flto
 
 WARNINGS += -Wall
 WARNINGS += -Wcast-align
Signature · 1 line
1.7.11.4
author
#1 lore raw

PATCH 2/2 kvm tools: Bring SMP back

We have this currently:

kvm__init()

      kvm__arch_setup_firmware()
         mptable__init()
            using kvm->nrcpus

kvm_cpu__init()

      kvm->nrcpus = kvm->cfg.nrcpus

kvm->nrcpus is used in mptable__init() before it is initialized, so mptable__init() will setup a wrong mp table.

Before:

$ ./lkvm -c 4
$ cat /proc/cpuinfo |grep ^processor|wc -l
1

After:

$ ./lkvm -c 4
$ cat /proc/cpuinfo |grep ^processor|wc -l
4
---
 tools/kvm/builtin-run.c | 7 -------
 tools/kvm/kvm.c         | 6 ++++++
 2 files changed, 6 insertions(+), 7 deletions(-)
tools/kvm/builtin-run.c +0 -7
index 5ddffaa..790b496 100644
@@ -656,19 +656,12 @@ static int kvm_cmd_run_init(int argc, const char **argv)
 		goto fail;
 	}
 
-
 	r = ioeventfd__init(kvm);
 	if (r < 0) {
 		pr_err("ioeventfd__init() failed with error %d\n", r);
 		goto fail;
 	}
 
-	r = kvm_cpu__init(kvm);
-	if (r < 0) {
-		pr_err("kvm_cpu__init() failed with error %d\n", r);
-		goto fail;
-	}
-
 	r = irq__init(kvm);
 	if (r < 0) {
 		pr_err("irq__init() failed with error %d\n", r);
tools/kvm/kvm.c +6 -0
index cca2e93..4fdad92 100644
@@ -248,6 +248,12 @@ int kvm__init(struct kvm *kvm)
 
 	kvm__init_ram(kvm);
 
+	ret = kvm_cpu__init(kvm);
+	if (ret < 0) {
+		pr_err("kvm_cpu__init() failed with error %d\n", ret);
+		goto err_vm_fd;
+	}
+
 	if (!kvm->cfg.firmware_filename) {
 		if (!kvm__load_kernel(kvm, kvm->cfg.kernel_filename,
 				kvm->cfg.initrd_filename, kvm->cfg.real_cmdline, kvm->cfg.vidmode))
Signature · 1 line
1.7.11.4
#2 lore raw

Re: [PATCH 2/2] kvm tools: Bring SMP back

Quoted 18 lines · Asias He

We have this currently:

   kvm__init()
      kvm__arch_setup_firmware()
         mptable__init()
            using kvm->nrcpus

   kvm_cpu__init()
      kvm->nrcpus = kvm->cfg.nrcpus

kvm->nrcpus is used in mptable__init() before it is initialized, so mptable__init() will setup a wrong mp table.

Before:

$ ./lkvm -c 4
$ cat /proc/cpuinfo |grep ^processor|wc -l
1
Quoted 6 lines

After:

$ ./lkvm -c 4
$ cat /proc/cpuinfo |grep ^processor|wc -l
4

Good catch!