mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
numa: Replace NUMA_MAX_N_CPUS macro with virNumaGetMaxCPUs()
This commit is contained in:
parent
5ed9b3bc29
commit
15ca990229
@ -1535,11 +1535,6 @@ nodeGetFreeMemoryFake(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if WITH_NUMACTL
|
#if WITH_NUMACTL
|
||||||
# if LIBNUMA_API_VERSION <= 1
|
|
||||||
# define NUMA_MAX_N_CPUS 4096
|
|
||||||
# else
|
|
||||||
# define NUMA_MAX_N_CPUS (numa_all_cpus_ptr->size)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define n_bits(var) (8 * sizeof(var))
|
# define n_bits(var) (8 * sizeof(var))
|
||||||
# define MASK_CPU_ISSET(mask, cpu) \
|
# define MASK_CPU_ISSET(mask, cpu) \
|
||||||
@ -1559,7 +1554,7 @@ virNodeGetSiblingsList(const char *dir, int cpu_id)
|
|||||||
if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &buf) < 0)
|
if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &buf) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBitmapParse(buf, 0, &ret, NUMA_MAX_N_CPUS) < 0)
|
if (virBitmapParse(buf, 0, &ret, virNumaGetMaxCPUs()) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -1602,7 +1597,7 @@ nodeCapsInitNUMA(virCapsPtr caps)
|
|||||||
unsigned long long memory;
|
unsigned long long memory;
|
||||||
virCapsHostNUMACellCPUPtr cpus = NULL;
|
virCapsHostNUMACellCPUPtr cpus = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int max_n_cpus = NUMA_MAX_N_CPUS;
|
int max_n_cpus = virNumaGetMaxCPUs();
|
||||||
int mask_n_bytes = max_n_cpus / 8;
|
int mask_n_bytes = max_n_cpus / 8;
|
||||||
int ncpus = 0;
|
int ncpus = 0;
|
||||||
bool topology_failed = false;
|
bool topology_failed = false;
|
||||||
|
@ -21,10 +21,18 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#define NUMA_MAX_N_CPUS 4096
|
||||||
|
|
||||||
#if WITH_NUMACTL
|
#if WITH_NUMACTL
|
||||||
# define NUMA_VERSION1_COMPATIBILITY 1
|
# define NUMA_VERSION1_COMPATIBILITY 1
|
||||||
# include <numa.h>
|
# include <numa.h>
|
||||||
#endif
|
|
||||||
|
# if LIBNUMA_API_VERSION > 1
|
||||||
|
# undef NUMA_MAX_N_CPUS
|
||||||
|
# define NUMA_MAX_N_CPUS (numa_all_cpus_ptr->size)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif /* WITH_NUMACTL */
|
||||||
|
|
||||||
#include "virnuma.h"
|
#include "virnuma.h"
|
||||||
#include "vircommand.h"
|
#include "vircommand.h"
|
||||||
@ -288,3 +296,17 @@ virNumaGetNodeMemory(int node ATTRIBUTE_UNUSED,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virNumaGetMaxCPUs:
|
||||||
|
*
|
||||||
|
* Get the maximum count of CPUs supportable in the host.
|
||||||
|
*
|
||||||
|
* Returns the count of CPUs supported.
|
||||||
|
*/
|
||||||
|
unsigned int
|
||||||
|
virNumaGetMaxCPUs(void)
|
||||||
|
{
|
||||||
|
return NUMA_MAX_N_CPUS;
|
||||||
|
}
|
||||||
|
@ -62,4 +62,6 @@ int virNumaGetNodeMemory(int node,
|
|||||||
unsigned long long *memsize,
|
unsigned long long *memsize,
|
||||||
unsigned long long *memfree);
|
unsigned long long *memfree);
|
||||||
|
|
||||||
|
unsigned int virNumaGetMaxCPUs(void);
|
||||||
|
|
||||||
#endif /* __VIR_NUMA_H__ */
|
#endif /* __VIR_NUMA_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user