diff options
author | Hollis Blanchard <hollisb@us.ibm.com> | 2008-12-02 16:51:58 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2008-12-31 09:55:41 -0500 |
commit | 7b7015914b30ad8d9136d41412c5129b9bc9af70 (patch) | |
tree | c0764fff834b784d933126f30ef5562aef0dc55c /arch/powerpc/kvm/timing.c | |
parent | 73e75b416ffcfa3a84952d8e389a0eca080f00e1 (diff) |
KVM: ppc: mostly cosmetic updates to the exit timing accounting code
The only significant changes were to kvmppc_exit_timing_write() and
kvmppc_exit_timing_show(), both of which were dramatically simplified.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/kvm/timing.c')
-rw-r--r-- | arch/powerpc/kvm/timing.c | 109 |
1 files changed, 43 insertions, 66 deletions
diff --git a/arch/powerpc/kvm/timing.c b/arch/powerpc/kvm/timing.c index f42d2728a6a5..47ee603f558e 100644 --- a/arch/powerpc/kvm/timing.c +++ b/arch/powerpc/kvm/timing.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * along with this program; if not, write to the Free Software | 12 | * along with this program; if not, write to the Free Software |
13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
14 | * | 14 | * |
15 | * Copyright IBM Corp. 2007 | 15 | * Copyright IBM Corp. 2008 |
16 | * | 16 | * |
17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> | 17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> |
18 | * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> | 18 | * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> |
@@ -24,10 +24,11 @@ | |||
24 | #include <linux/debugfs.h> | 24 | #include <linux/debugfs.h> |
25 | #include <linux/uaccess.h> | 25 | #include <linux/uaccess.h> |
26 | 26 | ||
27 | #include "timing.h" | ||
28 | #include <asm/time.h> | 27 | #include <asm/time.h> |
29 | #include <asm-generic/div64.h> | 28 | #include <asm-generic/div64.h> |
30 | 29 | ||
30 | #include "timing.h" | ||
31 | |||
31 | void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) | 32 | void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) |
32 | { | 33 | { |
33 | int i; | 34 | int i; |
@@ -52,8 +53,7 @@ void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) | |||
52 | local_irq_enable(); | 53 | local_irq_enable(); |
53 | } | 54 | } |
54 | 55 | ||
55 | static void add_exit_timing(struct kvm_vcpu *vcpu, | 56 | static void add_exit_timing(struct kvm_vcpu *vcpu, u64 duration, int type) |
56 | u64 duration, int type) | ||
57 | { | 57 | { |
58 | u64 old; | 58 | u64 old; |
59 | 59 | ||
@@ -115,54 +115,46 @@ void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) | |||
115 | } | 115 | } |
116 | 116 | ||
117 | static const char *kvm_exit_names[__NUMBER_OF_KVM_EXIT_TYPES] = { | 117 | static const char *kvm_exit_names[__NUMBER_OF_KVM_EXIT_TYPES] = { |
118 | [MMIO_EXITS] = "MMIO", | 118 | [MMIO_EXITS] = "MMIO", |
119 | [DCR_EXITS] = "DCR", | 119 | [DCR_EXITS] = "DCR", |
120 | [SIGNAL_EXITS] = "SIGNAL", | 120 | [SIGNAL_EXITS] = "SIGNAL", |
121 | [ITLB_REAL_MISS_EXITS] = "ITLBREAL", | 121 | [ITLB_REAL_MISS_EXITS] = "ITLBREAL", |
122 | [ITLB_VIRT_MISS_EXITS] = "ITLBVIRT", | 122 | [ITLB_VIRT_MISS_EXITS] = "ITLBVIRT", |
123 | [DTLB_REAL_MISS_EXITS] = "DTLBREAL", | 123 | [DTLB_REAL_MISS_EXITS] = "DTLBREAL", |
124 | [DTLB_VIRT_MISS_EXITS] = "DTLBVIRT", | 124 | [DTLB_VIRT_MISS_EXITS] = "DTLBVIRT", |
125 | [SYSCALL_EXITS] = "SYSCALL", | 125 | [SYSCALL_EXITS] = "SYSCALL", |
126 | [ISI_EXITS] = "ISI", | 126 | [ISI_EXITS] = "ISI", |
127 | [DSI_EXITS] = "DSI", | 127 | [DSI_EXITS] = "DSI", |
128 | [EMULATED_INST_EXITS] = "EMULINST", | 128 | [EMULATED_INST_EXITS] = "EMULINST", |
129 | [EMULATED_MTMSRWE_EXITS] = "EMUL_WAIT", | 129 | [EMULATED_MTMSRWE_EXITS] = "EMUL_WAIT", |
130 | [EMULATED_WRTEE_EXITS] = "EMUL_WRTEE", | 130 | [EMULATED_WRTEE_EXITS] = "EMUL_WRTEE", |
131 | [EMULATED_MTSPR_EXITS] = "EMUL_MTSPR", | 131 | [EMULATED_MTSPR_EXITS] = "EMUL_MTSPR", |
132 | [EMULATED_MFSPR_EXITS] = "EMUL_MFSPR", | 132 | [EMULATED_MFSPR_EXITS] = "EMUL_MFSPR", |
133 | [EMULATED_MTMSR_EXITS] = "EMUL_MTMSR", | 133 | [EMULATED_MTMSR_EXITS] = "EMUL_MTMSR", |
134 | [EMULATED_MFMSR_EXITS] = "EMUL_MFMSR", | 134 | [EMULATED_MFMSR_EXITS] = "EMUL_MFMSR", |
135 | [EMULATED_TLBSX_EXITS] = "EMUL_TLBSX", | 135 | [EMULATED_TLBSX_EXITS] = "EMUL_TLBSX", |
136 | [EMULATED_TLBWE_EXITS] = "EMUL_TLBWE", | 136 | [EMULATED_TLBWE_EXITS] = "EMUL_TLBWE", |
137 | [EMULATED_RFI_EXITS] = "EMUL_RFI", | 137 | [EMULATED_RFI_EXITS] = "EMUL_RFI", |
138 | [DEC_EXITS] = "DEC", | 138 | [DEC_EXITS] = "DEC", |
139 | [EXT_INTR_EXITS] = "EXTINT", | 139 | [EXT_INTR_EXITS] = "EXTINT", |
140 | [HALT_WAKEUP] = "HALT", | 140 | [HALT_WAKEUP] = "HALT", |
141 | [USR_PR_INST] = "USR_PR_INST", | 141 | [USR_PR_INST] = "USR_PR_INST", |
142 | [FP_UNAVAIL] = "FP_UNAVAIL", | 142 | [FP_UNAVAIL] = "FP_UNAVAIL", |
143 | [DEBUG_EXITS] = "DEBUG", | 143 | [DEBUG_EXITS] = "DEBUG", |
144 | [TIMEINGUEST] = "TIMEINGUEST" | 144 | [TIMEINGUEST] = "TIMEINGUEST" |
145 | }; | 145 | }; |
146 | 146 | ||
147 | static int kvmppc_exit_timing_show(struct seq_file *m, void *private) | 147 | static int kvmppc_exit_timing_show(struct seq_file *m, void *private) |
148 | { | 148 | { |
149 | struct kvm_vcpu *vcpu = m->private; | 149 | struct kvm_vcpu *vcpu = m->private; |
150 | int i; | 150 | int i; |
151 | u64 min, max; | 151 | |
152 | seq_printf(m, "%s", "type count min max sum sum_squared\n"); | ||
152 | 153 | ||
153 | for (i = 0; i < __NUMBER_OF_KVM_EXIT_TYPES; i++) { | 154 | for (i = 0; i < __NUMBER_OF_KVM_EXIT_TYPES; i++) { |
154 | if (vcpu->arch.timing_min_duration[i] == 0xFFFFFFFF) | 155 | seq_printf(m, "%12s %10d %10lld %10lld %20lld %20lld\n", |
155 | min = 0; | 156 | kvm_exit_names[i], |
156 | else | 157 | vcpu->arch.timing_count_type[i], |
157 | min = vcpu->arch.timing_min_duration[i]; | ||
158 | if (vcpu->arch.timing_max_duration[i] == 0) | ||
159 | max = 0; | ||
160 | else | ||
161 | max = vcpu->arch.timing_max_duration[i]; | ||
162 | |||
163 | seq_printf(m, "%12s: count %10d min %10lld " | ||
164 | "max %10lld sum %20lld sum_quad %20lld\n", | ||
165 | kvm_exit_names[i], vcpu->arch.timing_count_type[i], | ||
166 | vcpu->arch.timing_min_duration[i], | 158 | vcpu->arch.timing_min_duration[i], |
167 | vcpu->arch.timing_max_duration[i], | 159 | vcpu->arch.timing_max_duration[i], |
168 | vcpu->arch.timing_sum_duration[i], | 160 | vcpu->arch.timing_sum_duration[i], |
@@ -171,31 +163,19 @@ static int kvmppc_exit_timing_show(struct seq_file *m, void *private) | |||
171 | return 0; | 163 | return 0; |
172 | } | 164 | } |
173 | 165 | ||
166 | /* Write 'c' to clear the timing statistics. */ | ||
174 | static ssize_t kvmppc_exit_timing_write(struct file *file, | 167 | static ssize_t kvmppc_exit_timing_write(struct file *file, |
175 | const char __user *user_buf, | 168 | const char __user *user_buf, |
176 | size_t count, loff_t *ppos) | 169 | size_t count, loff_t *ppos) |
177 | { | 170 | { |
178 | size_t len; | 171 | int err = -EINVAL; |
179 | int err; | ||
180 | const char __user *p; | ||
181 | char c; | 172 | char c; |
182 | 173 | ||
183 | len = 0; | 174 | if (count > 1) { |
184 | p = user_buf; | ||
185 | while (len < count) { | ||
186 | if (get_user(c, p++)) | ||
187 | err = -EFAULT; | ||
188 | if (c == 0 || c == '\n') | ||
189 | break; | ||
190 | len++; | ||
191 | } | ||
192 | |||
193 | if (len > 1) { | ||
194 | err = -EINVAL; | ||
195 | goto done; | 175 | goto done; |
196 | } | 176 | } |
197 | 177 | ||
198 | if (copy_from_user(&c, user_buf, sizeof(c))) { | 178 | if (get_user(c, user_buf)) { |
199 | err = -EFAULT; | 179 | err = -EFAULT; |
200 | goto done; | 180 | goto done; |
201 | } | 181 | } |
@@ -203,16 +183,13 @@ static ssize_t kvmppc_exit_timing_write(struct file *file, | |||
203 | if (c == 'c') { | 183 | if (c == 'c') { |
204 | struct seq_file *seqf = (struct seq_file *)file->private_data; | 184 | struct seq_file *seqf = (struct seq_file *)file->private_data; |
205 | struct kvm_vcpu *vcpu = seqf->private; | 185 | struct kvm_vcpu *vcpu = seqf->private; |
206 | /* write does not affect out buffers previsously generated with | 186 | /* Write does not affect our buffers previously generated with |
207 | * show. Seq file is locked here to prevent races of init with | 187 | * show. seq_file is locked here to prevent races of init with |
208 | * a show call */ | 188 | * a show call */ |
209 | mutex_lock(&seqf->lock); | 189 | mutex_lock(&seqf->lock); |
210 | kvmppc_init_timing_stats(vcpu); | 190 | kvmppc_init_timing_stats(vcpu); |
211 | mutex_unlock(&seqf->lock); | 191 | mutex_unlock(&seqf->lock); |
212 | err = count; | 192 | err = count; |
213 | } else { | ||
214 | err = -EINVAL; | ||
215 | goto done; | ||
216 | } | 193 | } |
217 | 194 | ||
218 | done: | 195 | done: |
@@ -238,7 +215,7 @@ void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id) | |||
238 | static char dbg_fname[50]; | 215 | static char dbg_fname[50]; |
239 | struct dentry *debugfs_file; | 216 | struct dentry *debugfs_file; |
240 | 217 | ||
241 | snprintf(dbg_fname, sizeof(dbg_fname), "vm%u_vcpu%03u_timing", | 218 | snprintf(dbg_fname, sizeof(dbg_fname), "vm%u_vcpu%u_timing", |
242 | current->pid, id); | 219 | current->pid, id); |
243 | debugfs_file = debugfs_create_file(dbg_fname, 0666, | 220 | debugfs_file = debugfs_create_file(dbg_fname, 0666, |
244 | kvm_debugfs_dir, vcpu, | 221 | kvm_debugfs_dir, vcpu, |