Commit fd5aadaa authored by Hans de Goede's avatar Hans de Goede

Merge remote-tracking branch 'intel-speed-select/intel-sst' into review-hans

Summary of changes:

Till the commit:
"tools/power/x86/intel-speed-select: Get punit core mapping
information"

All patches just lays foundation for adding new hardware interface
in addition to existing MSR/MMIO interface.

All patches prefixed with "Abstract" just adds individual hardware
callback for functions called from the core processing.

The mailbox processing is abstracted to a new file with callbacks.

In addition some changes to reduce duplicated code for display
of TRL level.

Patch "Introduce Punit ID concept and add related API" add further
abstraction in addition to existing package and die scope.

-----------
tools/power/x86/intel-speed-select: Get punit core mapping information
-Adds a new way to get package/die/punit information for each CPU.
-----------

Introduce TPMI interface support
- Implement all abstracted callbacks above to use TPMI IOCTL interface.
-----------

tools/power/x86/intel-speed-select: Display punit info
- With TPMI the granularity is per punit, which can be multiple in a
package/die.
----------

tools/power/x86/intel-speed-select: Remove cpu mask display for non-cpu
power domain
tools/power/x86/intel-speed-select: Display fact info for non-cpu power
domain
-There are some power domains with no CPUs, the above patches adds CPU
as invalid for these domains
----------

tools/power/x86/intel-speed-select: Use cgroup v2 isolation
- Adds new option to use Cgroup CPU isolation instead of offline of CPUs
----------

tools/power/x86/intel-speed-select: Change TRL display for Emerald Rapids
- Emerald Rapid has multiple TRL levels and moves away from TRL level
based on instruction type
parents 6f561677 19799d3a
intel-speed-select-y += isst-config.o isst-core.o isst-display.o isst-daemon.o hfi-events.o
intel-speed-select-y += isst-config.o isst-core.o isst-display.o isst-daemon.o hfi-events.o isst-core-mbox.o isst-core-tpmi.o
This diff is collapsed.
This diff is collapsed.
......@@ -20,16 +20,17 @@
#include "isst.h"
static int per_package_levels_info[MAX_PACKAGE_COUNT][MAX_DIE_PER_PACKAGE];
static time_t per_package_levels_tm[MAX_PACKAGE_COUNT][MAX_DIE_PER_PACKAGE];
static int per_package_levels_info[MAX_PACKAGE_COUNT][MAX_DIE_PER_PACKAGE][MAX_PUNIT_PER_DIE];
static time_t per_package_levels_tm[MAX_PACKAGE_COUNT][MAX_DIE_PER_PACKAGE][MAX_PUNIT_PER_DIE];
static void init_levels(void)
{
int i, j;
int i, j, k;
for (i = 0; i < MAX_PACKAGE_COUNT; ++i)
for (j = 0; j < MAX_DIE_PER_PACKAGE; ++j)
per_package_levels_info[i][j] = -1;
for (k = 0; k < MAX_PUNIT_PER_DIE; ++k)
per_package_levels_info[i][j][k] = -1;
}
void process_level_change(struct isst_id *id)
......@@ -39,16 +40,16 @@ void process_level_change(struct isst_id *id)
time_t tm;
int ret;
if (id->pkg < 0 || id->die < 0) {
if (id->pkg < 0 || id->die < 0 || id->punit < 0) {
debug_printf("Invalid package/die info for cpu:%d\n", id->cpu);
return;
}
tm = time(NULL);
if (tm - per_package_levels_tm[id->pkg][id->die] < 2)
if (tm - per_package_levels_tm[id->pkg][id->die][id->punit] < 2)
return;
per_package_levels_tm[id->pkg][id->die] = tm;
per_package_levels_tm[id->pkg][id->die][id->punit] = tm;
ret = isst_get_ctdp_levels(id, &pkg_dev);
if (ret) {
......@@ -64,14 +65,14 @@ void process_level_change(struct isst_id *id)
return;
}
if (per_package_levels_info[id->pkg][id->die] == pkg_dev.current_level)
if (per_package_levels_info[id->pkg][id->die][id->punit] == pkg_dev.current_level)
return;
debug_printf("**Config level change for cpu:%d pkg:%d die:%d from %d to %d\n",
id->cpu, id->pkg, id->die, per_package_levels_info[id->pkg][id->die],
id->cpu, id->pkg, id->die, per_package_levels_info[id->pkg][id->die][id->punit],
pkg_dev.current_level);
per_package_levels_info[id->pkg][id->die] = pkg_dev.current_level;
per_package_levels_info[id->pkg][id->die][id->punit] = pkg_dev.current_level;
ctdp_level.core_cpumask_size =
alloc_cpu_set(&ctdp_level.core_cpumask);
......@@ -82,6 +83,19 @@ void process_level_change(struct isst_id *id)
return;
}
if (use_cgroupv2()) {
int ret;
ret = enable_cpuset_controller();
if (ret)
goto use_offline;
isolate_cpus(id, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask, pkg_dev.current_level);
goto free_mask;
}
use_offline:
if (ctdp_level.cpu_count) {
int i, max_cpus = get_topo_max_cpus();
for (i = 0; i < max_cpus; ++i) {
......@@ -96,7 +110,7 @@ void process_level_change(struct isst_id *id)
}
}
}
free_mask:
free_cpu_set(ctdp_level.core_cpumask);
}
......@@ -108,7 +122,7 @@ static void _poll_for_config_change(struct isst_id *id, void *arg1, void *arg2,
static void poll_for_config_change(void)
{
for_each_online_package_in_set(_poll_for_config_change, NULL, NULL,
for_each_online_power_domain_in_set(_poll_for_config_change, NULL, NULL,
NULL, NULL);
}
......
......@@ -28,6 +28,8 @@
#include <stdarg.h>
#include <sys/ioctl.h>
#include <linux/isst_if.h>
#define BIT(x) (1 << (x))
#define BIT_ULL(nr) (1ULL << (nr))
#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8 - 1 - (h))))
......@@ -77,29 +79,29 @@
#define DISP_FREQ_MULTIPLIER 100
#define MAX_PACKAGE_COUNT 8
#define MAX_DIE_PER_PACKAGE 2
#define MAX_PACKAGE_COUNT 8
#define MAX_DIE_PER_PACKAGE 2
#define MAX_PUNIT_PER_DIE 8
/* Unified structure to specific a CPU or a Power Domain */
struct isst_id {
int cpu;
int pkg;
int die;
int punit;
};
struct isst_clos_config {
unsigned int clos_min;
unsigned int clos_max;
unsigned char epp;
unsigned char clos_prop_prio;
unsigned char clos_min;
unsigned char clos_max;
unsigned char clos_desired;
};
struct isst_fact_bucket_info {
int high_priority_cores_count;
int sse_trl;
int avx_trl;
int avx512_trl;
int hp_cores;
int hp_ratios[TRL_MAX_LEVELS];
};
struct isst_pbf_info {
......@@ -117,9 +119,7 @@ struct isst_pbf_info {
#define ISST_TRL_MAX_ACTIVE_CORES 8
#define ISST_FACT_MAX_BUCKETS 8
struct isst_fact_info {
int lp_clipping_ratio_license_sse;
int lp_clipping_ratio_license_avx2;
int lp_clipping_ratio_license_avx512;
int lp_ratios[TRL_MAX_LEVELS];
struct isst_fact_bucket_info bucket_info[ISST_FACT_MAX_BUCKETS];
};
......@@ -143,20 +143,20 @@ struct isst_pkg_ctdp_level_info {
int pkg_max_power;
int fact;
int t_proc_hot;
int cooling_type;
int uncore_p0;
int uncore_p1;
int uncore_pm;
int sse_p1;
int avx2_p1;
int avx512_p1;
int amx_p1;
int mem_freq;
size_t core_cpumask_size;
cpu_set_t *core_cpumask;
int cpu_count;
unsigned long long buckets_info;
int trl_sse_active_cores[ISST_TRL_MAX_ACTIVE_CORES];
int trl_avx_active_cores[ISST_TRL_MAX_ACTIVE_CORES];
int trl_avx_512_active_cores[ISST_TRL_MAX_ACTIVE_CORES];
unsigned long long trl_cores; /* Buckets info */
int trl_ratios[TRL_MAX_LEVELS][ISST_TRL_MAX_ACTIVE_CORES];
int kobj_bucket_index;
int active_bucket;
int fact_max_index;
......@@ -178,13 +178,48 @@ struct isst_pkg_ctdp {
struct isst_pkg_ctdp_level_info ctdp_level[ISST_MAX_TDP_LEVELS];
};
enum isst_platform_param {
ISST_PARAM_MBOX_DELAY,
ISST_PARAM_MBOX_RETRIES,
};
struct isst_platform_ops {
int (*get_disp_freq_multiplier)(void);
int (*get_trl_max_levels)(void);
char *(*get_trl_level_name)(int level);
void (*update_platform_param)(enum isst_platform_param param, int value);
int (*is_punit_valid)(struct isst_id *id);
int (*read_pm_config)(struct isst_id *id, int *cp_state, int *cp_cap);
int (*get_config_levels)(struct isst_id *id, struct isst_pkg_ctdp *pkg_ctdp);
int (*get_ctdp_control)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_tdp_info)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_pwr_info)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_coremask_info)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_get_trl)(struct isst_id *id, int level, int avx_level, int *trl);
int (*get_get_trls)(struct isst_id *id, int level, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_trl_bucket_info)(struct isst_id *id, int level, unsigned long long *buckets_info);
int (*set_tdp_level)(struct isst_id *id, int tdp_level);
int (*get_pbf_info)(struct isst_id *id, int level, struct isst_pbf_info *pbf_info);
int (*set_pbf_fact_status)(struct isst_id *id, int pbf, int enable);
int (*get_fact_info)(struct isst_id *id, int level, int fact_bucket, struct isst_fact_info *fact_info);
void (*adjust_uncore_freq)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_clos_information)(struct isst_id *id, int *enable, int *type);
int (*pm_qos_config)(struct isst_id *id, int enable_clos, int priority_type);
int (*pm_get_clos)(struct isst_id *id, int clos, struct isst_clos_config *clos_config);
int (*set_clos)(struct isst_id *id, int clos, struct isst_clos_config *clos_config);
int (*clos_get_assoc_status)(struct isst_id *id, int *clos_id);
int (*clos_associate)(struct isst_id *id, int clos_id);
};
extern int is_cpu_in_power_domain(int cpu, struct isst_id *id);
extern int get_topo_max_cpus(void);
extern int get_cpu_count(struct isst_id *id);
extern int get_max_punit_core_id(struct isst_id *id);
extern int api_version(void);
/* Common interfaces */
FILE *get_output_file(void);
extern int is_debug_enabled(void);
extern void debug_printf(const char *format, ...);
extern int out_format_is_json(void);
extern void set_isst_id(struct isst_id *id, int cpu);
......@@ -196,21 +231,22 @@ extern void set_cpu_mask_from_punit_coremask(struct isst_id *id,
size_t core_cpumask_size,
cpu_set_t *core_cpumask,
int *cpu_cnt);
extern int isst_send_mbox_command(unsigned int cpu, unsigned char command,
unsigned char sub_command,
unsigned int write,
unsigned int req_data, unsigned int *resp);
extern int isst_send_msr_command(unsigned int cpu, unsigned int command,
int write, unsigned long long *req_resp);
extern int isst_set_platform_ops(int api_version);
extern void isst_update_platform_param(enum isst_platform_param, int vale);
extern int isst_get_disp_freq_multiplier(void);
extern int isst_get_trl_max_levels(void);
extern char *isst_get_trl_level_name(int level);
extern int isst_is_punit_valid(struct isst_id *id);
extern int isst_get_ctdp_levels(struct isst_id *id, struct isst_pkg_ctdp *pkg_dev);
extern int isst_get_ctdp_control(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level);
extern int isst_get_coremask_info(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level);
extern void isst_get_uncore_p0_p1_info(struct isst_id *id, int config_index,
extern void isst_adjust_uncore_freq(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level);
extern int isst_get_process_ctdp(struct isst_id *id, int tdp_level,
struct isst_pkg_ctdp *pkg_dev);
......@@ -228,11 +264,8 @@ extern int isst_set_tdp_level(struct isst_id *id, int tdp_level);
extern int isst_set_pbf_fact_status(struct isst_id *id, int pbf, int enable);
extern int isst_get_pbf_info(struct isst_id *id, int level,
struct isst_pbf_info *pbf_info);
extern void isst_get_pbf_info_complete(struct isst_pbf_info *pbf_info);
extern int isst_get_fact_info(struct isst_id *id, int level, int fact_bucket,
struct isst_fact_info *fact_info);
extern int isst_get_fact_bucket_info(struct isst_id *id, int level,
struct isst_fact_bucket_info *bucket_info);
extern void isst_fact_display_information(struct isst_id *id, FILE *outf, int level,
int fact_bucket, int fact_avx,
struct isst_fact_info *fact_info);
......@@ -265,11 +298,12 @@ extern int isst_read_pm_config(struct isst_id *id, int *cp_state, int *cp_cap);
extern void isst_display_error_info_message(int error, char *msg, int arg_valid, int arg);
extern int is_skx_based_platform(void);
extern int is_spr_platform(void);
extern int is_emr_platform(void);
extern int is_icx_platform(void);
extern void isst_trl_display_information(struct isst_id *id, FILE *outf, unsigned long long trl);
extern void set_cpu_online_offline(int cpu, int state);
extern void for_each_online_package_in_set(void (*callback)(struct isst_id *, void *, void *,
extern void for_each_online_power_domain_in_set(void (*callback)(struct isst_id *, void *, void *,
void *, void *),
void *arg1, void *arg2, void *arg3,
void *arg4);
......@@ -277,4 +311,14 @@ extern int isst_daemon(int debug_mode, int poll_interval, int no_daemon);
extern void process_level_change(struct isst_id *id);
extern int hfi_main(void);
extern void hfi_exit(void);
/* Interface specific callbacks */
extern struct isst_platform_ops *mbox_get_platform_ops(void);
extern struct isst_platform_ops *tpmi_get_platform_ops(void);
/* Cgroup related interface */
extern int enable_cpuset_controller(void);
extern int isolate_cpus(struct isst_id *id, int mask_size, cpu_set_t *cpu_mask, int level);
extern int use_cgroupv2(void);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment