vNUMA : public interface diff --git a/xen/include/public/arch-x86/dom_numa.h b/xen/include/public/arch-x86/dom_numa.h new file mode 100644 --- /dev/null +++ b/xen/include/public/arch-x86/dom_numa.h @@ -0,0 +1,91 @@ +/****************************************************************************** + * dom_numa.h + * + * Guest NUMA common structures. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author : Dulloor Rao + */ +#ifndef __XEN_PUBLIC_DOM_NUMA_X86_H__ +#define __XEN_PUBLIC_DOM_NUMA_X86_H__ + +#define XEN_MAX_VCPUS 128 + +/* vnodes are 1GB-aligned */ +#define XEN_MIN_VNODE_SHIFT (30) +#define XEN_INVALID_NODE (0xFF) + +struct xen_vnode_info { + uint8_t mnode_id; /* physical node vnode is allocated from */ + uint32_t start; /* start of the vnode range (in pages) */ + uint32_t end; /* end of the vnode range (in pages) */ +}; + +/* version : Interface version */ +#define XEN_DOM_NUMA_INTERFACE_VERSION 0x01 + +/* type : On NUMA platforms, the VM memory could be distributed across + * nodes in different ways. + */ +#define XEN_DOM_NUMA_CONFINE 0x01 /* Non-NUMA VM confined to a node */ +#define XEN_DOM_NUMA_SPLIT 0x02 /* NUMA VM split across nodes */ +#define XEN_DOM_NUMA_STRIPE 0x03 /* Non-NUMA VM striped across nodes */ +#define XEN_DOM_NUMA_DONTCARE 0x04 /* Ad-hoc allocation */ + +/* xen_domain_numa_info : + * For PV VMs, this is the NUMA enlightenment structure. + * For HVMs, this structure is shared with the domain builder (hvmloader). + * Size of data[] depends on nr_vnodes and nr_vcpus. + */ + +/* Macros to access data structures in dynamic data[] field. + * nr_vcpus and nr_vnodes must be initialized in the xen_domain_numa_info + * structure before calling these macros. */ +#define NUMA_INFO_SIZE(pinfo) \ + (sizeof(*pinfo) \ + + pinfo->nr_vnodes*sizeof(struct xen_vnode_info) \ + + pinfo->nr_vcpus*sizeof(uint8_t) \ + + pinfo->nr_vnodes*pinfo->nr_vnodes*sizeof(uint8_t)) + +#define NUMA_INFO_VNODE_INFO(pinfo) \ + (struct xen_vnode_info *)((uint8_t *)pinfo + sizeof(*pinfo)) + +#define NUMA_INFO_VCPU_TO_VNODE(pinfo) \ + (uint8_t *)((uint8_t *)NUMA_INFO_VNODE_INFO(pinfo) \ + + pinfo->nr_vnodes*sizeof(struct xen_vnode_info)) + +#define NUMA_INFO_VNODE_DISTANCE(pinfo) \ + (uint8_t *)((uint8_t *)NUMA_INFO_VCPU_TO_VNODE(pinfo) \ + + pinfo->nr_vcpus*sizeof(uint8_t)) + +struct xen_domain_numa_info { + uint8_t version; /* Interface version */ + uint8_t type; /* VM memory allocation scheme (see above) */ + + uint8_t nr_vcpus; + uint8_t nr_vnodes; + /* data[] has the following entries : + * //Only (nr_vnodes) entries are filled, each sizeof(struct xen_vnode_info) + * struct xen_vnode_info vnode_info[nr_vnodes]; + * //Only (nr_vcpus) entries are filled, each sizeof(uint8_t) + * uint8_t vcpu_to_vnode[nr_vcpus]; + * //Only (nr_vnodes*nr_vnodes) entries are filled, each sizeof(uint8_t) + * uint8_t vnode_distance[nr_vnodes*nr_vnodes]; + */ + uint8_t data[0]; +}; + +#endif diff --git a/xen/include/public/dom_numa.h b/xen/include/public/dom_numa.h new file mode 100644 --- /dev/null +++ b/xen/include/public/dom_numa.h @@ -0,0 +1,33 @@ +/****************************************************************************** + * dom_numa.h + * + * Guest NUMA common structures. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author : Dulloor Rao + */ + +#ifndef __XEN_PUBLIC_DOM_NUMA_H +#define __XEN_PUBLIC_DOM_NUMA_H + +#if defined(__i386__) || defined(__x86_64__) +#include "./arch-x86/dom_numa.h" +#else +#error "unsupported architecture" +#endif + + +#endif