diff options
author | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2023-01-17 14:34:27 -0800 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2023-02-03 10:01:50 +0100 |
commit | 2612ae596129ad9792b9cd5bf5937614edca185f (patch) | |
tree | 83b1703454a6a8a235ec85d57f3390cc85a2d1a4 /tools/power | |
parent | 61f9fdcdcd01f9a996b6db4e7092fcdfe8414ad5 (diff) |
tools/power/x86/intel-speed-select: Adjust uncore max/min frequency
When perf level is changed, uncore limits can change. Set the uncore
limits via Linux uncore sysfs, when user changes perf level with
-o option.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'tools/power')
-rw-r--r-- | tools/power/x86/intel-speed-select/isst-config.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 9f201189a06d..15bee7f52044 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -1319,6 +1319,34 @@ static void dump_isst_config(int arg) isst_ctdp_display_information_end(outf); } +static int set_uncore_min_max(struct isst_id *id, int max, int freq) +{ + char buffer[128], freq_str[16]; + int fd, ret, len; + + if (max) + snprintf(buffer, sizeof(buffer), + "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d/max_freq_khz", id->pkg, id->die); + else + snprintf(buffer, sizeof(buffer), + "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d/min_freq_khz", id->pkg, id->die); + + fd = open(buffer, O_WRONLY); + if (fd < 0) + return fd; + + snprintf(freq_str, sizeof(freq_str), "%d", freq); + len = strlen(freq_str); + ret = write(fd, freq_str, len); + if (ret == -1) { + close(fd); + return ret; + } + close(fd); + + return 0; +} + static void adjust_scaling_max_from_base_freq(int cpu); static void set_tdp_level_for_cpu(struct isst_id *id, void *arg1, void *arg2, void *arg3, @@ -1340,6 +1368,14 @@ static void set_tdp_level_for_cpu(struct isst_id *id, void *arg1, void *arg2, vo /* Wait for updated base frequencies */ usleep(2000); + /* Adjusting uncore freq */ + isst_get_uncore_p0_p1_info(id, tdp_level, &ctdp_level); + if (ctdp_level.uncore_pm) + set_uncore_min_max(id, 0, ctdp_level.uncore_pm * 100000); + + if (ctdp_level.uncore_p0) + set_uncore_min_max(id, 1, ctdp_level.uncore_p0 * 100000); + fprintf(stderr, "Option is set to online/offline\n"); ctdp_level.core_cpumask_size = alloc_cpu_set(&ctdp_level.core_cpumask); |