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>

+32 -1
+32 -1
drivers/kvm/kvm_main.c
··· 36 #include <asm/desc.h> 37 #include <linux/sysdev.h> 38 #include <linux/cpu.h> 39 40 #include "x86_emulate.h" 41 #include "segment_descriptor.h" ··· 73 }; 74 75 static struct dentry *debugfs_dir; 76 77 #define MAX_IO_MSRS 256 78 ··· 2257 2258 hpa_t bad_page_address; 2259 2260 int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module) 2261 { 2262 int r; ··· 2345 static __init int kvm_init(void) 2346 { 2347 static struct page *bad_page; 2348 - int r = 0; 2349 2350 kvm_init_debug(); 2351 2352 kvm_init_msr_list(); ··· 2371 2372 out: 2373 kvm_exit_debug(); 2374 return r; 2375 } 2376 ··· 2382 { 2383 kvm_exit_debug(); 2384 __free_page(pfn_to_page(bad_page_address >> PAGE_SHIFT)); 2385 } 2386 2387 module_init(kvm_init)
··· 36 #include <asm/desc.h> 37 #include <linux/sysdev.h> 38 #include <linux/cpu.h> 39 + #include <linux/fs.h> 40 + #include <linux/mount.h> 41 42 #include "x86_emulate.h" 43 #include "segment_descriptor.h" ··· 71 }; 72 73 static struct dentry *debugfs_dir; 74 + 75 + #define KVMFS_MAGIC 0x19700426 76 + struct vfsmount *kvmfs_mnt; 77 78 #define MAX_IO_MSRS 256 79 ··· 2252 2253 hpa_t bad_page_address; 2254 2255 + static int kvmfs_get_sb(struct file_system_type *fs_type, int flags, 2256 + const char *dev_name, void *data, struct vfsmount *mnt) 2257 + { 2258 + return get_sb_pseudo(fs_type, "kvm:", NULL, KVMFS_MAGIC, mnt); 2259 + } 2260 + 2261 + static struct file_system_type kvm_fs_type = { 2262 + .name = "kvmfs", 2263 + .get_sb = kvmfs_get_sb, 2264 + .kill_sb = kill_anon_super, 2265 + }; 2266 + 2267 int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module) 2268 { 2269 int r; ··· 2328 static __init int kvm_init(void) 2329 { 2330 static struct page *bad_page; 2331 + int r; 2332 2333 + r = register_filesystem(&kvm_fs_type); 2334 + if (r) 2335 + goto out3; 2336 + 2337 + kvmfs_mnt = kern_mount(&kvm_fs_type); 2338 + r = PTR_ERR(kvmfs_mnt); 2339 + if (IS_ERR(kvmfs_mnt)) 2340 + goto out2; 2341 kvm_init_debug(); 2342 2343 kvm_init_msr_list(); ··· 2346 2347 out: 2348 kvm_exit_debug(); 2349 + mntput(kvmfs_mnt); 2350 + out2: 2351 + unregister_filesystem(&kvm_fs_type); 2352 + out3: 2353 return r; 2354 } 2355 ··· 2353 { 2354 kvm_exit_debug(); 2355 __free_page(pfn_to_page(bad_page_address >> PAGE_SHIFT)); 2356 + mntput(kvmfs_mnt); 2357 + unregister_filesystem(&kvm_fs_type); 2358 } 2359 2360 module_init(kvm_init)