Skip to content

Commit

Permalink
add interface providing the free list to the hypervisor (hermit-os#101)
Browse files Browse the repository at this point in the history
Add an interface for sharing the free list with the hypervisor. This can be used to accelerate the cold migration of guests.
  • Loading branch information
Simon Pickartz authored and stlankes committed Sep 4, 2018
1 parent 04f0a00 commit 1a8e06a
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 5 deletions.
5 changes: 5 additions & 0 deletions arch/aarch64/mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions arch/x86_64/mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ static size_t __get_pages(size_t npages, size_t align)
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);
Expand Down
2 changes: 1 addition & 1 deletion caves
Submodule caves updated from 9f19fd to 1e1a23
6 changes: 3 additions & 3 deletions drivers/net/uhyve-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions include/hermit/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions include/hermit/stddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions include/hermit/vma.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#define __VMA_H__

#include <hermit/stddef.h>
#include <hermit/memory.h>
#include <asm/page.h>

#ifdef __cplusplus
Expand Down
16 changes: 15 additions & 1 deletion mm/vma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand All @@ -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()
Expand Down

0 comments on commit 1a8e06a

Please sign in to comment.