^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright IBM Corp. 2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Authors: Hollis Blanchard <hollisb@us.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/kvm_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm-generic/div64.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "timing.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /* Take a lock to avoid concurrent updates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) mutex_lock(&vcpu->arch.exit_timing_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) vcpu->arch.last_exit_type = 0xDEAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) for (i = 0; i < __NUMBER_OF_KVM_EXIT_TYPES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) vcpu->arch.timing_count_type[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) vcpu->arch.timing_max_duration[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) vcpu->arch.timing_min_duration[i] = 0xFFFFFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) vcpu->arch.timing_sum_duration[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) vcpu->arch.timing_sum_quad_duration[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) vcpu->arch.timing_last_exit = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) vcpu->arch.timing_exit.tv64 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) vcpu->arch.timing_last_enter.tv64 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) mutex_unlock(&vcpu->arch.exit_timing_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static void add_exit_timing(struct kvm_vcpu *vcpu, u64 duration, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) u64 old;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) mutex_lock(&vcpu->arch.exit_timing_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) vcpu->arch.timing_count_type[type]++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* sum */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) old = vcpu->arch.timing_sum_duration[type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) vcpu->arch.timing_sum_duration[type] += duration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if (unlikely(old > vcpu->arch.timing_sum_duration[type])) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) printk(KERN_ERR"%s - wrap adding sum of durations"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) " old %lld new %lld type %d exit # of type %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) __func__, old, vcpu->arch.timing_sum_duration[type],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) type, vcpu->arch.timing_count_type[type]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /* square sum */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) old = vcpu->arch.timing_sum_quad_duration[type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) vcpu->arch.timing_sum_quad_duration[type] += (duration*duration);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) if (unlikely(old > vcpu->arch.timing_sum_quad_duration[type])) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) printk(KERN_ERR"%s - wrap adding sum of squared durations"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) " old %lld new %lld type %d exit # of type %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) __func__, old,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) vcpu->arch.timing_sum_quad_duration[type],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) type, vcpu->arch.timing_count_type[type]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* set min/max */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) if (unlikely(duration < vcpu->arch.timing_min_duration[type]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) vcpu->arch.timing_min_duration[type] = duration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) if (unlikely(duration > vcpu->arch.timing_max_duration[type]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) vcpu->arch.timing_max_duration[type] = duration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) mutex_unlock(&vcpu->arch.exit_timing_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) u64 exit = vcpu->arch.timing_last_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) u64 enter = vcpu->arch.timing_last_enter.tv64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /* save exit time, used next exit when the reenter time is known */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) vcpu->arch.timing_last_exit = vcpu->arch.timing_exit.tv64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (unlikely(vcpu->arch.last_exit_type == 0xDEAD || exit == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) return; /* skip incomplete cycle (e.g. after reset) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) /* update statistics for average and standard deviation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) add_exit_timing(vcpu, (enter - exit), vcpu->arch.last_exit_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /* enter -> timing_last_exit is time spent in guest - log this too */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) add_exit_timing(vcpu, (vcpu->arch.timing_last_exit - enter),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) TIMEINGUEST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static const char *kvm_exit_names[__NUMBER_OF_KVM_EXIT_TYPES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) [MMIO_EXITS] = "MMIO",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) [SIGNAL_EXITS] = "SIGNAL",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) [ITLB_REAL_MISS_EXITS] = "ITLBREAL",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) [ITLB_VIRT_MISS_EXITS] = "ITLBVIRT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) [DTLB_REAL_MISS_EXITS] = "DTLBREAL",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) [DTLB_VIRT_MISS_EXITS] = "DTLBVIRT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) [SYSCALL_EXITS] = "SYSCALL",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) [ISI_EXITS] = "ISI",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) [DSI_EXITS] = "DSI",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) [EMULATED_INST_EXITS] = "EMULINST",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) [EMULATED_MTMSRWE_EXITS] = "EMUL_WAIT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) [EMULATED_WRTEE_EXITS] = "EMUL_WRTEE",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) [EMULATED_MTSPR_EXITS] = "EMUL_MTSPR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) [EMULATED_MFSPR_EXITS] = "EMUL_MFSPR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) [EMULATED_MTMSR_EXITS] = "EMUL_MTMSR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) [EMULATED_MFMSR_EXITS] = "EMUL_MFMSR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) [EMULATED_TLBSX_EXITS] = "EMUL_TLBSX",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) [EMULATED_TLBWE_EXITS] = "EMUL_TLBWE",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) [EMULATED_RFI_EXITS] = "EMUL_RFI",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) [DEC_EXITS] = "DEC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) [EXT_INTR_EXITS] = "EXTINT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) [HALT_WAKEUP] = "HALT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) [USR_PR_INST] = "USR_PR_INST",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) [FP_UNAVAIL] = "FP_UNAVAIL",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) [DEBUG_EXITS] = "DEBUG",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) [TIMEINGUEST] = "TIMEINGUEST"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static int kvmppc_exit_timing_show(struct seq_file *m, void *private)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct kvm_vcpu *vcpu = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) u64 min, max, sum, sum_quad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) seq_puts(m, "type count min max sum sum_squared\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) for (i = 0; i < __NUMBER_OF_KVM_EXIT_TYPES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) min = vcpu->arch.timing_min_duration[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) do_div(min, tb_ticks_per_usec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) max = vcpu->arch.timing_max_duration[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) do_div(max, tb_ticks_per_usec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) sum = vcpu->arch.timing_sum_duration[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) do_div(sum, tb_ticks_per_usec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) sum_quad = vcpu->arch.timing_sum_quad_duration[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) do_div(sum_quad, tb_ticks_per_usec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) seq_printf(m, "%12s %10d %10lld %10lld %20lld %20lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) kvm_exit_names[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) vcpu->arch.timing_count_type[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) max,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) sum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) sum_quad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) /* Write 'c' to clear the timing statistics. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static ssize_t kvmppc_exit_timing_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) const char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) char c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if (count > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (get_user(c, user_buf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) err = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (c == 'c') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct seq_file *seqf = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) struct kvm_vcpu *vcpu = seqf->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /* Write does not affect our buffers previously generated with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * show. seq_file is locked here to prevent races of init with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * a show call */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) mutex_lock(&seqf->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) kvmppc_init_timing_stats(vcpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) mutex_unlock(&seqf->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) err = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static int kvmppc_exit_timing_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return single_open(file, kvmppc_exit_timing_show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) static const struct file_operations kvmppc_exit_timing_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) .open = kvmppc_exit_timing_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) .write = kvmppc_exit_timing_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) .release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static char dbg_fname[50];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct dentry *debugfs_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) snprintf(dbg_fname, sizeof(dbg_fname), "vm%u_vcpu%u_timing",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) current->pid, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) debugfs_file = debugfs_create_file(dbg_fname, 0666, kvm_debugfs_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) vcpu, &kvmppc_exit_timing_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) vcpu->arch.debugfs_exit_timing = debugfs_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) debugfs_remove(vcpu->arch.debugfs_exit_timing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) vcpu->arch.debugfs_exit_timing = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }