diff options
author | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2024-07-07 19:44:46 -0700 |
---|---|---|
committer | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2024-07-09 10:50:05 -0700 |
commit | 971ae1844e7c105cff3699ad69dfed31810ef8e4 (patch) | |
tree | a6c2e77232876ba0d7dc1f5b5b5bafadbc1eb87c /gprofng/common/hwcdrv.c | |
parent | 604b972e61452801757f5c824e58a6c6c3a537d1 (diff) | |
download | gdb-971ae1844e7c105cff3699ad69dfed31810ef8e4.zip gdb-971ae1844e7c105cff3699ad69dfed31810ef8e4.tar.gz gdb-971ae1844e7c105cff3699ad69dfed31810ef8e4.tar.bz2 |
gprofng: add hardware counters for Intel Ice Lake processor
gprofng/ChangeLog
2024-07-07 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>.
* common/hwc_cpus.h: New constant for Intel Ice Lake processor.
* common/hwcdrv.c: Add a new argument to hwcfuncs_get_x86_eventsel.
Set config1 in perf_event_attr. Remove the use of memset.
* common/core_pcbe.c (core_pcbe_get_eventnum): Return 0.
* common/hwcentry.h: Add config1.
* src/collctrl.cc (Coll_Ctrl::build_data_desc):Set config1.
* common/hwcfuncs.c (process_data_descriptor): Set config1.
* common/hwctable.c: Add the hwc table for Intel Ice Lake processor.
* src/hwc_intel_icelake.h: New file.
Diffstat (limited to 'gprofng/common/hwcdrv.c')
-rw-r--r-- | gprofng/common/hwcdrv.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/gprofng/common/hwcdrv.c b/gprofng/common/hwcdrv.c index 0b4cfc3..aaf3acd 100644 --- a/gprofng/common/hwcdrv.c +++ b/gprofng/common/hwcdrv.c @@ -215,29 +215,29 @@ set_x86_attr_bits (eventsel_t *result_mask, eventsel_t evnt_valid_umask, } static int -hwcfuncs_get_x86_eventsel (unsigned int regno, const char *int_name, +hwcfuncs_get_x86_eventsel (Hwcentry *h, eventsel_t *return_event, uint_t *return_pmc_sel) { hwcfuncs_attr_t attrs[HWCFUNCS_MAX_ATTRS + 1]; unsigned nattrs = 0; char *nameOnly = NULL; - eventsel_t evntsel = 0; // event number + eventsel_t evntsel = h->config; eventsel_t evnt_valid_umask = 0; uint_t pmc_sel = 0; int rc = -1; *return_event = 0; *return_pmc_sel = 0; - void *attr_mem = hwcfuncs_parse_attrs (int_name, attrs, HWCFUNCS_MAX_ATTRS, + void *attr_mem = hwcfuncs_parse_attrs (h->int_name, attrs, HWCFUNCS_MAX_ATTRS, &nattrs, NULL); if (!attr_mem) { logerr (GTXT ("out of memory, could not parse attributes\n")); return -1; } - hwcfuncs_parse_ctr (int_name, NULL, &nameOnly, NULL, NULL, NULL); + hwcfuncs_parse_ctr (h->int_name, NULL, &nameOnly, NULL, NULL, NULL); /* look up evntsel */ - if (myperfctr_get_x86_eventnum (nameOnly, regno, + if (myperfctr_get_x86_eventnum (nameOnly, h->reg_num, &evntsel, &evnt_valid_umask, &pmc_sel)) { logerr (GTXT ("counter `%s' is not valid\n"), nameOnly); @@ -335,6 +335,7 @@ typedef struct hrtime_t min_time; // minimum time we're targeting between events char *name; } perf_event_def_t; +static perf_event_def_t event_def_0; typedef struct { // runtime state of perf_event buffer @@ -601,11 +602,17 @@ static void init_perf_event (struct perf_event_attr *hw, uint64_t event, uint64_t period, Hwcentry *hwce) { - memset (hw, 0, sizeof (struct perf_event_attr)); - hw->size = sizeof (struct perf_event_attr); + static struct perf_event_attr perf_event_attr_0 = { + .size = sizeof (struct perf_event_attr), + .disabled = 1, /* off by default */ + .exclude_hv = 1, + .wakeup_events = 1 /* wakeup every n events */ + }; + *hw = perf_event_attr_0; if (hwce && hwce->use_perf_event_type) { hw->config = hwce->config; + hw->config1 = hwce->config1; hw->type = hwce->type; } else @@ -632,13 +639,10 @@ init_perf_event (struct perf_event_attr *hw, uint64_t event, uint64_t period, // PERF_FORMAT_ID | // PERF_FORMAT_GROUP | 0; - hw->disabled = 1; /* off by default */ // Note: the following override config.priv bits! hw->exclude_user = (event & (1 << 16)) == 0; /* don't count user */ hw->exclude_kernel = (event & (1 << 17)) == 0; /* ditto kernel */ - hw->exclude_hv = 1; /* ditto hypervisor */ - hw->wakeup_events = 1; /* wakeup every n events */ dump_perf_event_attr (hw); } @@ -773,8 +777,7 @@ hdrv_pcl_internal_open () } // determine if PCL is available - perf_event_def_t tmp_event_def; - memset (&tmp_event_def, 0, sizeof (tmp_event_def)); + perf_event_def_t tmp_event_def = event_def_0; struct perf_event_attr *pe_attr = &tmp_event_def.hw; init_perf_event (pe_attr, 0, 0, NULL); pe_attr->type = PERF_TYPE_HARDWARE; // specify abstracted HW event @@ -1186,11 +1189,10 @@ hwcdrv_create_counters (unsigned hwcdef_cnt, Hwcentry *hwcdef) for (unsigned idx = 0; idx < hwcdef_cnt; idx++) { perf_event_def_t *glb_event_def = &global_perf_event_def[idx]; - memset (glb_event_def, 0, sizeof (perf_event_def_t)); + *glb_event_def = event_def_0; unsigned int pmc_sel; eventsel_t evntsel; - if (hwcfuncs_get_x86_eventsel (hwcdef[idx].reg_num, - hwcdef[idx].int_name, &evntsel, &pmc_sel)) + if (hwcfuncs_get_x86_eventsel (hwcdef + idx, &evntsel, &pmc_sel)) { TprintfT (0, "hwcdrv: ERROR: hwcfuncs_get_x86_eventsel() failed\n"); return HWCFUNCS_ERROR_HWCARGS; |