26 #include <linux/module.h>
40 vcpu->
arch.last_exit_type = 0xDEAD;
42 vcpu->
arch.timing_count_type[
i] = 0;
43 vcpu->
arch.timing_max_duration[
i] = 0;
44 vcpu->
arch.timing_min_duration[
i] = 0xFFFFFFFF;
45 vcpu->
arch.timing_sum_duration[
i] = 0;
46 vcpu->
arch.timing_sum_quad_duration[
i] = 0;
48 vcpu->
arch.timing_last_exit = 0;
49 vcpu->
arch.timing_exit.tv64 = 0;
50 vcpu->
arch.timing_last_enter.tv64 = 0;
61 vcpu->
arch.timing_count_type[
type]++;
64 old = vcpu->
arch.timing_sum_duration[
type];
66 if (
unlikely(old > vcpu->
arch.timing_sum_duration[type])) {
68 " old %lld new %lld type %d exit # of type %d\n",
69 __func__, old, vcpu->
arch.timing_sum_duration[type],
70 type, vcpu->
arch.timing_count_type[type]);
74 old = vcpu->
arch.timing_sum_quad_duration[
type];
76 if (
unlikely(old > vcpu->
arch.timing_sum_quad_duration[type])) {
78 " old %lld new %lld type %d exit # of type %d\n",
80 vcpu->
arch.timing_sum_quad_duration[type],
81 type, vcpu->
arch.timing_count_type[type]);
85 if (
unlikely(duration < vcpu->
arch.timing_min_duration[type]))
87 if (
unlikely(duration > vcpu->
arch.timing_max_duration[type]))
99 vcpu->
arch.timing_last_exit = vcpu->
arch.timing_exit.tv64;
101 if (
unlikely(vcpu->
arch.last_exit_type == 0xDEAD || exit == 0))
105 add_exit_timing(vcpu, (enter - exit), vcpu->
arch.last_exit_type);
107 add_exit_timing(vcpu, (vcpu->
arch.timing_last_exit - enter),
141 static int kvmppc_exit_timing_show(
struct seq_file *
m,
void *
private)
147 seq_printf(m,
"%s",
"type count min max sum sum_squared\n");
152 min = vcpu->
arch.timing_min_duration[
i];
154 max = vcpu->
arch.timing_max_duration[
i];
156 sum = vcpu->
arch.timing_sum_duration[
i];
158 sum_quad = vcpu->
arch.timing_sum_quad_duration[
i];
161 seq_printf(m,
"%12s %10d %10lld %10lld %20lld %20lld\n",
163 vcpu->
arch.timing_count_type[i],
175 const char __user *user_buf,
176 size_t count, loff_t *ppos)
206 static int kvmppc_exit_timing_open(
struct inode *
inode,
struct file *file)
213 .open = kvmppc_exit_timing_open,
215 .write = kvmppc_exit_timing_write,
222 static char dbg_fname[50];
223 struct dentry *debugfs_file;
225 snprintf(dbg_fname,
sizeof(dbg_fname),
"vm%u_vcpu%u_timing",
229 &kvmppc_exit_timing_fops);
233 __func__, dbg_fname);
237 vcpu->
arch.debugfs_exit_timing = debugfs_file;
242 if (vcpu->
arch.debugfs_exit_timing) {
244 vcpu->
arch.debugfs_exit_timing =
NULL;