@@ -56,6 +56,7 @@ struct hwloc_linux_backend_data_s {
56
56
} arch ;
57
57
int is_knl ;
58
58
int is_amd_with_CU ;
59
+ int is_fake_numa_uniform ; /* 0 if not fake, -1 if fake non-uniform, N if fake=<N>U */
59
60
int use_numa_distances ;
60
61
int use_numa_distances_for_cpuless ;
61
62
int use_numa_initiators ;
@@ -5531,6 +5532,40 @@ static int check_sysfs_cpu_path(int root_fd, int *old_filenames)
5531
5532
return -1 ;
5532
5533
}
5533
5534
5535
+ static void
5536
+ hwloc_linuxfs_check_kernel_cmdline (struct hwloc_linux_backend_data_s * data )
5537
+ {
5538
+ FILE * file ;
5539
+ char cmdline [4096 ];
5540
+ char * fakenuma ;
5541
+
5542
+ file = hwloc_fopen ("/proc/cmdline" , "r" , data -> root_fd );
5543
+ if (!file )
5544
+ return ;
5545
+
5546
+ cmdline [0 ] = 0 ;
5547
+ fgets (cmdline , sizeof (cmdline ), file );
5548
+
5549
+ fakenuma = strstr (cmdline , "numa=fake=" );
5550
+ if (fakenuma ) {
5551
+ /* in fake numa emulation, SLIT is updated but HMAT isn't, hence we need to disable/fix things later */
5552
+ unsigned width = 0 ;
5553
+ char type = 0 ;
5554
+ if (sscanf (fakenuma + 10 , "%u%c" , & width , & type ) == 2 && type == 'U' ) {
5555
+ /* if <N>U, each node is split in 8 nodes, we can still do things in this case */
5556
+ data -> is_fake_numa_uniform = width ;
5557
+ } else {
5558
+ /* otherwise fake nodes are created by just dividing the entire RAM,
5559
+ * without respecting locality at all
5560
+ */
5561
+ data -> is_fake_numa_uniform = -1 ;
5562
+ }
5563
+ hwloc_debug ("Found fake numa %d\n" , data -> is_fake_numa_uniform );
5564
+ }
5565
+
5566
+ fclose (file );
5567
+ }
5568
+
5534
5569
static int
5535
5570
hwloc_linuxfs_look_cpu (struct hwloc_backend * backend , struct hwloc_disc_status * dstatus )
5536
5571
{
@@ -5583,6 +5618,11 @@ hwloc_linuxfs_look_cpu(struct hwloc_backend *backend, struct hwloc_disc_status *
5583
5618
*/
5584
5619
hwloc_gather_system_info (topology , data );
5585
5620
5621
+ /**********************************
5622
+ * Detect things in /proc/cmdline
5623
+ */
5624
+ hwloc_linuxfs_check_kernel_cmdline (data );
5625
+
5586
5626
/**********************
5587
5627
* /proc/cpuinfo
5588
5628
*/
@@ -7215,6 +7255,7 @@ hwloc_linux_component_instantiate(struct hwloc_topology *topology,
7215
7255
data -> arch = HWLOC_LINUX_ARCH_UNKNOWN ;
7216
7256
data -> is_knl = 0 ;
7217
7257
data -> is_amd_with_CU = 0 ;
7258
+ data -> is_fake_numa_uniform = 0 ;
7218
7259
data -> is_real_fsroot = 1 ;
7219
7260
data -> root_path = NULL ;
7220
7261
fsroot_path = getenv ("HWLOC_FSROOT" );
0 commit comments