Message ID | 20220415201542.1496582-2-oupton@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: Clean up debugfs+stats init/destroy | expand |
On Fri, Apr 15, 2022, Oliver Upton wrote: > The field is only ever used for debugfs; put the initialization where > it belongs. No? static ssize_t kvm_vm_stats_read(struct file *file, char __user *user_buffer, size_t size, loff_t *offset) { struct kvm *kvm = file->private_data; return kvm_stats_read(kvm->stats_id, &kvm_vm_stats_header, &kvm_vm_stats_desc[0], &kvm->stat, sizeof(kvm->stat), user_buffer, size, offset); } static const struct file_operations kvm_vm_stats_fops = { .read = kvm_vm_stats_read, .llseek = noop_llseek, }; And with a name like kvm->stats_id, debugfs seems like it's piggbacking stats, not the other way 'round.
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index d292c4397579..ec9c6aad041b 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -955,6 +955,9 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd) int kvm_debugfs_num_entries = kvm_vm_stats_header.num_desc + kvm_vcpu_stats_header.num_desc; + snprintf(kvm->stats_id, sizeof(kvm->stats_id), + "kvm-%d", task_pid_nr(current)); + if (!debugfs_initialized()) return 0; @@ -4765,9 +4768,6 @@ static int kvm_dev_ioctl_create_vm(unsigned long type) if (r < 0) goto put_kvm; - snprintf(kvm->stats_id, sizeof(kvm->stats_id), - "kvm-%d", task_pid_nr(current)); - file = anon_inode_getfile("kvm-vm", &kvm_vm_fops, kvm, O_RDWR); if (IS_ERR(file)) { put_unused_fd(r);
The field is only ever used for debugfs; put the initialization where it belongs. Signed-off-by: Oliver Upton <oupton@google.com> --- virt/kvm/kvm_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)