How to confirm NUMA?

前端 未结 2 732
余生分开走
余生分开走 2021-02-06 05:27

How can I confirm that a host is NUMA-aware? The Oracle doc says that NUMA-awareness starts at kernel 2.6.19, but the NUMA man page says that it was introduced with 2.6.14. I\

2条回答
  •  借酒劲吻你
    2021-02-06 06:19

    The Oracle doc also states:

    Note: There was a known bug in the Linux Kernel that may cause the JVM to crash when being t with -XX:UseNUMA. The bug was fixed in 2012, so this should not affect the latest versions of the Linux Kernel. To see if your Kernel has this bug, you can run the native reproducer.

    Which I have reproduced here to demonstrate its simplicity:

    http://docs.oracle.com/javase/7/docs/technotes/guides/vm/reproducer.c

    To build the reproducer, you may need to install the numactl or numactl-devel packages depending on your distribution. See man numa_maps for details.

    #include 
    #include 
    #include 
    #include 
    #include 
    
    int main(void) {
       if (numa_all_nodes_ptr == (void*)0) {
         return -1;
       }
    
       size_t pagesize = getpagesize();
    
       void* mapped_memory = mmap(NULL, 3 * pagesize, PROT_READ|PROT_WRITE,
    MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
       if (mapped_memory == MAP_FAILED) {
         return -2;
       }
    
       void* page0 = mapped_memory;
       void* page1 = (void*)((uintptr_t)page0 + pagesize);
       void* page2 = (void*)((uintptr_t)page1 + pagesize); 
    
     // Set up the last page as interleaved.
       mbind(page2, pagesize, MPOL_INTERLEAVE, numa_all_nodes_ptr->maskp,
    numa_all_nodes_ptr->size, 0);
    
       // Setup the last two pages as interleaved.
       mbind(page1, 2 * pagesize, MPOL_INTERLEAVE,
    numa_all_nodes_ptr->maskp, numa_all_nodes_ptr->size, 0);
    
       *((char*)page2) = 2;
       *((char*)page1) = 1;
       *((char*)page0) = 0; // Crash here, when mbind_merge was broken.
    
       return 0;
    }
    

    So, I took the ambiguity to mean that 2.6.19 was the first safe version.

提交回复
热议问题