diff options
author | Avi Kivity <avi@qumranet.com> | 2007-02-20 07:07:37 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-03-04 04:12:41 -0500 |
commit | 37e29d906c6eb1ece907e509160518b2edc2c083 (patch) | |
tree | 2315e8b516d89400f6e03253d85f74eea3127526 /drivers | |
parent | 19d1408dfd683daf1c158bb8fbf54324eb4bf568 (diff) |
KVM: Add internal filesystem for generating inodes
The kvmfs inodes will represent virtual machines and vcpus, as necessary,
reducing cacheline bouncing due to inodes and filps being shared.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/kvm/kvm_main.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 0df0eebc54a9..c01252e84377 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -36,6 +36,8 @@ | |||
36 | #include <asm/desc.h> | 36 | #include <asm/desc.h> |
37 | #include <linux/sysdev.h> | 37 | #include <linux/sysdev.h> |
38 | #include <linux/cpu.h> | 38 | #include <linux/cpu.h> |
39 | #include <linux/fs.h> | ||
40 | #include <linux/mount.h> | ||
39 | 41 | ||
40 | #include "x86_emulate.h" | 42 | #include "x86_emulate.h" |
41 | #include "segment_descriptor.h" | 43 | #include "segment_descriptor.h" |
@@ -72,6 +74,9 @@ static struct kvm_stats_debugfs_item { | |||
72 | 74 | ||
73 | static struct dentry *debugfs_dir; | 75 | static struct dentry *debugfs_dir; |
74 | 76 | ||
77 | #define KVMFS_MAGIC 0x19700426 | ||
78 | struct vfsmount *kvmfs_mnt; | ||
79 | |||
75 | #define MAX_IO_MSRS 256 | 80 | #define MAX_IO_MSRS 256 |
76 | 81 | ||
77 | #define CR0_RESEVED_BITS 0xffffffff1ffaffc0ULL | 82 | #define CR0_RESEVED_BITS 0xffffffff1ffaffc0ULL |
@@ -2252,6 +2257,18 @@ static struct sys_device kvm_sysdev = { | |||
2252 | 2257 | ||
2253 | hpa_t bad_page_address; | 2258 | hpa_t bad_page_address; |
2254 | 2259 | ||
2260 | static int kvmfs_get_sb(struct file_system_type *fs_type, int flags, | ||
2261 | const char *dev_name, void *data, struct vfsmount *mnt) | ||
2262 | { | ||
2263 | return get_sb_pseudo(fs_type, "kvm:", NULL, KVMFS_MAGIC, mnt); | ||
2264 | } | ||
2265 | |||
2266 | static struct file_system_type kvm_fs_type = { | ||
2267 | .name = "kvmfs", | ||
2268 | .get_sb = kvmfs_get_sb, | ||
2269 | .kill_sb = kill_anon_super, | ||
2270 | }; | ||
2271 | |||
2255 | int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module) | 2272 | int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module) |
2256 | { | 2273 | { |
2257 | int r; | 2274 | int r; |
@@ -2328,8 +2345,16 @@ void kvm_exit_arch(void) | |||
2328 | static __init int kvm_init(void) | 2345 | static __init int kvm_init(void) |
2329 | { | 2346 | { |
2330 | static struct page *bad_page; | 2347 | static struct page *bad_page; |
2331 | int r = 0; | 2348 | int r; |
2349 | |||
2350 | r = register_filesystem(&kvm_fs_type); | ||
2351 | if (r) | ||
2352 | goto out3; | ||
2332 | 2353 | ||
2354 | kvmfs_mnt = kern_mount(&kvm_fs_type); | ||
2355 | r = PTR_ERR(kvmfs_mnt); | ||
2356 | if (IS_ERR(kvmfs_mnt)) | ||
2357 | goto out2; | ||
2333 | kvm_init_debug(); | 2358 | kvm_init_debug(); |
2334 | 2359 | ||
2335 | kvm_init_msr_list(); | 2360 | kvm_init_msr_list(); |
@@ -2346,6 +2371,10 @@ static __init int kvm_init(void) | |||
2346 | 2371 | ||
2347 | out: | 2372 | out: |
2348 | kvm_exit_debug(); | 2373 | kvm_exit_debug(); |
2374 | mntput(kvmfs_mnt); | ||
2375 | out2: | ||
2376 | unregister_filesystem(&kvm_fs_type); | ||
2377 | out3: | ||
2349 | return r; | 2378 | return r; |
2350 | } | 2379 | } |
2351 | 2380 | ||
@@ -2353,6 +2382,8 @@ static __exit void kvm_exit(void) | |||
2353 | { | 2382 | { |
2354 | kvm_exit_debug(); | 2383 | kvm_exit_debug(); |
2355 | __free_page(pfn_to_page(bad_page_address >> PAGE_SHIFT)); | 2384 | __free_page(pfn_to_page(bad_page_address >> PAGE_SHIFT)); |
2385 | mntput(kvmfs_mnt); | ||
2386 | unregister_filesystem(&kvm_fs_type); | ||
2356 | } | 2387 | } |
2357 | 2388 | ||
2358 | module_init(kvm_init) | 2389 | module_init(kvm_init) |