lkml.org 
[lkml]   [2022]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v4 4/6] perf cpumap: Handle dummy maps as empty in subset
On Mon, May 2, 2022 at 9:13 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 30/04/22 09:23, Ian Rogers wrote:
> > perf_cpu_map__empty is true for empty and dummy maps. Make is_subset
> > respect that.
>
> I think this might be the opposite of what I am trying to do, which is
> enable all_cpus to represent all the "cpu" values (3rd parameter of
> perf_event_open()) to iterate over including -1 so that per-thread and
> per-cpu events can be mixed.

Wouldn't you iterate over the cpus of the evsel? I'm not sure using
all_cpus in that way makes sense, it also violates the definition of
empty.

Thanks,
Ian

> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> > tools/lib/perf/cpumap.c | 4 ++--
> > tools/perf/tests/cpumap.c | 10 +++++++++-
> > 2 files changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c
> > index 384d5e076ee4..9c83675788c2 100644
> > --- a/tools/lib/perf/cpumap.c
> > +++ b/tools/lib/perf/cpumap.c
> > @@ -322,9 +322,9 @@ struct perf_cpu perf_cpu_map__max(struct perf_cpu_map *map)
> > /** Is 'b' a subset of 'a'. */
> > bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu_map *b)
> > {
> > - if (a == b || !b)
> > + if (a == b || perf_cpu_map__empty(b))
> > return true;
> > - if (!a || b->nr > a->nr)
> > + if (perf_cpu_map__empty(a) || b->nr > a->nr)
> > return false;
> >
> > for (int i = 0, j = 0; i < a->nr; i++) {
> > diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c
> > index f94929ebb54b..d52b58395385 100644
> > --- a/tools/perf/tests/cpumap.c
> > +++ b/tools/perf/tests/cpumap.c
> > @@ -128,13 +128,21 @@ static int test__cpu_map_merge(struct test_suite *test __maybe_unused, int subte
> > struct perf_cpu_map *a = perf_cpu_map__new("4,2,1");
> > struct perf_cpu_map *b = perf_cpu_map__new("4,5,7");
> > struct perf_cpu_map *c = perf_cpu_map__merge(a, b);
> > + struct perf_cpu_map *d = perf_cpu_map__dummy_new();
> > + struct perf_cpu_map *e = perf_cpu_map__merge(b, d);
> > char buf[100];
> >
> > TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(c) == 5);
> > cpu_map__snprint(c, buf, sizeof(buf));
> > TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "1-2,4-5,7"));
> > - perf_cpu_map__put(b);
> > +
> > + TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(e) == 3);
> > + cpu_map__snprint(e, buf, sizeof(buf));
> > + TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "4-5,7"));
> > +
> > perf_cpu_map__put(c);
> > + perf_cpu_map__put(d);
> > + perf_cpu_map__put(e);
> > return 0;
> > }
> >
>

\
 
 \ /
  Last update: 2022-05-02 19:06    [W:0.036 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site