提交 807fe9bb 编写于 作者: K Kan Liang 提交者: Caspar Zhang

ICX: perf parse-regs: Add generic support for arch__intr/user_reg_mask()

commit af785e75bf616704cab031e66403b6adcf5b700a upstream.

There may be different register mask for use with intr or user on some
platforms, e.g. Icelake.

Add weak functions arch__intr_reg_mask() and arch__user_reg_mask() to
return intr and user register mask respectively.

Check mask before printing or comparing the register name.

Generic code always return PERF_REGS_MASK. No functional change.
Suggested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
Tested-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1557865174-56264-2-git-send-email-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NShen, Xiaochen <xiaochen.shen@intel.com>
Signed-off-by: NJeffle Xu <jefflexu@linux.alibaba.com>
Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
上级 cb53f5f2
...@@ -12,6 +12,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) ...@@ -12,6 +12,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
const struct sample_reg *r; const struct sample_reg *r;
char *s, *os = NULL, *p; char *s, *os = NULL, *p;
int ret = -1; int ret = -1;
uint64_t mask;
if (unset) if (unset)
return 0; return 0;
...@@ -22,6 +23,11 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) ...@@ -22,6 +23,11 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
if (*mode) if (*mode)
return -1; return -1;
if (intr)
mask = arch__intr_reg_mask();
else
mask = arch__user_reg_mask();
/* str may be NULL in case no arg is passed to -I */ /* str may be NULL in case no arg is passed to -I */
if (str) { if (str) {
/* because str is read-only */ /* because str is read-only */
...@@ -37,14 +43,15 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) ...@@ -37,14 +43,15 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
if (!strcmp(s, "?")) { if (!strcmp(s, "?")) {
fprintf(stderr, "available registers: "); fprintf(stderr, "available registers: ");
for (r = sample_reg_masks; r->name; r++) { for (r = sample_reg_masks; r->name; r++) {
fprintf(stderr, "%s ", r->name); if (r->mask & mask)
fprintf(stderr, "%s ", r->name);
} }
fputc('\n', stderr); fputc('\n', stderr);
/* just printing available regs */ /* just printing available regs */
return -1; return -1;
} }
for (r = sample_reg_masks; r->name; r++) { for (r = sample_reg_masks; r->name; r++) {
if (!strcasecmp(s, r->name)) if ((r->mask & mask) && !strcasecmp(s, r->name))
break; break;
} }
if (!r->name) { if (!r->name) {
...@@ -65,7 +72,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) ...@@ -65,7 +72,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
/* default to all possible regs */ /* default to all possible regs */
if (*mode == 0) if (*mode == 0)
*mode = PERF_REGS_MASK; *mode = mask;
error: error:
free(os); free(os);
return ret; return ret;
......
...@@ -13,6 +13,16 @@ int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused, ...@@ -13,6 +13,16 @@ int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused,
return SDT_ARG_SKIP; return SDT_ARG_SKIP;
} }
uint64_t __weak arch__intr_reg_mask(void)
{
return PERF_REGS_MASK;
}
uint64_t __weak arch__user_reg_mask(void)
{
return PERF_REGS_MASK;
}
#ifdef HAVE_PERF_REGS_SUPPORT #ifdef HAVE_PERF_REGS_SUPPORT
int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
{ {
......
...@@ -23,6 +23,8 @@ enum { ...@@ -23,6 +23,8 @@ enum {
}; };
int arch_sdt_arg_parse_op(char *old_op, char **new_op); int arch_sdt_arg_parse_op(char *old_op, char **new_op);
uint64_t arch__intr_reg_mask(void);
uint64_t arch__user_reg_mask(void);
#ifdef HAVE_PERF_REGS_SUPPORT #ifdef HAVE_PERF_REGS_SUPPORT
#include <perf_regs.h> #include <perf_regs.h>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册