1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-30 00:00:15 +01:00

reduce the number of interrupts in the network driver

This commit is contained in:
Stefan Lankes 2017-11-22 00:47:29 +01:00
parent 5edefa8a89
commit 54bb7a84d9
2 changed files with 10 additions and 2 deletions

View file

@ -195,7 +195,7 @@ static void uhyve_netif_poll(void)
struct pbuf *p = NULL;
struct pbuf *q;
if (uhyve_net_read_sync(uhyve_netif->rx_buf, &len) == 0)
while (uhyve_net_read_sync(uhyve_netif->rx_buf, &len) == 0)
{
#if ETH_PAD_SIZE
len += ETH_PAD_SIZE; /*allow room for Ethernet padding */

View file

@ -46,6 +46,7 @@
#include <signal.h>
#include <limits.h>
#include <pthread.h>
#include <semaphore.h>
#include <elf.h>
#include <err.h>
#include <poll.h>
@ -189,6 +190,7 @@ static pthread_barrier_t barrier;
static __thread struct kvm_run *run = NULL;
static __thread int vcpufd = -1;
static __thread uint32_t cpuid = 0;
static sem_t net_sem;
int uhyve_argc = -1;
int uhyve_envc = -1;
@ -754,6 +756,7 @@ static void* wait_for_packet(void* arg)
else if (ret) {
uint64_t event_counter = 1;
write(efd, &event_counter, sizeof(event_counter));
sem_wait(&net_sem);
}
}
@ -771,6 +774,8 @@ static inline void check_network(void)
irqfd.gsi = UHYVE_IRQ;
kvm_ioctl(vmfd, KVM_IRQFD, &irqfd);
sem_init(&net_sem, 0, 0);
if (pthread_create(&net_thread, NULL, wait_for_packet, NULL))
err(1, "unable to create thread");
}
@ -894,7 +899,10 @@ static int vcpu_loop(void)
if (ret > 0) {
uhyve_netread->len = ret;
uhyve_netread->ret = 0;
} else uhyve_netread->ret = -1;
} else {
uhyve_netread->ret = -1;
sem_post(&net_sem);
}
break;
}