public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [2/2] Moving kvm_vcpu_cache to x86.c
@ 2007-11-29  8:16 Zhang, Xiantao
       [not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA394B5-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang, Xiantao @ 2007-11-29  8:16 UTC (permalink / raw)
  To: avi-atKUWr5tajBWk0Htik3J/w
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	carsteno-tA70FqPdS9bQT0dZR+AlfA, hollisb-r/Jw6+rmf7HQT0dZR+AlfA

[-- Attachment #1: Type: text/plain, Size: 4251 bytes --]

From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Date: Thu, 29 Nov 2007 15:45:57 +0800
Subject: [PATCH] Moving kvm_vcpu_cache to x86.c.
Moving kvm_vcpu_cache to x86.c, since only x86 platform will
use to align the memory area for fx_save.
Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/kvm/kvm.h      |    3 ++-
 drivers/kvm/kvm_main.c |   17 +----------------
 drivers/kvm/x86.c      |   19 ++++++++++++++++++-
 3 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index be18620..b2545c8 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -456,7 +456,8 @@ int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu
*vcpu,
 				    struct kvm_debug_guest *dbg);
 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run
*kvm_run);
 
-int kvm_arch_init(void *opaque);
+int kvm_arch_init(void *opaque, unsigned int vcpu_size,
+				struct module * module);
 void kvm_arch_exit(void);
 
 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index a6fbe6b..687ef98 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -56,9 +56,6 @@ LIST_HEAD(vm_list);
 
 static cpumask_t cpus_hardware_enabled;
 
-struct kmem_cache *kvm_vcpu_cache;
-EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
-
 static __read_mostly struct preempt_ops kvm_preempt_ops;
 
 static struct dentry *debugfs_dir;
@@ -1338,7 +1335,7 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
 
 	kvm_init_debug();
 
-	r = kvm_arch_init(opaque);
+	r = kvm_arch_init(opaque, vcpu_size, module);
 	if (r)
 		goto out_fail;
 
@@ -1375,15 +1372,6 @@ int kvm_init(void *opaque, unsigned int
vcpu_size,
 	if (r)
 		goto out_free_4;
 
-	/* A kmem cache lets us meet the alignment requirements of
fx_save. */
-	kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size,
-					   __alignof__(struct kvm_vcpu),
-					   0, NULL);
-	if (!kvm_vcpu_cache) {
-		r = -ENOMEM;
-		goto out_free_5;
-	}
-
 	kvm_chardev_ops.owner = module;
 
 	r = misc_register(&kvm_dev);
@@ -1398,8 +1386,6 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
 	return 0;
 
 out_free:
-	kmem_cache_destroy(kvm_vcpu_cache);
-out_free_5:
 	sysdev_unregister(&kvm_sysdev);
 out_free_4:
 	sysdev_class_unregister(&kvm_sysdev_class);
@@ -1423,7 +1409,6 @@ EXPORT_SYMBOL_GPL(kvm_init);
 void kvm_exit(void)
 {
 	misc_deregister(&kvm_dev);
-	kmem_cache_destroy(kvm_vcpu_cache);
 	sysdev_unregister(&kvm_sysdev);
 	sysdev_class_unregister(&kvm_sysdev_class);
 	unregister_reboot_notifier(&kvm_reboot_notifier);
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index c70ac33..b8a1b52 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -48,6 +48,10 @@
 
 struct kvm_x86_ops *kvm_x86_ops;
 
+struct kmem_cache *kvm_vcpu_cache;
+EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
+
+
 struct kvm_stats_debugfs_item debugfs_entries[] = {
 	{ "pf_fixed", VCPU_STAT(pf_fixed) },
 	{ "pf_guest", VCPU_STAT(pf_guest) },
@@ -1997,7 +2001,8 @@ int kvm_emulate_pio_string(struct kvm_vcpu *vcpu,
struct kvm_run *run, int in,
 }
 EXPORT_SYMBOL_GPL(kvm_emulate_pio_string);
 
-int kvm_arch_init(void *opaque)
+int kvm_arch_init(void *opaque, unsigned int vcpu_size,
+			struct module *module)
 {
 	int r;
 	struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
@@ -2006,6 +2011,15 @@ int kvm_arch_init(void *opaque)
 	if (r)
 		goto out_fail;
 
+	/* A kmem cache lets us meet the alignment requirements of
fx_save. */
+	kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size,
+					   __alignof__(struct kvm_vcpu),
+					   0, NULL);
+	if (!kvm_vcpu_cache) {
+		r = -ENOMEM;
+		goto out_free;
+	}
+
 	kvm_init_msr_list();
 
 	if (kvm_x86_ops) {
@@ -2030,6 +2044,8 @@ int kvm_arch_init(void *opaque)
 	return 0;
 
 out:
+	kmem_cache_destroy(kvm_vcpu_cache);
+out_free:
 	kvm_mmu_module_exit();
 out_fail:
 	return r;
@@ -2039,6 +2055,7 @@ void kvm_arch_exit(void)
 {
 	kvm_x86_ops = NULL;
 	kvm_mmu_module_exit();
+	kmem_cache_destroy(kvm_vcpu_cache);
 }
 
 int kvm_emulate_halt(struct kvm_vcpu *vcpu)
-- 
1.5.1.2

[-- Attachment #2: 0002-Moving-kvm_vcpu_cache-to-x86.c.patch --]
[-- Type: application/octet-stream, Size: 4115 bytes --]

From cdcfa8c208347a8540ca8a4bc25c0bdc7b96f4fa Mon Sep 17 00:00:00 2001
From: Zhang Xiantao <xiantao.zhang@intel.com>
Date: Thu, 29 Nov 2007 15:45:57 +0800
Subject: [PATCH] Moving kvm_vcpu_cache to x86.c.
Moving kvm_vcpu_cache to x86.c, since only x86 platform will
use to align the memory area for fx_save.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
---
 drivers/kvm/kvm.h      |    3 ++-
 drivers/kvm/kvm_main.c |   17 +----------------
 drivers/kvm/x86.c      |   19 ++++++++++++++++++-
 3 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index be18620..b2545c8 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -456,7 +456,8 @@ int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu,
 				    struct kvm_debug_guest *dbg);
 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
 
-int kvm_arch_init(void *opaque);
+int kvm_arch_init(void *opaque, unsigned int vcpu_size,
+				struct module * module);
 void kvm_arch_exit(void);
 
 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index a6fbe6b..687ef98 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -56,9 +56,6 @@ LIST_HEAD(vm_list);
 
 static cpumask_t cpus_hardware_enabled;
 
-struct kmem_cache *kvm_vcpu_cache;
-EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
-
 static __read_mostly struct preempt_ops kvm_preempt_ops;
 
 static struct dentry *debugfs_dir;
@@ -1338,7 +1335,7 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
 
 	kvm_init_debug();
 
-	r = kvm_arch_init(opaque);
+	r = kvm_arch_init(opaque, vcpu_size, module);
 	if (r)
 		goto out_fail;
 
@@ -1375,15 +1372,6 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
 	if (r)
 		goto out_free_4;
 
-	/* A kmem cache lets us meet the alignment requirements of fx_save. */
-	kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size,
-					   __alignof__(struct kvm_vcpu),
-					   0, NULL);
-	if (!kvm_vcpu_cache) {
-		r = -ENOMEM;
-		goto out_free_5;
-	}
-
 	kvm_chardev_ops.owner = module;
 
 	r = misc_register(&kvm_dev);
@@ -1398,8 +1386,6 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
 	return 0;
 
 out_free:
-	kmem_cache_destroy(kvm_vcpu_cache);
-out_free_5:
 	sysdev_unregister(&kvm_sysdev);
 out_free_4:
 	sysdev_class_unregister(&kvm_sysdev_class);
@@ -1423,7 +1409,6 @@ EXPORT_SYMBOL_GPL(kvm_init);
 void kvm_exit(void)
 {
 	misc_deregister(&kvm_dev);
-	kmem_cache_destroy(kvm_vcpu_cache);
 	sysdev_unregister(&kvm_sysdev);
 	sysdev_class_unregister(&kvm_sysdev_class);
 	unregister_reboot_notifier(&kvm_reboot_notifier);
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index c70ac33..b8a1b52 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -48,6 +48,10 @@
 
 struct kvm_x86_ops *kvm_x86_ops;
 
+struct kmem_cache *kvm_vcpu_cache;
+EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
+
+
 struct kvm_stats_debugfs_item debugfs_entries[] = {
 	{ "pf_fixed", VCPU_STAT(pf_fixed) },
 	{ "pf_guest", VCPU_STAT(pf_guest) },
@@ -1997,7 +2001,8 @@ int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
 }
 EXPORT_SYMBOL_GPL(kvm_emulate_pio_string);
 
-int kvm_arch_init(void *opaque)
+int kvm_arch_init(void *opaque, unsigned int vcpu_size,
+			struct module *module)
 {
 	int r;
 	struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
@@ -2006,6 +2011,15 @@ int kvm_arch_init(void *opaque)
 	if (r)
 		goto out_fail;
 
+	/* A kmem cache lets us meet the alignment requirements of fx_save. */
+	kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size,
+					   __alignof__(struct kvm_vcpu),
+					   0, NULL);
+	if (!kvm_vcpu_cache) {
+		r = -ENOMEM;
+		goto out_free;
+	}
+
 	kvm_init_msr_list();
 
 	if (kvm_x86_ops) {
@@ -2030,6 +2044,8 @@ int kvm_arch_init(void *opaque)
 	return 0;
 
 out:
+	kmem_cache_destroy(kvm_vcpu_cache);
+out_free:
 	kvm_mmu_module_exit();
 out_fail:
 	return r;
@@ -2039,6 +2055,7 @@ void kvm_arch_exit(void)
 {
 	kvm_x86_ops = NULL;
 	kvm_mmu_module_exit();
+	kmem_cache_destroy(kvm_vcpu_cache);
 }
 
 int kvm_emulate_halt(struct kvm_vcpu *vcpu)
-- 
1.5.1.2


[-- Attachment #3: Type: text/plain, Size: 309 bytes --]

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] [2/2] Moving kvm_vcpu_cache to x86.c
       [not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA394B5-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-11-29 12:21   ` Carsten Otte
  2007-11-30  7:41   ` Avi Kivity
  1 sibling, 0 replies; 4+ messages in thread
From: Carsten Otte @ 2007-11-29 12:21 UTC (permalink / raw)
  To: Zhang, Xiantao
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	carsteno-tA70FqPdS9bQT0dZR+AlfA, hollisb-r/Jw6+rmf7HQT0dZR+AlfA,
	avi-atKUWr5tajBWk0Htik3J/w

Zhang, Xiantao wrote:
> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Thu, 29 Nov 2007 15:45:57 +0800
> Subject: [PATCH] Moving kvm_vcpu_cache to x86.c.
> Moving kvm_vcpu_cache to x86.c, since only x86 platform will
> use to align the memory area for fx_save.
> Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Acked-by: Carsten Otte <cotte-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [2/2] Moving kvm_vcpu_cache to x86.c
       [not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA394B5-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  2007-11-29 12:21   ` Carsten Otte
@ 2007-11-30  7:41   ` Avi Kivity
       [not found]     ` <474FBEB7.7070108-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Avi Kivity @ 2007-11-30  7:41 UTC (permalink / raw)
  To: Zhang, Xiantao
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	carsteno-tA70FqPdS9bQT0dZR+AlfA, hollisb-r/Jw6+rmf7HQT0dZR+AlfA

Zhang, Xiantao wrote:
> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Thu, 29 Nov 2007 15:45:57 +0800
> Subject: [PATCH] Moving kvm_vcpu_cache to x86.c.
> Moving kvm_vcpu_cache to x86.c, since only x86 platform will
> use to align the memory area for fx_save.
>   


How about having a KVM_VCPU_ALIGN macro, defined to zero except for
x86?  Alternatively (possibly better as it saves some memory), move the
fpu state out of kvm_vcpu (accessed via a pointer).

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [2/2] Moving kvm_vcpu_cache to x86.c
       [not found]     ` <474FBEB7.7070108-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-11-30  8:31       ` Zhang, Xiantao
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang, Xiantao @ 2007-11-30  8:31 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	carsteno-tA70FqPdS9bQT0dZR+AlfA, hollisb-r/Jw6+rmf7HQT0dZR+AlfA

Avi Kivity wrote:
> Zhang, Xiantao wrote:
>> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Date: Thu, 29 Nov 2007 15:45:57 +0800
>> Subject: [PATCH] Moving kvm_vcpu_cache to x86.c.
>> Moving kvm_vcpu_cache to x86.c, since only x86 platform will
>> use to align the memory area for fx_save.
>> 
> 
> 
> How about having a KVM_VCPU_ALIGN macro, defined to zero except for
> x86?  Alternatively (possibly better as it saves some memory), move
> the fpu state out of kvm_vcpu (accessed via a pointer).

Both should be OK. But now that other archs have no such issues, maybe
we can move them to x86 first:)

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-11-30  8:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-29  8:16 [PATCH] [2/2] Moving kvm_vcpu_cache to x86.c Zhang, Xiantao
     [not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA394B5-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-29 12:21   ` Carsten Otte
2007-11-30  7:41   ` Avi Kivity
     [not found]     ` <474FBEB7.7070108-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-30  8:31       ` Zhang, Xiantao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox