lkml.org 
[lkml]   [2022]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [RFC PATCH v2 3/7] libperf: Add perf_evsel__{refresh, period}() functions
Date
Hi jirka

> On Fri, Mar 25, 2022 at 01:38:25PM +0900, Shunsuke Nakamura wrote:
>
> SNIP
>
> > +int perf_evsel__refresh_cpu(struct perf_evsel *evsel, int refresh,
> > +int cpu_map_idx) {
> > + return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_REFRESH,
> refresh,
> > +cpu_map_idx); }
> > +
> > +int perf_evsel__refresh(struct perf_evsel *evsel, int refresh) {
> > + int i;
> > + int err = 0;
> > +
> > + for (i = 0; i < xyarray__max_x(evsel->fd) && !err; i++)
> > + err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_REFRESH,
> refresh, i);
> > + return err;
> > +}
> > +
> > +int perf_evsel__period_cpu(struct perf_evsel *evsel, __u64 period,
> > +int cpu_map_idx) {
> > + struct perf_event_attr *attr;
> > + int err = 0;
> > +
> > + attr = perf_evsel__attr(evsel);
> > + if (!attr)
> > + return -EINVAL;
> > +
> > + err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_PERIOD,
> > + (unsigned long)&period, cpu_map_idx);
> > + if (err)
> > + return err;
> > +
> > + attr->sample_period = period;
>
> what's the point in updating attr? this will be used after event is created right?
>
This is to maintain consistency between evsel->attr->sample_period and the sample_period of the created event.
Users can reference evsel->attr->sample_period using perf_evsel__attr().
So I thought it was necessary to update the sample_period of the event and the sample_period of evsel to avoid discrepancies.


Best Regards
Shunsuke

\
 
 \ /
  Last update: 2022-04-11 10:31    [W:0.503 / U:0.700 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site