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 16:13:35 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0

On 6/7/22 19:44, Dr. David Alan Gilbert wrote:

+        return NULL;
+    }
+    descriptors->kvm_stats_header = kvm_stats_header;
+    descriptors->kvm_stats_desc = kvm_stats_desc;
+    descriptors->ident = g_strdup(ident);

There's something that confuses me here; you check your set of
descriptors above to find any with the matching ident, and if you've
already got it you return it; OK.  Now, if you don't match then you
read some stats and store it with that ident - but I don't see
when you read the stats from the fd, what makes it read the stats that
correspond to 'ident' ?

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.

If you mean how does it access the right stat, here it uses the offset
field in the descriptor

ret = pread(stats_fd, stats_data, size_data, kvm_stats_header->data_offset);
    ...
    for (i = 0; i < kvm_stats_header->num_desc; ++i) {
        uint64_t *stats;
        pdesc = (void *)kvm_stats_desc + i * size_desc;

        /* Add entry to the list */
        stats = (void *)stats_data + pdesc->offset;

Paolo



reply via email to

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