Re: [PATCH v5 3/3] libperf tests: Add test_stat_multiplexing test

From: nakamura.shun@xxxxxxxxxxx
Date: Tue Dec 21 2021 - 03:25:41 EST


Hi Namhyung

Sorry for the late reply.

> > +static double display_error(long long average,
> > + long long high,
> > + long long low,
> > + long long expected)
> > +{
> > + double error;
> > +
> > + error = (((double)average - expected) / expected) * 100.0;
> > +
> > + __T_VERBOSE(" Expected: %lld\n", expected);
> > + __T_VERBOSE(" High: %lld Low: %lld Average: %lld\n",
> > + high, low, average);
> > +
> > + __T_VERBOSE(" Average Error = %.2f%%\n", error);
> > +
> > + return error;
> > +}
> > +
> > +static int test_stat_multiplexing(void)
> > +{
> > + struct perf_counts_values expected_counts = { .val = 0 };
> > + struct perf_counts_values counts[EVENT_NUM] = {{ .val = 0 },};
> > + struct perf_thread_map *threads;
> > + struct perf_evlist *evlist;
> > + struct perf_evsel *evsel;
> > + struct perf_event_attr attr = {
> > + .type = PERF_TYPE_HARDWARE,
> > + .config = PERF_COUNT_HW_INSTRUCTIONS,
> > + .read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
> > + PERF_FORMAT_TOTAL_TIME_RUNNING,
> > + .disabled = 1,
>
> It'd be nice if you use a less restrictive event attribute
> so that we can test it on VM or with non-root.
>
> How about using SOFTWARE / CPU_CLOCKS with
> exclude_kernel = 1 ?

I'm currently working on adding a new API for libperf.
So, I will respond to the above comments around the end of January.


Best Regards
Shunsuke