提交 ae06ef75 编写于 作者: J John Garry 提交者: Zhong Jinghua

perf pmu: Add pmu_id()

mainline inclusion
from mainline-v5.11-rc1
commit 51d54847
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I63VF5
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=51d548471510843e56d9f427aa6473ca0981c4a4

--------------------------------------------------------------------------

Add a function to read the PMU id sysfs entry. This is only done for uncore
PMUs where this would possibly be relevant.
Signed-off-by: NJohn Garry <john.garry@huawei.com>
Acked-by: NKajol Jain <kjain@linux.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linuxarm@huawei.com
Link: http://lore.kernel.org/lkml/1607080216-36968-4-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NJunhao He <hejunhao3@huawei.com>
上级 3b893351
......@@ -597,6 +597,7 @@ static struct perf_cpu_map *__pmu_cpumask(const char *path)
* Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64)
* may have a "cpus" file.
*/
#define SYS_TEMPLATE_ID "./bus/event_source/devices/%s/identifier"
#define CPUS_TEMPLATE_UNCORE "%s/bus/event_source/devices/%s/cpumask"
#define CPUS_TEMPLATE_CPU "%s/bus/event_source/devices/%s/cpus"
......@@ -635,6 +636,21 @@ static bool pmu_is_uncore(const char *name)
return file_available(path);
}
static char *pmu_id(const char *name)
{
char path[PATH_MAX], *str;
size_t len;
snprintf(path, PATH_MAX, SYS_TEMPLATE_ID, name);
if (sysfs__read_str(path, &str, &len) < 0)
return NULL;
str[len - 1] = 0; /* remove line feed */
return str;
}
/*
* PMU CORE devices have different name other than cpu in sysfs on some
* platforms.
......@@ -852,6 +868,8 @@ static struct perf_pmu *pmu_lookup(const char *name)
pmu->name = strdup(name);
pmu->type = type;
pmu->is_uncore = pmu_is_uncore(name);
if (pmu->is_uncore)
pmu->id = pmu_id(name);
pmu->max_precise = pmu_max_precise(name);
pmu_add_cpu_aliases(&aliases, pmu);
......
......@@ -30,6 +30,7 @@ struct perf_pmu_caps {
struct perf_pmu {
char *name;
char *id;
__u32 type;
bool selectable;
bool is_uncore;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册