6bea1ddf8b
Replace repeated pattern for (i = 0; i < nb_numa_nodes; i++) { if (test_bit(idx, numa_info[i].node_cpu)) { ... break; with a helper function to lookup numa node index for cpu. Suggested-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
39 lines
1.1 KiB
C
39 lines
1.1 KiB
C
#ifndef SYSEMU_NUMA_H
|
|
#define SYSEMU_NUMA_H
|
|
|
|
#include "qemu/bitmap.h"
|
|
#include "qemu/option.h"
|
|
#include "sysemu/sysemu.h"
|
|
#include "sysemu/hostmem.h"
|
|
#include "hw/boards.h"
|
|
|
|
extern int nb_numa_nodes; /* Number of NUMA nodes */
|
|
|
|
struct numa_addr_range {
|
|
ram_addr_t mem_start;
|
|
ram_addr_t mem_end;
|
|
QLIST_ENTRY(numa_addr_range) entry;
|
|
};
|
|
|
|
typedef struct node_info {
|
|
uint64_t node_mem;
|
|
DECLARE_BITMAP(node_cpu, MAX_CPUMASK_BITS);
|
|
struct HostMemoryBackend *node_memdev;
|
|
bool present;
|
|
QLIST_HEAD(, numa_addr_range) addr; /* List to store address ranges */
|
|
} NodeInfo;
|
|
|
|
extern NodeInfo numa_info[MAX_NODES];
|
|
void parse_numa_opts(MachineClass *mc);
|
|
void numa_post_machine_init(void);
|
|
void query_numa_node_mem(uint64_t node_mem[]);
|
|
extern QemuOptsList qemu_numa_opts;
|
|
void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node);
|
|
void numa_unset_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node);
|
|
uint32_t numa_get_node(ram_addr_t addr, Error **errp);
|
|
|
|
/* on success returns node index in numa_info,
|
|
* on failure returns nb_numa_nodes */
|
|
int numa_get_node_for_cpu(int idx);
|
|
#endif
|