v1: https://lore.kernel.org/kvm/[email protected]/
This used to be a more exhaustive patch set shrinking kvm_vcpu's size.
But we concluded that this would be too fragile to maintain and would
require a more radical layout change to group often used members
together instead of chopping off individual padding bytes.
The remaining two patches are nonetheless useful, as they either make
the structure layout a more natural fit (as for kvm_pmu, putting the
version atop) or removing pointless padding (kvm_mmu_memory_cache).
Please apply!
Thanks,
Mathias Krause (2):
KVM: x86: Shrink struct kvm_pmu
KVM: Shrink struct kvm_mmu_memory_cache
arch/x86/include/asm/kvm_host.h | 2 +-
include/linux/kvm_types.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--
2.39.1
Move the 'version' member to the beginning of the structure to reuse an
existing hole instead of introducing another one.
This allows us to save 8 bytes for 64 bit builds.
Signed-off-by: Mathias Krause <[email protected]>
---
arch/x86/include/asm/kvm_host.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 6aaae18f1854..43329c60a6b5 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -516,6 +516,7 @@ struct kvm_pmc {
#define KVM_PMC_MAX_FIXED 3
#define KVM_AMD_PMC_MAX_GENERIC 6
struct kvm_pmu {
+ u8 version;
unsigned nr_arch_gp_counters;
unsigned nr_arch_fixed_counters;
unsigned available_event_types;
@@ -528,7 +529,6 @@ struct kvm_pmu {
u64 global_ovf_ctrl_mask;
u64 reserved_bits;
u64 raw_event_mask;
- u8 version;
struct kvm_pmc gp_counters[KVM_INTEL_PMC_MAX_GENERIC];
struct kvm_pmc fixed_counters[KVM_PMC_MAX_FIXED];
struct irq_work irq_work;
--
2.39.1
Move the 'capacity' member around to make use of the padding hole on 64
bit systems instead of introducing yet another one.
This allows us to save 8 bytes per instance for 64 bit builds of which,
e.g., x86's struct kvm_vcpu_arch has a few.
Signed-off-by: Mathias Krause <[email protected]>
---
v2: use order as suggested by Sean
include/linux/kvm_types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h
index 76de36e56cdf..0b2ddce47f11 100644
--- a/include/linux/kvm_types.h
+++ b/include/linux/kvm_types.h
@@ -91,11 +91,11 @@ struct gfn_to_pfn_cache {
* is topped up (__kvm_mmu_topup_memory_cache()).
*/
struct kvm_mmu_memory_cache {
- int nobjs;
gfp_t gfp_zero;
gfp_t gfp_custom;
struct kmem_cache *kmem_cache;
int capacity;
+ int nobjs;
void **objects;
};
#endif
--
2.39.1
On Fri, Feb 17, 2023, Mathias Krause wrote:
> Move the 'capacity' member around to make use of the padding hole on 64
Nit, 'nobjs' is the field that gets moved in this version. No need for another
version, I can fix up when applying.
If no one objects, I'll plan on taking this through kvm-x86/generic.
On 17.03.23 23:45, Sean Christopherson wrote:
> On Fri, Feb 17, 2023, Mathias Krause wrote:
>> Move the 'capacity' member around to make use of the padding hole on 64
>
> Nit, 'nobjs' is the field that gets moved in this version. No need for another
> version, I can fix up when applying.
Ahh, forgot to update the changelog after switching the layout. But as
it was 'nobjs' next to 'capacity' for both variants, I wrongly thought
there's no need to. But sure, you're right.
>
> If no one objects, I'll plan on taking this through kvm-x86/generic.
Thanks,
Mathias
On Fri, 17 Feb 2023 20:33:34 +0100, Mathias Krause wrote:
> v1: https://lore.kernel.org/kvm/[email protected]/
>
> This used to be a more exhaustive patch set shrinking kvm_vcpu's size.
> But we concluded that this would be too fragile to maintain and would
> require a more radical layout change to group often used members
> together instead of chopping off individual padding bytes.
>
> [...]
Applied patch 1 to kvm-x86 pmu, and patch 2 to generic, thanks!
[1/2] KVM: x86: Shrink struct kvm_pmu
https://github.com/kvm-x86/linux/commit/12aad9164763
[2/2] KVM: Shrink struct kvm_mmu_memory_cache
https://github.com/kvm-x86/linux/commit/f530b531fb9e
--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes