From: Peter Dinda Date: Fri, 28 Jun 2013 20:00:35 +0000 (-0500) Subject: added NUMA interface files to pass NUMA layout between host and Palacios X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=c8cd507ac7d45e737267a4a47199b1fef6f35ba0 added NUMA interface files to pass NUMA layout between host and Palacios --- diff --git a/palacios/include/interfaces/vmm_numa.h b/palacios/include/interfaces/vmm_numa.h new file mode 100644 index 0000000..f41fc92 --- /dev/null +++ b/palacios/include/interfaces/vmm_numa.h @@ -0,0 +1,50 @@ +/* + * This file is part of the Palacios Virtual Machine Monitor developed + * by the V3VEE Project with funding from the United States National + * Science Foundation and the Department of Energy. + * + * The V3VEE Project is a joint project between Northwestern University + * and the University of New Mexico. You can find out more at + * http://www.v3vee.org + * + * Copyright (c) 2013, Jack Lange + * Copyright (c) 2013, The V3VEE Project + * All rights reserved. + * + * Author: Jack Lange + * + * This is free software. You are permitted to use, + * redistribute, and modify it as specified in the file "V3VEE_LICENSE". + */ + + + +#ifndef __VMM_NUMA_INTERFACE_H_ +#define __VMM_NUMA_INTERFACE_H_ + + +#ifdef __V3VEE__ + +#include +#include + +int v3_numa_gpa_to_node(struct v3_vm_info * vm, addr_t gpa); +int v3_numa_hpa_to_node(addr_t hpa); +int v3_numa_cpu_to_node(uint32_t cpu); +int v3_numa_get_distance(uint32_t node1, uint32_t node2); + +#endif + + +struct v3_numa_hooks { + int (*cpu_to_node)(int phys_cpu_id); + int (*phys_addr_to_node)(void * addr); + int (*get_distance)(int node1, int node2); +}; + + + +extern void V3_Init_NUMA(struct v3_numa_hooks * hooks); + + +#endif diff --git a/palacios/src/interfaces/vmm_numa.c b/palacios/src/interfaces/vmm_numa.c new file mode 100644 index 0000000..9630cd9 --- /dev/null +++ b/palacios/src/interfaces/vmm_numa.c @@ -0,0 +1,77 @@ +/* + * This file is part of the Palacios Virtual Machine Monitor developed + * by the V3VEE Project with funding from the United States National + * Science Foundation and the Department of Energy. + * + * The V3VEE Project is a joint project between Northwestern University + * and the University of New Mexico. You can find out more at + * http://www.v3vee.org + * + * Copyright (c) 2013, Jack Lange + * Copyright (c) 2013, The V3VEE Project + * All rights reserved. + * + * Author: Jack Lange + * + * This is free software. You are permitted to use, + * redistribute, and modify it as specified in the file "V3VEE_LICENSE". + */ + + +#include +#include +#include +#include + + +static struct v3_numa_hooks * numa_hooks = NULL; + +void V3_Init_NUMA(struct v3_numa_hooks * hooks) { + numa_hooks = hooks; + V3_Print("V3 NUMA interface initialized\n"); + return; +} + +int v3_numa_hpa_to_node(addr_t hpa) { + if (!numa_hooks) { + return 0; + } + + return numa_hooks->phys_addr_to_node((void *)hpa); +} + + +int v3_numa_gpa_to_node(struct v3_vm_info * vm, addr_t gpa) { + addr_t hpa = 0; + + if (!numa_hooks) { + return 0; + } + + if (v3_gpa_to_hpa(&(vm->cores[0]), gpa, &hpa) == -1) { + PrintError("Tried to find NUMA node for invalid GPA (%p)\n", (void *)gpa); + return -1; + } + + return numa_hooks->phys_addr_to_node((void *)hpa); + +} + +int v3_numa_cpu_to_node(uint32_t cpu) { + + if (!numa_hooks){ + return 0; + } + + return numa_hooks->cpu_to_node(cpu); +} + +int v3_numa_get_distance(uint32_t node1, uint32_t node2) { + + if (!numa_hooks) { + return 0; + } + + + return numa_hooks->get_distance(node1, node2); +}