KVM: selftests: Increase 'maxnode' for guest_memfd tests
PATCH v2 1/1 KVM: selftests: Increase 'maxnode' for guest_memfd tests
Increase 'maxnode' when using 'get_mempolicy' syscall in guest_memfd mmap and NUMA policy tests to fix a failure on one Intel GNR platform.
On a CXL-capable platform, the memory affinity of CXL memory regions may not be covered by the SRAT. Since each CXL memory region is enumerated via a CFMWS table, at early boot the kernel parses all CFMWS tables to detect all CXL memory regions and assigns a 'faked' NUMA node for each of them, starting from the highest NUMA node ID enumerated via the SRAT.
This increases the 'nr_node_ids'. E.g., on the aforementioned Intel GNR platform which has 4 NUMA nodes and 18 CFMWS tables, it increases to 22.
This results in the 'get_mempolicy' syscall failure on that platform, because currently 'maxnode' is hard-coded to 8 but the 'get_mempolicy' syscall requires the 'maxnode' to be not smaller than the 'nr_node_ids'.
Increase the 'maxnode' to the number of bits of 'nodemask', which is 'unsigned long', to fix this.
This may not cover all systems. Perhaps a better way is to always set the 'nodemask' and 'maxnode' based on the actual maximum NUMA node ID on the system, but for now just do the simple way.
---
v1 -> v2:
- Add 'Reported-by' and 'Closes" tags. - Sean
- Use BITS_PER_TYPE(). - Sean
- Slightly simplify changelog to simply say "increase 'maxnode' to bits of 'nodemask'" to reflect the code better.
--- tools/testing/selftests/kvm/guest_memfd_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/guest_memfd_test.c +1 -1
@@ -80,7 +80,7 @@ static void test_mbind(int fd, size_t total_size) {const unsigned long nodemask_0 =1 ;/* nid: 0 */ unsigned long nodemask =0 ; -unsigned long maxnode =8 ; +unsigned long maxnode =BITS_PER_TYPE (nodemask);int policy;char *mem;int ret;
base-commit: a91cc48246605af9aeef1edd32232976d74d9502
Signature · 1 line
2.53.0
Quoted 16 lines · Kai Huang
Increase 'maxnode' when using '
get_mempolicy' syscall inguest_memfdmmap and NUMA policy tests to fix a failure on one Intel GNR platform.On a CXL-capable platform, the memory affinity of CXL memory regions may not be covered by the SRAT. Since each CXL memory region is enumerated via a CFMWS table, at early boot the kernel parses all CFMWS tables to detect all CXL memory regions and assigns a 'faked' NUMA node for each of them, starting from the highest NUMA node ID enumerated via the SRAT.
This increases the '
nr_node_ids'. E.g., on the aforementioned Intel GNR platform which has 4 NUMA nodes and 18 CFMWS tables, it increases to 22.This results in the '
get_mempolicy' syscall failure on that platform, because currently 'maxnode' is hard-coded to 8 but the 'get_mempolicy' syscall requires the 'maxnode' to be not smaller than the 'nr_node_ids'.
Quoted 6 lines
Increase the 'maxnode' to the number of bits of 'nodemask', which is 'unsigned long', to fix this.
This may not cover all systems. Perhaps a better way is to always set the 'nodemask' and 'maxnode' based on the actual maximum NUMA node ID on the system, but for now just do the simple way.
Quoted 35 lines
Reported-by Yi Lai <[email protected]>Signed-off-by Kai Huang <[email protected]>---
v1 -> v2:
- Add 'Reported-by' and 'Closes" tags. - Sean
- UseBITS_PER_TYPE(). - Sean
- Slightly simplify changelog to simply say "increase 'maxnode' to bits of 'nodemask'" to reflect the code better.--- tools/testing/selftests/kvm/guest_memfd_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/kvm/guest_memfd_test.c +1
-1@@ -80,7 +80,7 @@ static void test_mbind(int fd, size_t total_size) {const unsigned long nodemask_0 =1 ;/* nid: 0 */ unsigned long nodemask =0 ; -unsigned long maxnode =8 ; +unsigned long maxnode =BITS_PER_TYPE (nodemask);int policy;char *mem;int ret;base-commit:
a91cc48246605af9aeef1edd32232976d74d9502--
2.53.0
Quoted 10 lines · Kai Huang
Increase 'maxnode' when using '
get_mempolicy' syscall inguest_memfdmmap and NUMA policy tests to fix a failure on one Intel GNR platform.On a CXL-capable platform, the memory affinity of CXL memory regions may not be covered by the SRAT. Since each CXL memory region is enumerated via a CFMWS table, at early boot the kernel parses all CFMWS tables to detect all CXL memory regions and assigns a 'faked' NUMA node for each of them, starting from the highest NUMA node ID enumerated via the SRAT.
[...]
Applied to kvm-x86 fixes, thanks!
[1/1] KVM: selftests: Increase 'maxnode' for guest_memfd tests
https://github.com/kvm-x86/linux/commit/afa85076709d