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 36 #include <asm/desc.h> 37 37 #include <linux/sysdev.h> 38 38 #include <linux/cpu.h> 39 + #include <linux/fs.h> 40 + #include <linux/mount.h> 39 41 40 42 #include "x86_emulate.h" 41 43 #include "segment_descriptor.h" ··· 73 71 }; 74 72 75 73 static struct dentry *debugfs_dir; 74 + 75 + #define KVMFS_MAGIC 0x19700426 76 + struct vfsmount *kvmfs_mnt; 76 77 77 78 #define MAX_IO_MSRS 256 78 79 ··· 2257 2252 2258 2253 hpa_t bad_page_address; 2259 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 + 2260 2267 int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module) 2261 2268 { 2262 2269 int r; ··· 2345 2328 static __init int kvm_init(void) 2346 2329 { 2347 2330 static struct page *bad_page; 2348 - int r = 0; 2331 + int r; 2349 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; 2350 2341 kvm_init_debug(); 2351 2342 2352 2343 kvm_init_msr_list(); ··· 2371 2346 2372 2347 out: 2373 2348 kvm_exit_debug(); 2349 + mntput(kvmfs_mnt); 2350 + out2: 2351 + unregister_filesystem(&kvm_fs_type); 2352 + out3: 2374 2353 return r; 2375 2354 } 2376 2355 ··· 2382 2353 { 2383 2354 kvm_exit_debug(); 2384 2355 __free_page(pfn_to_page(bad_page_address >> PAGE_SHIFT)); 2356 + mntput(kvmfs_mnt); 2357 + unregister_filesystem(&kvm_fs_type); 2385 2358 } 2386 2359 2387 2360 module_init(kvm_init)