perf parse-regs: Split parse_regs
PATCH v2 1/3 perf parse-regs: Split parse_regs
From: Kan Liang <[email protected]>
The available registers for --int-regs and --user-regs may be different, e.g. XMM registers.
Split parse_regs into two dedicated functions for --int-regs and --user-regs respectively.
Modify the warning message. "--user-regs=?" should be applied to show the available registers for --user-regs.
---
No changes since V1
tools/perf/builtin-record.c | 4 ++-- tools/perf/util/parse-regs-options.c | 19 ++++++++++++++++--- tools/perf/util/parse-regs-options.h | 3 ++- 3 files changed, 20 insertions(+), 6 deletions(-)
tools/perf/builtin-record.c +2 -2
@@ -2029,10 +2029,10 @@ static struct option __record_options[] = { "use per-thread mmaps"),OPT_CALLBACK_OPTARG ('I' ,"intr-regs" , &record.opts.sample_intr_regs,NULL ,"any register" ,"sample selected machine registers on interrupt," -" use '-I?' to list register names" , parse_regs), +" use '-I?' to list register names" , parse_intr_regs),OPT_CALLBACK_OPTARG (0 ,"user-regs" , &record.opts.sample_user_regs,NULL ,"any register" ,"sample selected machine registers on interrupt," -" use '-I?' to list register names" , parse_regs), +" use '--user-regs=?' to list register names" , parse_user_regs),OPT_BOOLEAN (0 ,"running-time" , &record.opts.running_time,"Record running/enabled time of read (:S) events" ), OPT_CALLBACK('k', "clockid", &record.opts,
tools/perf/util/parse-regs-options.c +16 -3
@@ -5,8 +5,8 @@#include <subcmd/parse-options.h> #include "util/parse-regs-options.h" -int -parse_regs (const struct option *opt,const char *str,int unset) +static int +__parse_regs (const struct option *opt,const char *str,int unset,bool intr) {uint64_t *mode = (uint64_t *)opt->value;const struct sample_reg *r;
@@ -48,7 +48,8 @@ parse_regs(const struct option *opt, const char *str, int unset)break ; }if (!r->name) { -ui__warning ("Unknown register \"%s\", check man page or run \"perf record -I?\"\n" , s); +ui__warning ("Unknown register \"%s\", check man page or run \"perf record %s?\"\n" , + s, intr ?"-I" :"--user-regs=" ); goto error; }
@@ -69,3 +70,15 @@ parse_regs(const struct option *opt, const char *str, int unset)free (os);return ret; } + +int +parse_user_regs (const struct option *opt,const char *str,int unset) +{ +return __parse_regs (opt, str, unset, false); +} + +int +parse_intr_regs (const struct option *opt,const char *str,int unset) +{ +return __parse_regs (opt, str, unset, true); +}
tools/perf/util/parse-regs-options.h +2 -1
@@ -2,5 +2,6 @@#ifndef _PERF_PARSE_REGS_OPTIONS_H#define _PERF_PARSE_REGS_OPTIONS_H 1struct option ; -int parse_regs (const struct option *opt,const char *str,int unset); +int parse_user_regs (const struct option *opt,const char *str,int unset); +int parse_intr_regs (const struct option *opt,const char *str,int unset);#endif /* _PERF_PARSE_REGS_OPTIONS_H */
Signature · 1 line
2.7.4
PATCH v2 2/3 perf parse-regs: Add generic support for arch__intr/user_reg_mask()
From: Kan Liang <[email protected]>
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.
---
Changes since V1:
- Drop has_non_gprs_support() and non_gprs_mask()
Use arch__intr/user_reg_mask()
tools/perf/util/parse-regs-options.c | 13 ++++++++++--- tools/perf/util/perf_regs.c | 10 ++++++++++ tools/perf/util/perf_regs.h | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-)
tools/perf/util/parse-regs-options.c +10 -3
@@ -12,6 +12,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)const struct sample_reg *r;char *s, *os =NULL , *p;int ret =-1 ; +uint64_t mask;if (unset)return 0 ;
@@ -22,6 +23,11 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)if (*mode)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 */ if (str) {/* because str is read-only */
@@ -37,14 +43,15 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)if (!strcmp (s,"?" )) {fprintf (stderr,"available registers: " );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);/* just printing available regs */ return -1 ; }for (r = sample_reg_masks; r->name; r++) { -if (!strcasecmp (s, r->name)) +if ((r->mask & mask) && !strcasecmp (s, r->name))break ; }if (!r->name) {
@@ -65,7 +72,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)/* default to all possible regs */ if (*mode ==0 ) - *mode =PERF_REGS_MASK ; + *mode = mask; error:free (os);return ret;
tools/perf/util/perf_regs.c +10 -0
@@ -13,6 +13,16 @@ int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused,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 int perf_reg_value (u64 *valp,struct regs_dump *regs,int id) {
tools/perf/util/perf_regs.h +2 -0
@@ -23,6 +23,8 @@ enum { };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 #include <perf_regs.h>
Signature · 1 line
2.7.4
tip-bot for Kan Liang
merge bot[tip:perf/core] perf parse-regs: Add generic support for arch__intr/user_reg_mask()
perf parse-regs: Add generic support for arch__intr/user_reg_mask()
Commit-ID: af785e75bf616704cab031e66403b6adcf5b700a Gitweb: https://git.kernel.org/tip/af785e75bf616704cab031e66403b6adcf5b700a Author: Kan Liang <[email protected]> AuthorDate: Tue, 14 May 2019 13:19:33 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 16 May 2019 14:17:12 -0300
perf parse-regs: Add generic support for arch__intr/user_reg_mask()
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.
--- tools/perf/util/parse-regs-options.c | 13 ++++++++++--- tools/perf/util/perf_regs.c | 10 ++++++++++ tools/perf/util/perf_regs.h | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-)
tools/perf/util/parse-regs-options.c +10 -3
@@ -12,6 +12,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)const struct sample_reg *r;char *s, *os =NULL , *p;int ret =-1 ; +uint64_t mask;if (unset)return 0 ;
@@ -22,6 +23,11 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)if (*mode)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 */ if (str) {/* because str is read-only */
@@ -37,14 +43,15 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)if (!strcmp (s,"?" )) {fprintf (stderr,"available registers: " );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);/* just printing available regs */ return -1 ; }for (r = sample_reg_masks; r->name; r++) { -if (!strcasecmp (s, r->name)) +if ((r->mask & mask) && !strcasecmp (s, r->name))break ; }if (!r->name) {
@@ -65,7 +72,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)/* default to all possible regs */ if (*mode ==0 ) - *mode =PERF_REGS_MASK ; + *mode = mask; error:free (os);return ret;
tools/perf/util/perf_regs.c +10 -0
@@ -13,6 +13,16 @@ int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused,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 int perf_reg_value (u64 *valp,struct regs_dump *regs,int id) {
tools/perf/util/perf_regs.h +2 -0
@@ -23,6 +23,8 @@ enum { };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 #include <perf_regs.h>
PATCH v2 3/3 perf regs x86: Add X86 specific arch__intr_reg_mask()
In reply to [email protected]From: Kan Liang <[email protected]>
XMM registers can be collected on Icelake and later platforms.
Add specific arch__intr_reg_mask(), which creating an event to check if the kernel and hardware can collect XMM registers.
Test on Skylake which doesn't support XMM registers collection. There is nothing changed.
#perf record -I?
available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-I, --intr-regs[=<any register>]
sample selected machine registers on
interrupt, use '-I?' to list register names
#perf record -I
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.905 MB perf.data (2520 samples) ]
#perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type:
IP|TID|TIME|CPU|PERIOD|REGS_INTR, read_format: ID, disabled: 1,
inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3,
sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol:
1, bpf_event: 1, sample_regs_intr: 0xff0fff
Test on Icelake which support XMM registers collection.
#perf record -I?
available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 XMM9 XMM10 XMM11 XMM12 XMM13 XMM14 XMM15
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-I, --intr-regs[=<any register>]
sample selected machine registers on
interrupt, use '-I?' to list register names
#perf record -I
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.800 MB perf.data (318 samples) ]
#perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type:
IP|TID|TIME|CPU|PERIOD|REGS_INTR, read_format: ID, disabled: 1,
inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3,
sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol:
1, bpf_event: 1, sample_regs_intr: 0xffffffff00ff0fff
---
Changes since V1:
- Add specific arch__intr_reg_mask() support
Drop specific has_non_gprs_support() and non_gprs_mask()
tools/perf/arch/x86/include/perf_regs.h | 1 + tools/perf/arch/x86/util/perf_regs.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+)
tools/perf/arch/x86/include/perf_regs.h +1 -0
@@ -9,6 +9,7 @@void perf_regs_load (u64 *regs);#define PERF_REGS_MAX PERF_REG_X86_XMM_MAX +#define PERF_XMM_REGS_MASK (~((1ULL << PERF_REG_X86_XMM0) - 1))#ifndef HAVE_ARCH_X86_64_SUPPORT #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32
tools/perf/arch/x86/util/perf_regs.c +25 -0
@@ -270,3 +270,28 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)return SDT_ARG_VALID ; } + +uint64_t arch__intr_reg_mask (void ) +{ +struct perf_event_attr attr = { + .type =PERF_TYPE_HARDWARE , + .config =PERF_COUNT_HW_CPU_CYCLES , + .sample_period =1 , + .sample_type =PERF_SAMPLE_REGS_INTR , + .sample_regs_intr =PERF_XMM_REGS_MASK , + .precise_ip =1 , + .disabled =1 , + .exclude_kernel =1 , + }; +int fd; + +event_attr_init (&attr); + + fd =sys_perf_event_open (&attr,0 ,-1 ,-1 ,0 ); +if (fd !=-1 ) { +close (fd); +return (PERF_XMM_REGS_MASK |PERF_REGS_MASK ); + } + +return PERF_REGS_MASK ; +}
Signature · 1 line
2.7.4
Re: [PATCH V2 3/3] perf regs x86: Add X86 specific arch__intr_reg_mask()
Em Tue, May 14, 2019 at 01:19:34PM -0700, [email protected] escreveu:
Quoted 9 lines
From: Kan Liang <[email protected]>
XMM registers can be collected on Icelake and later platforms.
Add specific
arch__intr_reg_mask(), which creating an event to check if the kernel and hardware can collect XMM registers.Test on Skylake which doesn't support XMM registers collection. There is nothing changed.
Thanks a lot for doing this and tested on both a machine without these registers as well as on one with it.
Applied, together with Ravi's tested-by for the first two and the change in the --user-regs doc,
Regards,
- Arnaldo
Quoted 105 lines
#perf record -I?
available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]-I, --intr-regs[=<any register>]
sample selected machine registers on
interrupt, use '-I?' to list register names#perf record -I
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.905 MB perf.data (2520 samples) ]#perf evlist -v cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|REGS_INTR, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, sample_regs_intr: 0xff0fffTest on Icelake which support XMM registers collection.
#perf record -I?
available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 XMM9 XMM10 XMM11 XMM12 XMM13 XMM14 XMM15Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]-I, --intr-regs[=<any register>]
sample selected machine registers on
interrupt, use '-I?' to list register names#perf record -I
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.800 MB perf.data (318 samples) ]#perf evlist -v cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|REGS_INTR, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, sample_regs_intr: 0xffffffff00ff0fffSigned-off-by Kan Liang <[email protected]>---
Changes since V1:
- Add specificarch__intr_reg_mask()support
Drop specifichas_non_gprs_support()andnon_gprs_mask()tools/perf/arch/x86/include/perf_regs.h | 1 + tools/perf/arch/x86/util/perf_regs.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+)tools/perf/arch/x86/include/perf_regs.h +1
-0@@ -9,6 +9,7 @@void perf_regs_load (u64 *regs);#define PERF_REGS_MAX PERF_REG_X86_XMM_MAX +#define PERF_XMM_REGS_MASK (~((1ULL << PERF_REG_X86_XMM0) - 1))#ifndef HAVE_ARCH_X86_64_SUPPORT #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32tools/perf/arch/x86/util/perf_regs.c +25
-0@@ -270,3 +270,28 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)return SDT_ARG_VALID ; } + +uint64_t arch__intr_reg_mask (void ) +{ +struct perf_event_attr attr = { + .type =PERF_TYPE_HARDWARE , + .config =PERF_COUNT_HW_CPU_CYCLES , + .sample_period =1 , + .sample_type =PERF_SAMPLE_REGS_INTR , + .sample_regs_intr =PERF_XMM_REGS_MASK , + .precise_ip =1 , + .disabled =1 , + .exclude_kernel =1 , + }; +int fd; + +event_attr_init (&attr); + + fd =sys_perf_event_open (&attr,0 ,-1 ,-1 ,0 ); +if (fd !=-1 ) { +close (fd); +return (PERF_XMM_REGS_MASK |PERF_REGS_MASK ); + } + +return PERF_REGS_MASK ; +}Signature · 1 line
2.7.4
Signature · 1 line
- Arnaldo
tip-bot for Kan Liang
merge bot[tip:perf/core] perf regs x86: Add X86 specific arch__intr_reg_mask()
In reply to [email protected]perf regs x86: Add X86 specific arch__intr_reg_mask()
Commit-ID: 6466ec14aaf44ff14a05369dcf0929d0f01171c6 Gitweb: https://git.kernel.org/tip/6466ec14aaf44ff14a05369dcf0929d0f01171c6 Author: Kan Liang <[email protected]> AuthorDate: Tue, 14 May 2019 13:19:34 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 16 May 2019 14:17:23 -0300
perf regs x86: Add X86 specific arch__intr_reg_mask()
XMM registers can be collected on Icelake and later platforms.
Add specific arch__intr_reg_mask(), which creating an event to check if the kernel and hardware can collect XMM registers.
Test on Skylake which doesn't support XMM registers collection. There is nothing changed.
#perf record -I?
available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-I, --intr-regs[=<any register>]
sample selected machine registers on
interrupt, use '-I?' to list register names
#perf record -I
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.905 MB perf.data (2520 samples) ]
#perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type:
IP|TID|TIME|CPU|PERIOD|REGS_INTR, read_format: ID, disabled: 1,
inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3,
sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol:
1, bpf_event: 1, sample_regs_intr: 0xff0fff
Test on Icelake which support XMM registers collection.
#perf record -I?
available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 XMM9 XMM10 XMM11 XMM12 XMM13 XMM14 XMM15
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-I, --intr-regs[=<any register>]
sample selected machine registers on
interrupt, use '-I?' to list register names
#perf record -I
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.800 MB perf.data (318 samples) ]
#perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type:
IP|TID|TIME|CPU|PERIOD|REGS_INTR, read_format: ID, disabled: 1,
inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3,
sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol:
1, bpf_event: 1, sample_regs_intr: 0xffffffff00ff0fff
Committer notes:
Don't set attr.sample_period as a named struct init, as it is part of an unnamed union in 'struct perf_event_attr', and doing so breaks the build on older gcc versions, such as:
gcc version 4.1.2 20080704 (Red Hat 4.1.2-55) gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
arch/x86/util/perf_regs.c: In function 'arch__intr_reg_mask':
arch/x86/util/perf_regs.c:279: error: unknown field 'sample_period' specified in initializer
cc1: warnings being treated as errors
arch/x86/util/perf_regs.c:279: warning: missing braces around initializer arch/x86/util/perf_regs.c:279: warning: (near initialization for 'attr.<anonymous>')
--- tools/perf/arch/x86/include/perf_regs.h | 1 + tools/perf/arch/x86/util/perf_regs.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
tools/perf/arch/x86/include/perf_regs.h +1 -0
@@ -9,6 +9,7 @@void perf_regs_load (u64 *regs);#define PERF_REGS_MAX PERF_REG_X86_XMM_MAX +#define PERF_XMM_REGS_MASK (~((1ULL << PERF_REG_X86_XMM0) - 1))#ifndef HAVE_ARCH_X86_64_SUPPORT #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32
tools/perf/arch/x86/util/perf_regs.c +28 -0
@@ -270,3 +270,31 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)return SDT_ARG_VALID ; } + +uint64_t arch__intr_reg_mask (void ) +{ +struct perf_event_attr attr = { + .type =PERF_TYPE_HARDWARE , + .config =PERF_COUNT_HW_CPU_CYCLES , + .sample_type =PERF_SAMPLE_REGS_INTR , + .sample_regs_intr =PERF_XMM_REGS_MASK , + .precise_ip =1 , + .disabled =1 , + .exclude_kernel =1 , + }; +int fd; +/* +* In an unnamed union, init it here to build on older gcc versions +*/ + attr.sample_period =1 ; + +event_attr_init (&attr); + + fd =sys_perf_event_open (&attr,0 ,-1 ,-1 ,0 ); +if (fd !=-1 ) { +close (fd); +return (PERF_XMM_REGS_MASK |PERF_REGS_MASK ); + } + +return PERF_REGS_MASK ; +}
Quoted 5 lines · On 5/15/19 1:49 AM, [email protected] wrote:
From: Kan Liang <[email protected]>
The available registers for --int-regs and --user-regs may be different, e.g. XMM registers.
Quoted 8 lines
Split
parse_regsinto two dedicated functions for --int-regs and --user-regs respectively.Modify the warning message. "--user-regs=?" should be applied to show the available registers for --user-regs.
Signed-off-by Kan Liang <[email protected]>---
For patch 1 and 2,
Minor neat. Should we update document as well? May be something like:
tools/perf/Documentation/perf-record.txt
--user-regs::
Similar to -I, but capture user registers at sample time. To list the available user registers use --user-regs=\?.
Ravi
Quoted 19 lines · Ravi Bangoria
Quoted 5 lines · On 5/15/19 1:49 AM, [email protected] wrote:
From: Kan Liang <[email protected]>
The available registers for --int-regs and --user-regs may be different, e.g. XMM registers.
Quoted 8 lines
Split
parse_regsinto two dedicated functions for --int-regs and --user-regs respectively.Modify the warning message. "--user-regs=?" should be applied to show the available registers for --user-regs.
Signed-off-by Kan Liang <[email protected]>---
For patch 1 and 2,
Tested-by Ravi Bangoria <[email protected]>
Quoted 8 lines
Minor neat. Should we update document as well? May be something like:
tools/perf/Documentation/perf-record.txt--user-regs::
Similar to -I, but capture user registers at sample time. To list the available user registers use --user-regs=\?.
Hi Ravi,
Thanks for test.
The change of document looks good.
Thanks,
Kan
tip-bot for Kan Liang
merge botperf parse-regs: Split parse_regs
Commit-ID: aeea9062d949584ac1f2f9a20f0e5ed306539a3e Gitweb: https://git.kernel.org/tip/aeea9062d949584ac1f2f9a20f0e5ed306539a3e Author: Kan Liang <[email protected]> AuthorDate: Tue, 14 May 2019 13:19:32 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 15 May 2019 16:36:49 -0300
perf parse-regs: Split parse_regs
The available registers for --int-regs and --user-regs may be different, e.g. XMM registers.
Split parse_regs into two dedicated functions for --int-regs and --user-regs respectively.
Modify the warning message. "--user-regs=?" should be applied to show the available registers for --user-regs.
--- tools/perf/Documentation/perf-record.txt | 3 ++- tools/perf/builtin-record.c | 4 ++-- tools/perf/util/parse-regs-options.c | 19 ++++++++++++++++--- tools/perf/util/parse-regs-options.h | 3 ++- 4 files changed, 22 insertions(+), 7 deletions(-)
tools/perf/Documentation/perf-record.txt +2 -1
@@ -406,7 +406,8 @@ symbolic names, e.g. on x86, ax, si. To list the available registers use --intr-regs=ax,bx. The list of register is architecture dependent. --user-regs:: -Capture user registers at sample time. Same arguments as -I. +Similar to -I, but capture user registers at sample time. To list the available +user registers use --user-regs=\?. --running-time:: Record running and enabled time for read events (:S)
tools/perf/builtin-record.c +2 -2
@@ -2168,10 +2168,10 @@ static struct option __record_options[] = { "use per-thread mmaps"),OPT_CALLBACK_OPTARG ('I' ,"intr-regs" , &record.opts.sample_intr_regs,NULL ,"any register" ,"sample selected machine registers on interrupt," -" use '-I?' to list register names" , parse_regs), +" use '-I?' to list register names" , parse_intr_regs),OPT_CALLBACK_OPTARG (0 ,"user-regs" , &record.opts.sample_user_regs,NULL ,"any register" ,"sample selected machine registers on interrupt," -" use '-I?' to list register names" , parse_regs), +" use '--user-regs=?' to list register names" , parse_user_regs),OPT_BOOLEAN (0 ,"running-time" , &record.opts.running_time,"Record running/enabled time of read (:S) events" ), OPT_CALLBACK('k', "clockid", &record.opts,
tools/perf/util/parse-regs-options.c +16 -3
@@ -5,8 +5,8 @@#include <subcmd/parse-options.h> #include "util/parse-regs-options.h" -int -parse_regs (const struct option *opt,const char *str,int unset) +static int +__parse_regs (const struct option *opt,const char *str,int unset,bool intr) {uint64_t *mode = (uint64_t *)opt->value;const struct sample_reg *r;
@@ -48,7 +48,8 @@ parse_regs(const struct option *opt, const char *str, int unset)break ; }if (!r->name) { -ui__warning ("Unknown register \"%s\", check man page or run \"perf record -I?\"\n" , s); +ui__warning ("Unknown register \"%s\", check man page or run \"perf record %s?\"\n" , + s, intr ?"-I" :"--user-regs=" ); goto error; }
@@ -69,3 +70,15 @@ error:free (os);return ret; } + +int +parse_user_regs (const struct option *opt,const char *str,int unset) +{ +return __parse_regs (opt, str, unset, false); +} + +int +parse_intr_regs (const struct option *opt,const char *str,int unset) +{ +return __parse_regs (opt, str, unset, true); +}
tools/perf/util/parse-regs-options.h +2 -1
@@ -2,5 +2,6 @@#ifndef _PERF_PARSE_REGS_OPTIONS_H#define _PERF_PARSE_REGS_OPTIONS_H 1struct option ; -int parse_regs (const struct option *opt,const char *str,int unset); +int parse_user_regs (const struct option *opt,const char *str,int unset); +int parse_intr_regs (const struct option *opt,const char *str,int unset);#endif /* _PERF_PARSE_REGS_OPTIONS_H */