Skip to content

Commit a084c3c

Browse files
Yicong Yangwilldeacon
authored andcommitted
drivers/perf: hisi: Add tt_core_deprecated for compatibility
Previously tt_core is defined as config1:0-7 which may not cover all the CPUs sharing L3C on platforms with more than 8 CPUs in a L3C. In order to support such platforms extend tt_core to 16 bits, since no spare space in config1, tt_core was moved to config2:0-15. Though linux expects the users to retrieve the control encoding from sysfs first for each option, it's possible if user doesn't follow this and hardcoded tt_core in config1. So add an option tt_core_deprecated for config1:0-7 for backward compatibility. Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Signed-off-by: Will Deacon <will@kernel.org>
1 parent ea0b391 commit a084c3c

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

Documentation/admin-guide/perf/hisi-pmu.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ specified as a bitmap::
6666

6767
This will only count the operations from core/thread 0 and 1 in this cluster.
6868

69+
User should not use tt_core_deprecated to specify the core/thread filtering.
70+
This option is provided for backward compatiblility and only support 8bit
71+
which may not cover all the core/thread sharing L3C.
72+
6973
2. Tracetag allow the user to chose to count only read, write or atomic
7074
operations via the tt_req parameeter in perf. The default value counts all
7175
operations. tt_req is 3bits, 3'b100 represents read operations, 3'b101

drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
#define L3C_V2_NR_EVENTS 0xFF
5858

5959
HISI_PMU_EVENT_ATTR_EXTRACTOR(ext, config, 17, 16);
60+
/*
61+
* Remain the config1:0-7 for backward compatibility if some existing users
62+
* hardcode the config1:0-7 directly without parsing the sysfs attribute.
63+
*/
64+
HISI_PMU_EVENT_ATTR_EXTRACTOR(tt_core_deprecated, config1, 7, 0);
6065
HISI_PMU_EVENT_ATTR_EXTRACTOR(tt_req, config1, 10, 8);
6166
HISI_PMU_EVENT_ATTR_EXTRACTOR(datasrc_cfg, config1, 15, 11);
6267
HISI_PMU_EVENT_ATTR_EXTRACTOR(datasrc_skt, config1, 16, 16);
@@ -95,6 +100,21 @@ static bool support_ext(struct hisi_l3c_pmu *pmu)
95100
return l3c_pmu_ext->support_ext;
96101
}
97102

103+
/*
104+
* tt_core was extended to cover all the CPUs sharing the L3 and was moved from
105+
* config1:0-7 to config2:0-*. Try it first and fallback to tt_core_deprecated
106+
* if user's still using the deprecated one.
107+
*/
108+
static u32 hisi_l3c_pmu_get_tt_core(struct perf_event *event)
109+
{
110+
u32 core = hisi_get_tt_core(event);
111+
112+
if (core)
113+
return core;
114+
115+
return hisi_get_tt_core_deprecated(event);
116+
}
117+
98118
static int hisi_l3c_pmu_get_event_idx(struct perf_event *event)
99119
{
100120
struct hisi_pmu *l3c_pmu = to_hisi_pmu(event->pmu);
@@ -259,7 +279,7 @@ static void hisi_l3c_pmu_clear_ds(struct perf_event *event)
259279
static void hisi_l3c_pmu_config_core_tracetag(struct perf_event *event)
260280
{
261281
struct hw_perf_event *hwc = &event->hw;
262-
u32 core = hisi_get_tt_core(event);
282+
u32 core = hisi_l3c_pmu_get_tt_core(event);
263283

264284
if (core) {
265285
u32 val;
@@ -280,7 +300,7 @@ static void hisi_l3c_pmu_config_core_tracetag(struct perf_event *event)
280300
static void hisi_l3c_pmu_clear_core_tracetag(struct perf_event *event)
281301
{
282302
struct hw_perf_event *hwc = &event->hw;
283-
u32 core = hisi_get_tt_core(event);
303+
u32 core = hisi_l3c_pmu_get_tt_core(event);
284304

285305
if (core) {
286306
u32 val;
@@ -300,7 +320,7 @@ static void hisi_l3c_pmu_clear_core_tracetag(struct perf_event *event)
300320

301321
static bool hisi_l3c_pmu_have_filter(struct perf_event *event)
302322
{
303-
return hisi_get_tt_req(event) || hisi_get_tt_core(event) ||
323+
return hisi_get_tt_req(event) || hisi_l3c_pmu_get_tt_core(event) ||
304324
hisi_get_datasrc_cfg(event) || hisi_get_datasrc_skt(event);
305325
}
306326

@@ -331,6 +351,9 @@ static int hisi_l3c_pmu_check_filter(struct perf_event *event)
331351
if (ext < 0 || ext > hisi_l3c_pmu->ext_num)
332352
return -EINVAL;
333353

354+
if (hisi_get_tt_core(event) && hisi_get_tt_core_deprecated(event))
355+
return -EINVAL;
356+
334357
return 0;
335358
}
336359

@@ -602,10 +625,11 @@ static const struct attribute_group hisi_l3c_pmu_v1_format_group = {
602625

603626
static struct attribute *hisi_l3c_pmu_v2_format_attr[] = {
604627
HISI_PMU_FORMAT_ATTR(event, "config:0-7"),
605-
HISI_PMU_FORMAT_ATTR(tt_core, "config2:0-15"),
628+
HISI_PMU_FORMAT_ATTR(tt_core_deprecated, "config1:0-7"),
606629
HISI_PMU_FORMAT_ATTR(tt_req, "config1:8-10"),
607630
HISI_PMU_FORMAT_ATTR(datasrc_cfg, "config1:11-15"),
608631
HISI_PMU_FORMAT_ATTR(datasrc_skt, "config1:16"),
632+
HISI_PMU_FORMAT_ATTR(tt_core, "config2:0-15"),
609633
NULL
610634
};
611635

@@ -617,6 +641,7 @@ static const struct attribute_group hisi_l3c_pmu_v2_format_group = {
617641
static struct attribute *hisi_l3c_pmu_v3_format_attr[] = {
618642
HISI_PMU_FORMAT_ATTR(event, "config:0-7"),
619643
HISI_PMU_FORMAT_ATTR(ext, "config:16-17"),
644+
HISI_PMU_FORMAT_ATTR(tt_core_deprecated, "config1:0-7"),
620645
HISI_PMU_FORMAT_ATTR(tt_req, "config1:8-10"),
621646
HISI_PMU_FORMAT_ATTR(tt_core, "config2:0-15"),
622647
NULL

0 commit comments

Comments
 (0)