]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
LoongArch: KVM: Add stat information with kernel irqchip
authorBibo Mao <maobibo@loongson.cn>
Mon, 21 Jul 2025 01:26:32 +0000 (09:26 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Mon, 21 Jul 2025 01:26:32 +0000 (09:26 +0800)
Move stat information about kernel irqchip from VM to vCPU, since all
vm exiting events should be vCPU relative. And also add entry with
structure kvm_vcpu_stats_desc[], so that it can display with directory
/sys/kernel/debug/kvm.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/include/asm/kvm_host.h
arch/loongarch/kvm/intc/eiointc.c
arch/loongarch/kvm/intc/ipi.c
arch/loongarch/kvm/intc/pch_pic.c
arch/loongarch/kvm/vcpu.c

index a3c4cc46c892242ae0f89fbc9e3326aae2cecad0..0cecbd038bb3c0f85f416ad810c1d19846af77f8 100644 (file)
@@ -50,12 +50,6 @@ struct kvm_vm_stat {
        struct kvm_vm_stat_generic generic;
        u64 pages;
        u64 hugepages;
-       u64 ipi_read_exits;
-       u64 ipi_write_exits;
-       u64 eiointc_read_exits;
-       u64 eiointc_write_exits;
-       u64 pch_pic_read_exits;
-       u64 pch_pic_write_exits;
 };
 
 struct kvm_vcpu_stat {
@@ -65,6 +59,12 @@ struct kvm_vcpu_stat {
        u64 cpucfg_exits;
        u64 signal_exits;
        u64 hypercall_exits;
+       u64 ipi_read_exits;
+       u64 ipi_write_exits;
+       u64 eiointc_read_exits;
+       u64 eiointc_write_exits;
+       u64 pch_pic_read_exits;
+       u64 pch_pic_write_exits;
 };
 
 #define KVM_MEM_HUGEPAGE_CAPABLE       (1UL << 0)
index c52a478fbb10e00aef845025ae9e8bba8e8db1f9..a3a12af9ecbff8ecaf3507a6cdf54c0235a0e3f7 100644 (file)
@@ -173,7 +173,7 @@ static int kvm_eiointc_read(struct kvm_vcpu *vcpu,
 
        offset = addr & 0x7;
        addr -= offset;
-       vcpu->kvm->stat.eiointc_read_exits++;
+       vcpu->stat.eiointc_read_exits++;
        spin_lock_irqsave(&eiointc->lock, flags);
        ret = loongarch_eiointc_read(vcpu, eiointc, addr, &data);
        spin_unlock_irqrestore(&eiointc->lock, flags);
@@ -307,7 +307,7 @@ static int kvm_eiointc_write(struct kvm_vcpu *vcpu,
                return -EINVAL;
        }
 
-       vcpu->kvm->stat.eiointc_write_exits++;
+       vcpu->stat.eiointc_write_exits++;
        spin_lock_irqsave(&eiointc->lock, flags);
        switch (len) {
        case 1:
index fe734dc062ed47aa3b2f54a0bcfae6787fc5e685..e658d5b37c044efa7c451397e44f170ad0efa904 100644 (file)
@@ -268,36 +268,16 @@ static int kvm_ipi_read(struct kvm_vcpu *vcpu,
                        struct kvm_io_device *dev,
                        gpa_t addr, int len, void *val)
 {
-       int ret;
-       struct loongarch_ipi *ipi;
-
-       ipi = vcpu->kvm->arch.ipi;
-       if (!ipi) {
-               kvm_err("%s: ipi irqchip not valid!\n", __func__);
-               return -EINVAL;
-       }
-       ipi->kvm->stat.ipi_read_exits++;
-       ret = loongarch_ipi_readl(vcpu, addr, len, val);
-
-       return ret;
+       vcpu->stat.ipi_read_exits++;
+       return loongarch_ipi_readl(vcpu, addr, len, val);
 }
 
 static int kvm_ipi_write(struct kvm_vcpu *vcpu,
                        struct kvm_io_device *dev,
                        gpa_t addr, int len, const void *val)
 {
-       int ret;
-       struct loongarch_ipi *ipi;
-
-       ipi = vcpu->kvm->arch.ipi;
-       if (!ipi) {
-               kvm_err("%s: ipi irqchip not valid!\n", __func__);
-               return -EINVAL;
-       }
-       ipi->kvm->stat.ipi_write_exits++;
-       ret = loongarch_ipi_writel(vcpu, addr, len, val);
-
-       return ret;
+       vcpu->stat.ipi_write_exits++;
+       return loongarch_ipi_writel(vcpu, addr, len, val);
 }
 
 static const struct kvm_io_device_ops kvm_ipi_ops = {
index 08fce845f66803adb7b4a63e7ffedc1f32202018..6f00ffe05c544ecf1302c4f21a9c778f8e0da6fe 100644 (file)
@@ -196,7 +196,7 @@ static int kvm_pch_pic_read(struct kvm_vcpu *vcpu,
        }
 
        /* statistics of pch pic reading */
-       vcpu->kvm->stat.pch_pic_read_exits++;
+       vcpu->stat.pch_pic_read_exits++;
        ret = loongarch_pch_pic_read(s, addr, len, val);
 
        return ret;
@@ -303,7 +303,7 @@ static int kvm_pch_pic_write(struct kvm_vcpu *vcpu,
        }
 
        /* statistics of pch pic writing */
-       vcpu->kvm->stat.pch_pic_write_exits++;
+       vcpu->stat.pch_pic_write_exits++;
        ret = loongarch_pch_pic_write(s, addr, len, val);
 
        return ret;
index 5af32ec62cb16aca8a6e50f17715ed054a01b18d..d1b8c50941ca233a8fc4519a8276d6bccd916f24 100644 (file)
@@ -20,7 +20,13 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {
        STATS_DESC_COUNTER(VCPU, idle_exits),
        STATS_DESC_COUNTER(VCPU, cpucfg_exits),
        STATS_DESC_COUNTER(VCPU, signal_exits),
-       STATS_DESC_COUNTER(VCPU, hypercall_exits)
+       STATS_DESC_COUNTER(VCPU, hypercall_exits),
+       STATS_DESC_COUNTER(VCPU, ipi_read_exits),
+       STATS_DESC_COUNTER(VCPU, ipi_write_exits),
+       STATS_DESC_COUNTER(VCPU, eiointc_read_exits),
+       STATS_DESC_COUNTER(VCPU, eiointc_write_exits),
+       STATS_DESC_COUNTER(VCPU, pch_pic_read_exits),
+       STATS_DESC_COUNTER(VCPU, pch_pic_write_exits)
 };
 
 const struct kvm_stats_header kvm_vcpu_stats_header = {