qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v5 02/10] kvm: Support for querying fd-based stats


From: Paolo Bonzini
Subject: Re: [PATCH v5 02/10] kvm: Support for querying fd-based stats
Date: Wed, 8 Jun 2022 17:58:09 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0

On 6/8/22 16:52, Dr. David Alan Gilbert wrote:
If you mean why not some other source, each source has a different file
descriptor:

+    int stats_fd = kvm_vcpu_ioctl(cpu, KVM_GET_STATS_FD, NULL);

but the descriptors are consistent every time KVM_GET_STATS_FD is called, so
basically "ident" can be used as a cache key.

Ah OK, this is what I was after; it's a little weird that the caller
does the ioctl to get the stats-fd, but it does the lookup internally
with current_cpu for the ident.

Oh yeah that's weird.

Let me squash in this:

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 023bf4ea79..71896ad173 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3871,17 +3871,7 @@ static StatsDescriptors 
*find_stats_descriptors(StatsTarget target, int stats_fd
     size_t size_desc;
     ssize_t ret;
- switch (target) {
-    case STATS_TARGET_VM:
-        ident = StatsTarget_str(STATS_TARGET_VM);
-        break;
-    case STATS_TARGET_VCPU:
-        ident = current_cpu->parent_obj.canonical_path;
-        break;
-    default:
-        abort();
-    }
-
+    ident = StatsTarget_str(target);
     QTAILQ_FOREACH(descriptors, &stats_descriptors, next) {
         if (g_str_equal(descriptors->ident, ident)) {
             return descriptors;
@@ -3917,7 +3907,7 @@ static StatsDescriptors 
*find_stats_descriptors(StatsTarget target, int stats_fd
     }
     descriptors->kvm_stats_header = kvm_stats_header;
     descriptors->kvm_stats_desc = kvm_stats_desc;
-    descriptors->ident = g_strdup(ident);
+    descriptors->ident = ident;
     QTAILQ_INSERT_TAIL(&stats_descriptors, descriptors, next);
     return descriptors;
 }

(once I test it).

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]