Skip to content

Commit d74e6e2

Browse files
committed
tools/power/x86/intel-speed-select: Prevent increasing MAX_DIE_PER_PACKAGE
In the function for_each_online_power_domain_in_set() to pick one CPU from each power domain a three-dimensional array is used, which assumes that a package contains multiple dies, that means the die_id from /sys/devices/system/cpu/cpu0/topology/die_id is only local to package. If it is not unique, still there will be no functional issues in the current generation of products, but the MAX_DIE_PER_PACKAGE will need to be increased for future products with many packages. After kernel version 6.9 die ID is unique system wide not per package. Even if the CPU topology has no dies, the ID will still increment across package. In this case the die_id in package 0 will be 0 and die_id in package 1 will be 1 in a 2-package system. Since the die count must be same for packages, just count the number of dies in package 0 and calculate die index from /sys/devices/system/cpu/cpu0/topology/die_id which is only unique within a package. In this way the array size "int cpus[MAX_PACKAGE_COUNT][MAX_DIE_PER_PACKAGE][MAX_PUNIT_PER_DIE]" doesn't have to increase with increasing package count. No functional change is expected. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
1 parent 6ad1b2d commit d74e6e2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tools/power/x86/intel-speed-select/isst-config.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static int fact_enable_fail;
4848
static int cgroupv2;
4949
static int max_die_id;
5050
static int max_punit_id;
51+
static int max_die_id_package_0;
5152

5253
/* clos related */
5354
static int current_clos = -1;
@@ -557,6 +558,8 @@ void for_each_online_power_domain_in_set(void (*callback)(struct isst_id *, void
557558
if (id.pkg < 0 || id.die < 0 || id.punit < 0)
558559
continue;
559560

561+
id.die = id.die % (max_die_id_package_0 + 1);
562+
560563
valid_mask[id.pkg][id.die] = 1;
561564

562565
if (cpus[id.pkg][id.die][id.punit] == -1)
@@ -568,7 +571,7 @@ void for_each_online_power_domain_in_set(void (*callback)(struct isst_id *, void
568571
for (k = 0; k < MAX_PUNIT_PER_DIE && k < MAX_DIE_PER_PACKAGE; k++) {
569572
id.cpu = cpus[i][k][k];
570573
id.pkg = i;
571-
id.die = k;
574+
id.die = get_physical_die_id(id.cpu);
572575
id.punit = k;
573576
if (isst_is_punit_valid(&id))
574577
callback(&id, arg1, arg2, arg3, arg4);
@@ -586,7 +589,10 @@ void for_each_online_power_domain_in_set(void (*callback)(struct isst_id *, void
586589
for (k = 0; k < MAX_PUNIT_PER_DIE; k++) {
587590
id.cpu = cpus[i][j][k];
588591
id.pkg = i;
589-
id.die = j;
592+
if (id.cpu >= 0)
593+
id.die = get_physical_die_id(id.cpu);
594+
else
595+
id.die = id.pkg;
590596
id.punit = k;
591597
if (isst_is_punit_valid(&id))
592598
callback(&id, arg1, arg2, arg3, arg4);
@@ -815,6 +821,9 @@ static void create_cpu_map(void)
815821
if (max_punit_id < cpu_map[i].punit_id)
816822
max_punit_id = cpu_map[i].punit_id;
817823

824+
if (!pkg_id && max_die_id_package_0 < die_id)
825+
max_die_id_package_0 = die_id;
826+
818827
debug_printf(
819828
"map logical_cpu:%d core: %d die:%d pkg:%d punit:%d punit_cpu:%d punit_core:%d\n",
820829
i, cpu_map[i].core_id, cpu_map[i].die_id,

0 commit comments

Comments
 (0)