linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Deepak Surti <Deepak.Surti@arm.com>
To: "irogers@google.com" <irogers@google.com>
Cc: Ben Gainey <Ben.Gainey@arm.com>,
	"alexander.shishkin@linux.intel.com"
	<alexander.shishkin@linux.intel.com>,
	Mark Barnett <Mark.Barnett@arm.com>,
	James Clark <James.Clark@arm.com>,
	"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
	"ak@linux.intel.com" <ak@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	"will@kernel.org" <will@kernel.org>,
	Mark Rutland <Mark.Rutland@arm.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"acme@kernel.org" <acme@kernel.org>,
	"jolsa@kernel.org" <jolsa@kernel.org>,
	"namhyung@kernel.org" <namhyung@kernel.org>
Subject: Re: [PATCH v1 3/4] tools/perf: Modify event parser to support alt-period term
Date: Mon, 25 Nov 2024 16:02:02 +0000	[thread overview]
Message-ID: <c406571bc3c5ee5840ad5c59cd01ff5d7e7decd8.camel@arm.com> (raw)
In-Reply-To: <CAP-5=fVuUVQW-E1Dow-H2O6kjHnoV3Rk-H5r1mA=EBfE8SZbzg@mail.gmail.com>

On Wed, 2024-11-13 at 18:10 -0800, Ian Rogers wrote:
> On Thu, Nov 7, 2024 at 8:08 AM Deepak Surti <deepak.surti@arm.com>
> wrote:
> > 
> > From: Ben Gainey <ben.gainey@arm.com>
> > 
> > parse-events is modified, adding the "alt-period" term which can be
> > used
> > to specify the alternative sampling period.
> > 
> > Signed-off-by: Ben Gainey <ben.gainey@arm.com>
> 
> Hi Deepak,
> 
> this and the next change conflict with:
> https://lore.kernel.org/all/20241015000158.871828-1-irogers@google.com/
> https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/commit/tools/perf/tests/shell/attr.sh?h=perf-tools-next&id=8519e4f44c2af72214dc029f0334be068466e71f
> 
Hi Ian,

> Could you migrate the work to perf-tools-next?

Acknowledged. Will do this in the next version 2 of the patch.

Thanks,
Deepak

> Thanks,
> Ian
> 
> > ---
> >  tools/include/uapi/linux/perf_event.h             |  3 +++
> >  tools/perf/tests/attr.c                           |  1 +
> >  tools/perf/tests/attr.py                          |  1 +
> >  tools/perf/tests/attr/base-record                 |  3 ++-
> >  tools/perf/tests/attr/base-record-spe             |  1 +
> >  tools/perf/tests/attr/base-stat                   |  3 ++-
> >  tools/perf/tests/attr/system-wide-dummy           |  3 ++-
> >  tools/perf/tests/attr/test-record-alt-period-term | 12
> > ++++++++++++
> >  tools/perf/tests/attr/test-record-dummy-C0        |  3 ++-
> >  tools/perf/util/parse-events.c                    | 15
> > +++++++++++++++
> >  tools/perf/util/parse-events.h                    |  3 ++-
> >  tools/perf/util/parse-events.l                    |  1 +
> >  tools/perf/util/perf_event_attr_fprintf.c         |  1 +
> >  tools/perf/util/pmu.c                             |  1 +
> >  14 files changed, 46 insertions(+), 5 deletions(-)
> >  create mode 100644 tools/perf/tests/attr/test-record-alt-period-
> > term
> > 
> > diff --git a/tools/include/uapi/linux/perf_event.h
> > b/tools/include/uapi/linux/perf_event.h
> > index 4842c36fdf80..bedae424ba36 100644
> > --- a/tools/include/uapi/linux/perf_event.h
> > +++ b/tools/include/uapi/linux/perf_event.h
> > @@ -379,6 +379,7 @@ enum perf_event_read_format {
> >  #define PERF_ATTR_SIZE_VER6    120     /* add: aux_sample_size */
> >  #define PERF_ATTR_SIZE_VER7    128     /* add: sig_data */
> >  #define PERF_ATTR_SIZE_VER8    136     /* add: config3 */
> > +#define PERF_ATTR_SIZE_VER9    144     /* add:
> > alternative_sample_period */
> > 
> >  /*
> >   * Hardware event_id to monitor via a performance monitoring
> > event:
> > @@ -522,6 +523,8 @@ struct perf_event_attr {
> >         __u64   sig_data;
> > 
> >         __u64   config3; /* extension of config2 */
> > +
> > +       __u64   alternative_sample_period;
> >  };
> > 
> >  /*
> > diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
> > index 97e1bdd6ec0e..956b58c7ba8f 100644
> > --- a/tools/perf/tests/attr.c
> > +++ b/tools/perf/tests/attr.c
> > @@ -139,6 +139,7 @@ static int store_event(struct perf_event_attr
> > *attr, pid_t pid, struct perf_cpu
> >         WRITE_ASS(branch_sample_type, "llu");
> >         WRITE_ASS(sample_regs_user,   "llu");
> >         WRITE_ASS(sample_stack_user,  PRIu32);
> > +       WRITE_ASS(alternative_sample_period,  "llu");
> > 
> >         fclose(file);
> >         return 0;
> > diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py
> > index e890c261ad26..75c4527393f9 100644
> > --- a/tools/perf/tests/attr.py
> > +++ b/tools/perf/tests/attr.py
> > @@ -91,6 +91,7 @@ class Event(dict):
> >          'branch_sample_type',
> >          'sample_regs_user',
> >          'sample_stack_user',
> > +        'alternative_sample_period',
> >      ]
> > 
> >      def add(self, data):
> > diff --git a/tools/perf/tests/attr/base-record
> > b/tools/perf/tests/attr/base-record
> > index b44e4e6e4443..403de2e2c891 100644
> > --- a/tools/perf/tests/attr/base-record
> > +++ b/tools/perf/tests/attr/base-record
> > @@ -5,7 +5,7 @@ group_fd=-1
> >  flags=0|8
> >  cpu=*
> >  type=0|1
> > -size=136
> > +size=144
> >  config=0|1
> >  sample_period=*
> >  sample_type=263
> > @@ -39,3 +39,4 @@ config2=0
> >  branch_sample_type=0
> >  sample_regs_user=0
> >  sample_stack_user=0
> > +alternative_sample_period=0
> > \ No newline at end of file
> > diff --git a/tools/perf/tests/attr/base-record-spe
> > b/tools/perf/tests/attr/base-record-spe
> > index 08fa96b59240..db528d7d8b73 100644
> > --- a/tools/perf/tests/attr/base-record-spe
> > +++ b/tools/perf/tests/attr/base-record-spe
> > @@ -38,3 +38,4 @@ config2=*
> >  branch_sample_type=*
> >  sample_regs_user=*
> >  sample_stack_user=*
> > +alternative_sample_period=0
> > \ No newline at end of file
> > diff --git a/tools/perf/tests/attr/base-stat
> > b/tools/perf/tests/attr/base-stat
> > index fccd8ec4d1b0..27ef0fa1386f 100644
> > --- a/tools/perf/tests/attr/base-stat
> > +++ b/tools/perf/tests/attr/base-stat
> > @@ -5,7 +5,7 @@ group_fd=-1
> >  flags=0|8
> >  cpu=*
> >  type=0
> > -size=136
> > +size=144
> >  config=0
> >  sample_period=0
> >  sample_type=65536
> > @@ -39,3 +39,4 @@ config2=0
> >  branch_sample_type=0
> >  sample_regs_user=0
> >  sample_stack_user=0
> > +alternative_sample_period=0
> > diff --git a/tools/perf/tests/attr/system-wide-dummy
> > b/tools/perf/tests/attr/system-wide-dummy
> > index a1e1d6a263bf..5c4d2a60931d 100644
> > --- a/tools/perf/tests/attr/system-wide-dummy
> > +++ b/tools/perf/tests/attr/system-wide-dummy
> > @@ -7,7 +7,7 @@ cpu=*
> >  pid=-1
> >  flags=8
> >  type=1
> > -size=136
> > +size=144
> >  config=9
> >  sample_period=1
> >  # PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME |
> > @@ -50,3 +50,4 @@ config2=0
> >  branch_sample_type=0
> >  sample_regs_user=0
> >  sample_stack_user=0
> > +alternative_sample_period=0
> > diff --git a/tools/perf/tests/attr/test-record-alt-period-term
> > b/tools/perf/tests/attr/test-record-alt-period-term
> > new file mode 100644
> > index 000000000000..e0de4c8eb1c8
> > --- /dev/null
> > +++ b/tools/perf/tests/attr/test-record-alt-period-term
> > @@ -0,0 +1,12 @@
> > +[config]
> > +command = record
> > +args    = --no-bpf-event -e cycles/period=3,alt-period=2/ -- kill
> > >/dev/null 2>&1
> > +ret     = 1
> > +kernel_since = 6.11
> > +
> > +[event-10:base-record]
> > +sample_period=3
> > +alternative_sample_period=2
> > +
> > +freq=0
> > +sample_type=7
> > diff --git a/tools/perf/tests/attr/test-record-dummy-C0
> > b/tools/perf/tests/attr/test-record-dummy-C0
> > index 576ec48b3aaf..d4f0546e02b6 100644
> > --- a/tools/perf/tests/attr/test-record-dummy-C0
> > +++ b/tools/perf/tests/attr/test-record-dummy-C0
> > @@ -10,7 +10,7 @@ cpu=0
> >  pid=-1
> >  flags=8
> >  type=1
> > -size=136
> > +size=144
> >  config=9
> >  sample_period=4000
> >  # PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME |
> > @@ -53,3 +53,4 @@ config2=0
> >  branch_sample_type=0
> >  sample_regs_user=0
> >  sample_stack_user=0
> > +alternative_sample_period=0
> > diff --git a/tools/perf/util/parse-events.c
> > b/tools/perf/util/parse-events.c
> > index 9a8be1e46d67..48723cea3a51 100644
> > --- a/tools/perf/util/parse-events.c
> > +++ b/tools/perf/util/parse-events.c
> > @@ -826,6 +826,7 @@ static const char *config_term_name(enum
> > parse_events__term_type term_type)
> >                 [PARSE_EVENTS__TERM_TYPE_RAW]                   =
> > "raw",
> >                 [PARSE_EVENTS__TERM_TYPE_LEGACY_CACHE]          =
> > "legacy-cache",
> >                 [PARSE_EVENTS__TERM_TYPE_HARDWARE]              =
> > "hardware",
> > +               [PARSE_EVENTS__TERM_TYPE_ALT_SAMPLE_PERIOD]     =
> > "alt-period",
> >         };
> >         if ((unsigned int)term_type >=
> > __PARSE_EVENTS__TERM_TYPE_NR)
> >                 return "unknown term";
> > @@ -854,6 +855,7 @@ config_term_avail(enum parse_events__term_type
> > term_type, struct parse_events_er
> >         case PARSE_EVENTS__TERM_TYPE_NAME:
> >         case PARSE_EVENTS__TERM_TYPE_METRIC_ID:
> >         case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
> > +       case PARSE_EVENTS__TERM_TYPE_ALT_SAMPLE_PERIOD:
> >         case PARSE_EVENTS__TERM_TYPE_PERCORE:
> >                 return true;
> >         case PARSE_EVENTS__TERM_TYPE_USER:
> > @@ -998,6 +1000,16 @@ do
> > {                                                                  
> >        \
> >                         return -EINVAL;
> >                 }
> >                 break;
> > +       case PARSE_EVENTS__TERM_TYPE_ALT_SAMPLE_PERIOD:
> > +               CHECK_TYPE_VAL(NUM);
> > +               if (term->val.num == 0) {
> > +                       parse_events_error__handle(err, term-
> > >err_val,
> > +                                               strdup("expected a
> > non-zero value"),
> > +                                               NULL);
> > +                       return -EINVAL;
> > +               }
> > +               attr->alternative_sample_period = term->val.num;
> > +               break;
> >         case PARSE_EVENTS__TERM_TYPE_DRV_CFG:
> >         case PARSE_EVENTS__TERM_TYPE_USER:
> >         case PARSE_EVENTS__TERM_TYPE_LEGACY_CACHE:
> > @@ -1124,6 +1136,7 @@ static int config_term_tracepoint(struct
> > perf_event_attr *attr,
> >         case PARSE_EVENTS__TERM_TYPE_RAW:
> >         case PARSE_EVENTS__TERM_TYPE_LEGACY_CACHE:
> >         case PARSE_EVENTS__TERM_TYPE_HARDWARE:
> > +       case PARSE_EVENTS__TERM_TYPE_ALT_SAMPLE_PERIOD:
> >         default:
> >                 if (err) {
> >                         parse_events_error__handle(err, term-
> > >err_term,
> > @@ -1255,6 +1268,7 @@ do
> > {                                                              \
> >                 case PARSE_EVENTS__TERM_TYPE_RAW:
> >                 case PARSE_EVENTS__TERM_TYPE_LEGACY_CACHE:
> >                 case PARSE_EVENTS__TERM_TYPE_HARDWARE:
> > +               case PARSE_EVENTS__TERM_TYPE_ALT_SAMPLE_PERIOD:
> >                 default:
> >                         break;
> >                 }
> > @@ -1308,6 +1322,7 @@ static int get_config_chgs(struct perf_pmu
> > *pmu, struct parse_events_terms *head
> >                 case PARSE_EVENTS__TERM_TYPE_RAW:
> >                 case PARSE_EVENTS__TERM_TYPE_LEGACY_CACHE:
> >                 case PARSE_EVENTS__TERM_TYPE_HARDWARE:
> > +               case PARSE_EVENTS__TERM_TYPE_ALT_SAMPLE_PERIOD:
> >                 default:
> >                         break;
> >                 }
> > diff --git a/tools/perf/util/parse-events.h
> > b/tools/perf/util/parse-events.h
> > index 10cc9c433116..f1482361321a 100644
> > --- a/tools/perf/util/parse-events.h
> > +++ b/tools/perf/util/parse-events.h
> > @@ -79,7 +79,8 @@ enum parse_events__term_type {
> >         PARSE_EVENTS__TERM_TYPE_RAW,
> >         PARSE_EVENTS__TERM_TYPE_LEGACY_CACHE,
> >         PARSE_EVENTS__TERM_TYPE_HARDWARE,
> > -#define        __PARSE_EVENTS__TERM_TYPE_NR
> > (PARSE_EVENTS__TERM_TYPE_HARDWARE + 1)
> > +       PARSE_EVENTS__TERM_TYPE_ALT_SAMPLE_PERIOD,
> > +#define        __PARSE_EVENTS__TERM_TYPE_NR
> > (PARSE_EVENTS__TERM_TYPE_ALT_SAMPLE_PERIOD + 1)
> >  };
> > 
> >  struct parse_events_term {
> > diff --git a/tools/perf/util/parse-events.l
> > b/tools/perf/util/parse-events.l
> > index 5a0bcd7f166a..1972a5a696ef 100644
> > --- a/tools/perf/util/parse-events.l
> > +++ b/tools/perf/util/parse-events.l
> > @@ -331,6 +331,7 @@ percore                     { return
> > term(yyscanner, PARSE_EVENTS__TERM_TYPE_PERCORE); }
> >  aux-output             { return term(yyscanner,
> > PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT); }
> >  aux-sample-size                { return term(yyscanner,
> > PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE); }
> >  metric-id              { return term(yyscanner,
> > PARSE_EVENTS__TERM_TYPE_METRIC_ID); }
> > +alt-period             { return term(yyscanner,
> > PARSE_EVENTS__TERM_TYPE_ALT_SAMPLE_PERIOD); }
> >  cpu-cycles|cycles                              { return
> > hw_term(yyscanner, PERF_COUNT_HW_CPU_CYCLES); }
> >  stalled-cycles-frontend|idle-cycles-frontend   { return
> > hw_term(yyscanner, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); }
> >  stalled-cycles-backend|idle-cycles-backend     { return
> > hw_term(yyscanner, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); }
> > diff --git a/tools/perf/util/perf_event_attr_fprintf.c
> > b/tools/perf/util/perf_event_attr_fprintf.c
> > index 59fbbba79697..c6af598070b5 100644
> > --- a/tools/perf/util/perf_event_attr_fprintf.c
> > +++ b/tools/perf/util/perf_event_attr_fprintf.c
> > @@ -335,6 +335,7 @@ int perf_event_attr__fprintf(FILE *fp, struct
> > perf_event_attr *attr,
> >         PRINT_ATTRf(sample_max_stack, p_unsigned);
> >         PRINT_ATTRf(aux_sample_size, p_unsigned);
> >         PRINT_ATTRf(sig_data, p_unsigned);
> > +       PRINT_ATTRf(alternative_sample_period, p_unsigned);
> > 
> >         return ret;
> >  }
> > diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> > index 61bdda01a05a..7615d05e389f 100644
> > --- a/tools/perf/util/pmu.c
> > +++ b/tools/perf/util/pmu.c
> > @@ -1738,6 +1738,7 @@ int perf_pmu__for_each_format(struct perf_pmu
> > *pmu, void *state, pmu_format_call
> >                 "percore",
> >                 "aux-output",
> >                 "aux-sample-size=number",
> > +               "alt-period=number",
> >         };
> >         struct perf_pmu_format *format;
> >         int ret;
> > --
> > 2.43.0
> > 

  reply	other threads:[~2024-11-25 16:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 16:07 [PATCH v1 0/4] A mechanism for efficient support for per-function metrics Deepak Surti
2024-11-07 16:07 ` [PATCH v1 1/4] perf: Allow periodic events to alternate between two sample periods Deepak Surti
2024-11-14 15:01   ` Peter Zijlstra
2024-11-25 17:11     ` Deepak Surti
2024-11-07 16:07 ` [PATCH v1 2/4] perf: Allow adding fixed random jitter to the alternate sampling period Deepak Surti
2024-11-07 16:07 ` [PATCH v1 3/4] tools/perf: Modify event parser to support alt-period term Deepak Surti
2024-11-14  2:10   ` Ian Rogers
2024-11-25 16:02     ` Deepak Surti [this message]
2024-11-07 16:07 ` [PATCH v1 4/4] tools/perf: Modify event parser to support alt-period-jitter term Deepak Surti
2024-11-14  2:22 ` [PATCH v1 0/4] A mechanism for efficient support for per-function metrics Ian Rogers
2024-11-14 14:36   ` James Clark
2024-11-25 17:05   ` Deepak Surti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c406571bc3c5ee5840ad5c59cd01ff5d7e7decd8.camel@arm.com \
    --to=deepak.surti@arm.com \
    --cc=Ben.Gainey@arm.com \
    --cc=James.Clark@arm.com \
    --cc=Mark.Barnett@arm.com \
    --cc=Mark.Rutland@arm.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).