@@ -904,8 +904,8 @@ int backwards_count;
904
904
char * progname ;
905
905
906
906
#define CPU_SUBSET_MAXCPUS 1024 /* need to use before probe... */
907
- cpu_set_t * cpu_present_set , * cpu_affinity_set , * cpu_subset ;
908
- size_t cpu_present_setsize , cpu_affinity_setsize , cpu_subset_size ;
907
+ cpu_set_t * cpu_present_set , * cpu_allowed_set , * cpu_affinity_set , * cpu_subset ;
908
+ size_t cpu_present_setsize , cpu_allowed_setsize , cpu_affinity_setsize , cpu_subset_size ;
909
909
#define MAX_ADDED_COUNTERS 8
910
910
#define MAX_ADDED_THREAD_COUNTERS 24
911
911
#define BITMASK_SIZE 32
@@ -1157,6 +1157,11 @@ int cpu_is_not_present(int cpu)
1157
1157
return !CPU_ISSET_S (cpu , cpu_present_setsize , cpu_present_set );
1158
1158
}
1159
1159
1160
+ int cpu_is_not_allowed (int cpu )
1161
+ {
1162
+ return !CPU_ISSET_S (cpu , cpu_allowed_setsize , cpu_allowed_set );
1163
+ }
1164
+
1160
1165
/*
1161
1166
* run func(thread, core, package) in topology order
1162
1167
* skip non-present cpus
@@ -3396,6 +3401,10 @@ void free_all_buffers(void)
3396
3401
cpu_present_set = NULL ;
3397
3402
cpu_present_setsize = 0 ;
3398
3403
3404
+ CPU_FREE (cpu_allowed_set );
3405
+ cpu_allowed_set = NULL ;
3406
+ cpu_allowed_setsize = 0 ;
3407
+
3399
3408
CPU_FREE (cpu_affinity_set );
3400
3409
cpu_affinity_set = NULL ;
3401
3410
cpu_affinity_setsize = 0 ;
@@ -5697,13 +5706,29 @@ void topology_probe()
5697
5706
CPU_ZERO_S (cpu_present_setsize , cpu_present_set );
5698
5707
for_all_proc_cpus (mark_cpu_present );
5699
5708
5709
+ /*
5710
+ * Allocate and initialize cpu_allowed_set
5711
+ */
5712
+ cpu_allowed_set = CPU_ALLOC ((topo .max_cpu_num + 1 ));
5713
+ if (cpu_allowed_set == NULL )
5714
+ err (3 , "CPU_ALLOC" );
5715
+ cpu_allowed_setsize = CPU_ALLOC_SIZE ((topo .max_cpu_num + 1 ));
5716
+ CPU_ZERO_S (cpu_allowed_setsize , cpu_allowed_set );
5717
+
5700
5718
/*
5701
5719
* Validate that all cpus in cpu_subset are also in cpu_present_set
5702
5720
*/
5703
5721
for (i = 0 ; i < CPU_SUBSET_MAXCPUS ; ++ i ) {
5704
- if (CPU_ISSET_S (i , cpu_subset_size , cpu_subset ))
5722
+ if (!cpu_subset ) {
5723
+ if (CPU_ISSET_S (i , cpu_present_setsize , cpu_present_set ))
5724
+ CPU_SET_S (i , cpu_allowed_setsize , cpu_allowed_set );
5725
+ continue ;
5726
+ }
5727
+ if (CPU_ISSET_S (i , cpu_subset_size , cpu_subset )) {
5705
5728
if (!CPU_ISSET_S (i , cpu_present_setsize , cpu_present_set ))
5706
5729
err (1 , "cpu%d not present" , i );
5730
+ CPU_SET_S (i , cpu_allowed_setsize , cpu_allowed_set );
5731
+ }
5707
5732
}
5708
5733
5709
5734
/*
0 commit comments