Skip to content

Commit 0a99afb

Browse files
bibo-maoKexyBiscuit
authored andcommitted
FROMGIT: LoongArch: KVM: Add stat information with kernel irqchip
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 <[email protected]> Signed-off-by: Huacai Chen <[email protected]> (cherry picked from commit 46ecfb6 https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson.git loongarch-next) Signed-off-by: Kexy Biscuit <[email protected]>
1 parent 7c4574e commit 0a99afb

File tree

5 files changed

+21
-35
lines changed

5 files changed

+21
-35
lines changed

arch/loongarch/include/asm/kvm_host.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ struct kvm_vm_stat {
5050
struct kvm_vm_stat_generic generic;
5151
u64 pages;
5252
u64 hugepages;
53-
u64 ipi_read_exits;
54-
u64 ipi_write_exits;
55-
u64 eiointc_read_exits;
56-
u64 eiointc_write_exits;
57-
u64 pch_pic_read_exits;
58-
u64 pch_pic_write_exits;
5953
};
6054

6155
struct kvm_vcpu_stat {
@@ -65,6 +59,12 @@ struct kvm_vcpu_stat {
6559
u64 cpucfg_exits;
6660
u64 signal_exits;
6761
u64 hypercall_exits;
62+
u64 ipi_read_exits;
63+
u64 ipi_write_exits;
64+
u64 eiointc_read_exits;
65+
u64 eiointc_write_exits;
66+
u64 pch_pic_read_exits;
67+
u64 pch_pic_write_exits;
6868
};
6969

7070
#define KVM_MEM_HUGEPAGE_CAPABLE (1UL << 0)

arch/loongarch/kvm/intc/eiointc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static int kvm_eiointc_read(struct kvm_vcpu *vcpu,
173173

174174
offset = addr & 0x7;
175175
addr -= offset;
176-
vcpu->kvm->stat.eiointc_read_exits++;
176+
vcpu->stat.eiointc_read_exits++;
177177
spin_lock_irqsave(&eiointc->lock, flags);
178178
ret = loongarch_eiointc_read(vcpu, eiointc, addr, &data);
179179
spin_unlock_irqrestore(&eiointc->lock, flags);
@@ -307,7 +307,7 @@ static int kvm_eiointc_write(struct kvm_vcpu *vcpu,
307307
return -EINVAL;
308308
}
309309

310-
vcpu->kvm->stat.eiointc_write_exits++;
310+
vcpu->stat.eiointc_write_exits++;
311311
spin_lock_irqsave(&eiointc->lock, flags);
312312
switch (len) {
313313
case 1:

arch/loongarch/kvm/intc/ipi.c

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -268,36 +268,16 @@ static int kvm_ipi_read(struct kvm_vcpu *vcpu,
268268
struct kvm_io_device *dev,
269269
gpa_t addr, int len, void *val)
270270
{
271-
int ret;
272-
struct loongarch_ipi *ipi;
273-
274-
ipi = vcpu->kvm->arch.ipi;
275-
if (!ipi) {
276-
kvm_err("%s: ipi irqchip not valid!\n", __func__);
277-
return -EINVAL;
278-
}
279-
ipi->kvm->stat.ipi_read_exits++;
280-
ret = loongarch_ipi_readl(vcpu, addr, len, val);
281-
282-
return ret;
271+
vcpu->stat.ipi_read_exits++;
272+
return loongarch_ipi_readl(vcpu, addr, len, val);
283273
}
284274

285275
static int kvm_ipi_write(struct kvm_vcpu *vcpu,
286276
struct kvm_io_device *dev,
287277
gpa_t addr, int len, const void *val)
288278
{
289-
int ret;
290-
struct loongarch_ipi *ipi;
291-
292-
ipi = vcpu->kvm->arch.ipi;
293-
if (!ipi) {
294-
kvm_err("%s: ipi irqchip not valid!\n", __func__);
295-
return -EINVAL;
296-
}
297-
ipi->kvm->stat.ipi_write_exits++;
298-
ret = loongarch_ipi_writel(vcpu, addr, len, val);
299-
300-
return ret;
279+
vcpu->stat.ipi_write_exits++;
280+
return loongarch_ipi_writel(vcpu, addr, len, val);
301281
}
302282

303283
static const struct kvm_io_device_ops kvm_ipi_ops = {

arch/loongarch/kvm/intc/pch_pic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static int kvm_pch_pic_read(struct kvm_vcpu *vcpu,
196196
}
197197

198198
/* statistics of pch pic reading */
199-
vcpu->kvm->stat.pch_pic_read_exits++;
199+
vcpu->stat.pch_pic_read_exits++;
200200
ret = loongarch_pch_pic_read(s, addr, len, val);
201201

202202
return ret;
@@ -303,7 +303,7 @@ static int kvm_pch_pic_write(struct kvm_vcpu *vcpu,
303303
}
304304

305305
/* statistics of pch pic writing */
306-
vcpu->kvm->stat.pch_pic_write_exits++;
306+
vcpu->stat.pch_pic_write_exits++;
307307
ret = loongarch_pch_pic_write(s, addr, len, val);
308308

309309
return ret;

arch/loongarch/kvm/vcpu.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {
2020
STATS_DESC_COUNTER(VCPU, idle_exits),
2121
STATS_DESC_COUNTER(VCPU, cpucfg_exits),
2222
STATS_DESC_COUNTER(VCPU, signal_exits),
23-
STATS_DESC_COUNTER(VCPU, hypercall_exits)
23+
STATS_DESC_COUNTER(VCPU, hypercall_exits),
24+
STATS_DESC_COUNTER(VCPU, ipi_read_exits),
25+
STATS_DESC_COUNTER(VCPU, ipi_write_exits),
26+
STATS_DESC_COUNTER(VCPU, eiointc_read_exits),
27+
STATS_DESC_COUNTER(VCPU, eiointc_write_exits),
28+
STATS_DESC_COUNTER(VCPU, pch_pic_read_exits),
29+
STATS_DESC_COUNTER(VCPU, pch_pic_write_exits)
2430
};
2531

2632
const struct kvm_stats_header kvm_vcpu_stats_header = {

0 commit comments

Comments
 (0)