vhost: add device op when notification to guest is sent
This patch adds an operation callback which gets called every time the library is waking up the guest trough an eventfd_write() call. This can be used by 3rd party application, like OVS, to track the number of times interrupts where generated. This might be of interest to find out system-call were called in the fast path. Signed-off-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
This commit is contained in:
parent
52b5a707e6
commit
039253166a
@ -172,7 +172,15 @@ struct vhost_device_ops {
|
|||||||
int (*new_connection)(int vid);
|
int (*new_connection)(int vid);
|
||||||
void (*destroy_connection)(int vid);
|
void (*destroy_connection)(int vid);
|
||||||
|
|
||||||
void *reserved[2]; /**< Reserved for future extension */
|
/**
|
||||||
|
* This callback gets called each time a guest gets notified
|
||||||
|
* about waiting packets. This is the interrupt handling trough
|
||||||
|
* the eventfd_write(callfd), which can be used for counting these
|
||||||
|
* "slow" syscalls.
|
||||||
|
*/
|
||||||
|
void (*guest_notified)(int vid);
|
||||||
|
|
||||||
|
void *reserved[1]; /**< Reserved for future extension */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -543,13 +543,19 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
|
|||||||
|
|
||||||
if ((vhost_need_event(vhost_used_event(vq), new, old) &&
|
if ((vhost_need_event(vhost_used_event(vq), new, old) &&
|
||||||
(vq->callfd >= 0)) ||
|
(vq->callfd >= 0)) ||
|
||||||
unlikely(!signalled_used_valid))
|
unlikely(!signalled_used_valid)) {
|
||||||
eventfd_write(vq->callfd, (eventfd_t) 1);
|
eventfd_write(vq->callfd, (eventfd_t) 1);
|
||||||
|
if (dev->notify_ops->guest_notified)
|
||||||
|
dev->notify_ops->guest_notified(dev->vid);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Kick the guest if necessary. */
|
/* Kick the guest if necessary. */
|
||||||
if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
|
if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
|
||||||
&& (vq->callfd >= 0))
|
&& (vq->callfd >= 0)) {
|
||||||
eventfd_write(vq->callfd, (eventfd_t)1);
|
eventfd_write(vq->callfd, (eventfd_t)1);
|
||||||
|
if (dev->notify_ops->guest_notified)
|
||||||
|
dev->notify_ops->guest_notified(dev->vid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,8 +606,11 @@ vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)
|
|||||||
if (vhost_need_event(off, new, old))
|
if (vhost_need_event(off, new, old))
|
||||||
kick = true;
|
kick = true;
|
||||||
kick:
|
kick:
|
||||||
if (kick)
|
if (kick) {
|
||||||
eventfd_write(vq->callfd, (eventfd_t)1);
|
eventfd_write(vq->callfd, (eventfd_t)1);
|
||||||
|
if (dev->notify_ops->guest_notified)
|
||||||
|
dev->notify_ops->guest_notified(dev->vid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __rte_always_inline void
|
static __rte_always_inline void
|
||||||
|
Loading…
Reference in New Issue
Block a user