Define the data structures to be used on the KVM side: vCPUDirtyQuotaContext: stores the dirty quota context for individual vCPUs (shared between QEMU and KVM). dirty_counter: number of pages dirtied by the vCPU dirty_quota: limit on the number of pages the vCPU can dirty dirty_quota_migration_enabled: flag to see if migration is on or off. Co-developed-by: Anurag Madnawat <anurag.madnawat@xxxxxxxxxxx> Signed-off-by: Anurag Madnawat <anurag.madnawat@xxxxxxxxxxx> Signed-off-by: Shivam Kumar <shivam.kumar1@xxxxxxxxxxx> Signed-off-by: Shaju Abraham <shaju.abraham@xxxxxxxxxxx> Signed-off-by: Manish Mishra <manish.mishra@xxxxxxxxxxx> --- include/linux/dirty_quota_migration.h | 17 +++++++++++++++++ include/linux/kvm_host.h | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 include/linux/dirty_quota_migration.h diff --git a/include/linux/dirty_quota_migration.h b/include/linux/dirty_quota_migration.h new file mode 100644 index 000000000000..4f4e0d80a04d --- /dev/null +++ b/include/linux/dirty_quota_migration.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef DIRTY_QUOTA_MIGRATION_H +#define DIRTY_QUOTA_MIGRATION_H +#include <linux/kvm.h> + +/** + * vCPUDirtyQuotaContext: dirty quota context of a vCPU + * + * @dirty_counter: number of pages dirtied by the vCPU + * @dirty_quota: limit on the number of pages the vCPU can dirty + */ +struct vCPUDirtyQuotaContext { + u64 dirty_counter; + u64 dirty_quota; +}; + +#endif /* DIRTY_QUOTA_MIGRATION_H */ diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 9e0667e3723e..3cb6a43da01c 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -38,6 +38,7 @@ #include <asm/kvm_host.h> #include <linux/kvm_dirty_ring.h> +#include <linux/dirty_quota_migration.h> #ifndef KVM_MAX_VCPU_IDS #define KVM_MAX_VCPU_IDS KVM_MAX_VCPUS @@ -360,6 +361,7 @@ struct kvm_vcpu { * it is a valid slot. */ int last_used_slot; + struct vCPUDirtyQuotaContext *vCPUdqctx; }; /* must be called with irqs disabled */ @@ -618,6 +620,7 @@ struct kvm { u32 dirty_ring_size; bool vm_bugged; bool vm_dead; + bool dirty_quota_migration_enabled; #ifdef CONFIG_HAVE_KVM_PM_NOTIFIER struct notifier_block pm_notifier; -- 2.22.3