History

KVM: Move x86's version of struct kvm_mmu_memory_cache to common code

Move x86's 'struct kvm_mmu_memory_cache' to common code in anticipation of moving the entire x86 implementation code to common KVM and reusing it for arm64 and MIPS. Add a new architecture specific asm/kvm_types.h to control the existence and parameters of the struct. The new header is needed to avoid a chicken-and-egg problem with asm/kvm_host.h as all architectures define instances of the struct in their vCPU structs. Add an asm-generic version of kvm_types.h to avoid having empty files on PPC and s390 in the long term, and for arm64 and mips in the short term.

Sean Christopherson committed 6 years ago

Commit 2aa9c191 parent 94ce87e8 files · +35 −13Browse files

Showing the changes to include/linux (1 of 8 files). Show all

Unified · Split

include/linux/kvm_types.h+19−0
@@ -20,6 +20,8 @@ enum kvm_mr_change; · 19 unmodified lines
2020
2121 #include <linux/types.h>
2222
23+#include <asm/kvm_types.h>
24+
2325 /*
2426 * Address types:
2527 *
@@ -58,4 +60,21 @@ struct gfn_to_pfn_cache { · 32 unmodified lines
5860 bool dirty;
5961 };
6062
63+#ifdef KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE
64+/*
65+ * Memory caches are used to preallocate memory ahead of various MMU flows,
66+ * e.g. page fault handlers. Gracefully handling allocation failures deep in
67+ * MMU flows is problematic, as is triggering reclaim, I/O, etc... while
68+ * holding MMU locks. Note, these caches act more like prefetch buffers than
69+ * classical caches, i.e. objects are not returned to the cache on being freed.
70+ */
71+struct kvm_mmu_memory_cache {
72+ int nobjs;
73+ gfp_t gfp_zero;
74+ struct kmem_cache *kmem_cache;
75+ void *objects[KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE];
76+};
77+#endif
78+
79+
6180 #endif /* __KVM_TYPES_H__ */