add interface providing the free list to the hypervisor (#101)

Add an interface for sharing the free list with the hypervisor. This can be used to accelerate the cold migration of guests.
This commit is contained in:
Simon Pickartz 2018-09-04 13:09:23 +02:00 committed by Stefan Lankes
parent 04f0a001e0
commit 1a8e06a365
8 changed files with 37 additions and 5 deletions

View File

@ -64,6 +64,11 @@ atomic_int64_t total_pages = ATOMIC_INIT(0);
atomic_int64_t total_allocated_pages = ATOMIC_INIT(0);
atomic_int64_t total_available_pages = ATOMIC_INIT(0);
free_list_t *get_free_list(void)
{
return free_start;
}
size_t get_pages(size_t npages)
{
size_t i, ret = 0;

View File

@ -134,6 +134,11 @@ out:
return ret;
}
free_list_t *get_free_list(void)
{
return free_start;
}
size_t get_pages(size_t npages)
{
return __get_pages(npages, PAGE_SIZE);

2
caves

@ -1 +1 @@
Subproject commit 9f19fde7b78ea85d3f7ff06252316f75579df617
Subproject commit 1e1a23bc82a71c5326b1cc0a76883ee2a52a7f3f

View File

@ -58,7 +58,7 @@
#include "uhyve-net.h"
#define UHYVE_IRQ 11
#define UHYVE_IRQ_NET 11
static int8_t uhyve_net_init_ok = 0;
static struct netif* mynetif = NULL;
@ -257,8 +257,8 @@ err_t uhyve_netif_init (struct netif* netif)
LWIP_DEBUGF(NETIF_DEBUG, ("\n"));
uhyve_netif->ethaddr = (struct eth_addr *)netif->hwaddr;
LOG_INFO("uhye_netif uses irq %d\n", UHYVE_IRQ);
irq_install_handler(32+UHYVE_IRQ, uhyve_irqhandler);
LOG_INFO("uhye_netif uses irq %d\n", UHYVE_IRQ_NET);
irq_install_handler(32+UHYVE_IRQ_NET, uhyve_irqhandler);
/*
* Initialize the snmp variables and counters inside the struct netif.

View File

@ -36,12 +36,17 @@
#ifndef __MEMORY_H__
#define __MEMORY_H__
typedef struct free_list free_list_t;
/** @brief Initialize the memory subsystem */
int memory_init(void);
/** @brief Request physical page frames */
size_t get_pages(size_t npages);
/** @brief Returns a pointer to the free_list */
free_list_t *get_free_list(void);
/** @brief Get a single page
*
* Convenience function: uses get_pages(1);

View File

@ -74,6 +74,8 @@ extern size_t image_size;
#define UHYVE_PORT_NETREAD 0x680
#define UHYVE_PORT_NETSTAT 0x700
#define UHYVE_PORT_FREELIST 0x720
/* Ports and data structures for uhyve command line arguments and envp
* forwarding */
#define UHYVE_PORT_CMDSIZE 0x740

View File

@ -37,6 +37,7 @@
#define __VMA_H__
#include <hermit/stddef.h>
#include <hermit/memory.h>
#include <asm/page.h>
#ifdef __cplusplus

View File

@ -32,7 +32,10 @@
#include <hermit/spinlock.h>
#include <hermit/errno.h>
#include <hermit/logging.h>
#include <asm/io.h>
#include <asm/irq.h>
#define UHYVE_IRQ_FREELIST 12
/*
* Note that linker symbols are not variables, they have no memory allocated for
* maintaining a value, rather their address is their value.
@ -49,6 +52,13 @@ static vma_t vma_boot = { VMA_MIN, VMA_MIN, VMA_HEAP };
static vma_t* vma_list = &vma_boot;
spinlock_irqsave_t hermit_mm_lock = SPINLOCK_IRQSAVE_INIT;
typedef struct free_list free_list_t;
static void uhyve_irq_freelist_handler(struct state* s)
{
outportl(UHYVE_PORT_FREELIST, (unsigned)virt_to_phys((size_t)get_free_list()));
}
int vma_init(void)
{
int ret;
@ -68,7 +78,11 @@ int vma_init(void)
ret = vma_add(HEAP_START, HEAP_START+HEAP_SIZE, VMA_NO_ACCESS);
if (BUILTIN_EXPECT(ret, 0))
goto out;
LOG_INFO("Reserve space for the heap: 0x%llx - 0x%llx\n", HEAP_START, HEAP_START+HEAP_SIZE-1);
LOG_INFO("Reserve space for the heap: 0x%llx - 0x%llx\n", HEAP_START, HEAP_START+HEAP_SIZE-1);
// install IRQ handler for the migration interface
LOG_INFO("freelist channel uses irq %d\n", UHYVE_IRQ_FREELIST);
irq_install_handler(32+UHYVE_IRQ_FREELIST, uhyve_irq_freelist_handler);
// we might move the architecture specific VMA regions to a
// seperate function vma_arch_init()