Skip to content

Commit

Permalink
kvm/eventfd: use list_for_each_entry when deassign ioeventfd
Browse files Browse the repository at this point in the history
Simpify kvm_deassign_ioeventfd_idx to use list_for_each_entry as the
loop just ends at the entry that's found and deleted.

Note, coalesced_mmio_ops and ioeventfd_ops are the only instances of
kvm_io_device_ops that implement a destructor, all other callers of
kvm_io_bus_unregister_dev() are unaffected by this change.

Suggested-by: Michal Luczaj <[email protected]>
Signed-off-by: Wei Wang <[email protected]>
Reviewed-by: Sean Christopherson <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[sean: call out that only select users implement a destructor]
Signed-off-by: Sean Christopherson <[email protected]>
  • Loading branch information
wei-w-wang authored and sean-jc committed Jun 13, 2023
1 parent 5ea5ca3 commit cc77b95
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions virt/kvm/eventfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ static int
kvm_deassign_ioeventfd_idx(struct kvm *kvm, enum kvm_bus bus_idx,
struct kvm_ioeventfd *args)
{
struct _ioeventfd *p, *tmp;
struct _ioeventfd *p;
struct eventfd_ctx *eventfd;
struct kvm_io_bus *bus;
int ret = -ENOENT;
Expand All @@ -915,8 +915,7 @@ kvm_deassign_ioeventfd_idx(struct kvm *kvm, enum kvm_bus bus_idx,

mutex_lock(&kvm->slots_lock);

list_for_each_entry_safe(p, tmp, &kvm->ioeventfds, list) {

list_for_each_entry(p, &kvm->ioeventfds, list) {
if (p->bus_idx != bus_idx ||
p->eventfd != eventfd ||
p->addr != args->addr ||
Expand Down

0 comments on commit cc77b95

Please sign in to comment.