Skip to content

Commit 1a8e06a

Browse files
Simon Pickartzstlankes
authored andcommitted
add interface providing the free list to the hypervisor (hermit-os#101)
Add an interface for sharing the free list with the hypervisor. This can be used to accelerate the cold migration of guests.
1 parent 04f0a00 commit 1a8e06a

File tree

8 files changed

+37
-5
lines changed

8 files changed

+37
-5
lines changed

arch/aarch64/mm/memory.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ atomic_int64_t total_pages = ATOMIC_INIT(0);
6464
atomic_int64_t total_allocated_pages = ATOMIC_INIT(0);
6565
atomic_int64_t total_available_pages = ATOMIC_INIT(0);
6666

67+
free_list_t *get_free_list(void)
68+
{
69+
return free_start;
70+
}
71+
6772
size_t get_pages(size_t npages)
6873
{
6974
size_t i, ret = 0;

arch/x86_64/mm/memory.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ static size_t __get_pages(size_t npages, size_t align)
134134
return ret;
135135
}
136136

137+
free_list_t *get_free_list(void)
138+
{
139+
return free_start;
140+
}
141+
137142
size_t get_pages(size_t npages)
138143
{
139144
return __get_pages(npages, PAGE_SIZE);

caves

Submodule caves updated from 9f19fde to 1e1a23b

drivers/net/uhyve-net.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
#include "uhyve-net.h"
6060

61-
#define UHYVE_IRQ 11
61+
#define UHYVE_IRQ_NET 11
6262

6363
static int8_t uhyve_net_init_ok = 0;
6464
static struct netif* mynetif = NULL;
@@ -257,8 +257,8 @@ err_t uhyve_netif_init (struct netif* netif)
257257
LWIP_DEBUGF(NETIF_DEBUG, ("\n"));
258258
uhyve_netif->ethaddr = (struct eth_addr *)netif->hwaddr;
259259

260-
LOG_INFO("uhye_netif uses irq %d\n", UHYVE_IRQ);
261-
irq_install_handler(32+UHYVE_IRQ, uhyve_irqhandler);
260+
LOG_INFO("uhye_netif uses irq %d\n", UHYVE_IRQ_NET);
261+
irq_install_handler(32+UHYVE_IRQ_NET, uhyve_irqhandler);
262262

263263
/*
264264
* Initialize the snmp variables and counters inside the struct netif.

include/hermit/memory.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@
3636
#ifndef __MEMORY_H__
3737
#define __MEMORY_H__
3838

39+
typedef struct free_list free_list_t;
40+
3941
/** @brief Initialize the memory subsystem */
4042
int memory_init(void);
4143

4244
/** @brief Request physical page frames */
4345
size_t get_pages(size_t npages);
4446

47+
/** @brief Returns a pointer to the free_list */
48+
free_list_t *get_free_list(void);
49+
4550
/** @brief Get a single page
4651
*
4752
* Convenience function: uses get_pages(1);

include/hermit/stddef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ extern size_t image_size;
7474
#define UHYVE_PORT_NETREAD 0x680
7575
#define UHYVE_PORT_NETSTAT 0x700
7676

77+
#define UHYVE_PORT_FREELIST 0x720
78+
7779
/* Ports and data structures for uhyve command line arguments and envp
7880
* forwarding */
7981
#define UHYVE_PORT_CMDSIZE 0x740

include/hermit/vma.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#define __VMA_H__
3838

3939
#include <hermit/stddef.h>
40+
#include <hermit/memory.h>
4041
#include <asm/page.h>
4142

4243
#ifdef __cplusplus

mm/vma.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
#include <hermit/spinlock.h>
3333
#include <hermit/errno.h>
3434
#include <hermit/logging.h>
35+
#include <asm/io.h>
36+
#include <asm/irq.h>
3537

38+
#define UHYVE_IRQ_FREELIST 12
3639
/*
3740
* Note that linker symbols are not variables, they have no memory allocated for
3841
* maintaining a value, rather their address is their value.
@@ -49,6 +52,13 @@ static vma_t vma_boot = { VMA_MIN, VMA_MIN, VMA_HEAP };
4952
static vma_t* vma_list = &vma_boot;
5053
spinlock_irqsave_t hermit_mm_lock = SPINLOCK_IRQSAVE_INIT;
5154

55+
typedef struct free_list free_list_t;
56+
57+
static void uhyve_irq_freelist_handler(struct state* s)
58+
{
59+
outportl(UHYVE_PORT_FREELIST, (unsigned)virt_to_phys((size_t)get_free_list()));
60+
}
61+
5262
int vma_init(void)
5363
{
5464
int ret;
@@ -68,7 +78,11 @@ int vma_init(void)
6878
ret = vma_add(HEAP_START, HEAP_START+HEAP_SIZE, VMA_NO_ACCESS);
6979
if (BUILTIN_EXPECT(ret, 0))
7080
goto out;
71-
LOG_INFO("Reserve space for the heap: 0x%llx - 0x%llx\n", HEAP_START, HEAP_START+HEAP_SIZE-1);
81+
LOG_INFO("Reserve space for the heap: 0x%llx - 0x%llx\n", HEAP_START, HEAP_START+HEAP_SIZE-1);
82+
83+
// install IRQ handler for the migration interface
84+
LOG_INFO("freelist channel uses irq %d\n", UHYVE_IRQ_FREELIST);
85+
irq_install_handler(32+UHYVE_IRQ_FREELIST, uhyve_irq_freelist_handler);
7286

7387
// we might move the architecture specific VMA regions to a
7488
// seperate function vma_arch_init()

0 commit comments

Comments
 (0)