Sean Christopherson seanjc@google.com 于2023年6月29日周四 05:19写道:
On Wed, Jun 07, 2023, Jinrong Liang wrote:
-static struct kvm_pmu_event_filter *remove_event(struct kvm_pmu_event_filter *f, +static struct kvm_pmu_event_filter *remove_event(struct __kvm_pmu_event_filter *__f, uint64_t event)
Can you tack on a patch to drop the return? None of the callers consume it, and it incorrectly implies that the incoming filter isn't modified.
Thank you very much for your suggestion! I'm more than happy to follow your advice and modify the code accordingly.
{ bool found = false; int i;
struct kvm_pmu_event_filter *f = (void *)__f;
Nit, reverse xmas tree is preferred:
struct kvm_pmu_event_filter *f = (void *)__f; bool found = false; int i;
Hoever, I don't think this one needs to cast, the cast is only necessary when invoking a KVM ioctl(), e.g. I believe this should work:
static void remove_event(struct __kvm_pmu_event_filter *f, uint64_t event) { bool found = false; int i;
for (i = 0; i < f->nevents; i++) { if (found) f->events[i - 1] = f->events[i]; else found = f->events[i] == event; } if (found) f->nevents--;
}
@@ -569,19 +554,16 @@ static void run_masked_events_test(struct kvm_vcpu *vcpu, const uint64_t masked_events[], const int nmasked_events) {
struct kvm_pmu_event_filter *f;
struct __kvm_pmu_event_filter f = {
.nevents = nmasked_events,
.action = KVM_PMU_EVENT_ALLOW,
.flags = KVM_PMU_EVENT_FLAG_MASKED_EVENTS,
Tabs, not spaces please.
+static int set_pmu_single_event_filter(struct kvm_vcpu *vcpu, uint64_t event,
uint32_t flags, uint32_t action)
+{
struct __kvm_pmu_event_filter f = {
.nevents = 1,
.flags = flags,
.action = action,
.events = {
event,
Tabs.
I will include these change in the new patch version and ensure that any related code is adjusted accordingly.
Once again, I truly appreciate your guidance!