Re: [PATCH 3/3 v2] perf symbols: convert symbol__is_idle to use strlist

From: Song Liu
Date: Mon Feb 10 2020 - 13:52:31 EST




> On Feb 10, 2020, at 8:31 AM, Kim Phillips <kim.phillips@xxxxxxx> wrote:
>
> Use the more optimized strlist implementation to do the idle function
> lookup.
>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Cc: Mark Rutland <mark.rutland@xxxxxxx>
> Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Cc: Cong Wang <xiyou.wangcong@xxxxxxxxx>
> Cc: Jin Yao <yao.jin@xxxxxxxxxxxxxxx>
> Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
> Cc: Kim Phillips <kim.phillips@xxxxxxx>
> Cc: Song Liu <songliubraving@xxxxxx>
> Cc: Davidlohr Bueso <dave@xxxxxxxxxxxx>
> Cc: linux-perf-users@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
> Signed-off-by: Kim Phillips <kim.phillips@xxxxxxx>
> ---
> v2: new this series, based on Jiri's comment:
>
> https://lore.kernel.org/lkml/20200120092844.GC608405@krava/
>
> ...and this time with the Cc list intact.
>
> tools/perf/util/symbol.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index f3120c4f47ad..1077013d8ce2 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -654,13 +654,17 @@ static bool symbol__is_idle(const char *name)
> NULL
> };
> int i;
> + static struct strlist *idle_symbols_list;

nit, probably just personal preference:

Maybe move idle_symbols_list out of the function and add the logic
to symbol__init()?

Other than this:

Acked-by: Song Liu <songliubraving@xxxxxx>

>
> - for (i = 0; idle_symbols[i]; i++) {
> - if (!strcmp(idle_symbols[i], name))
> - return true;
> - }
> + if (idle_symbols_list)
> + return strlist__has_entry(idle_symbols_list, name);
>
> - return false;
> + idle_symbols_list = strlist__new(NULL, NULL);
> +
> + for (i = 0; idle_symbols[i]; i++)
> + strlist__add(idle_symbols_list, idle_symbols[i]);
> +
> + return strlist__has_entry(idle_symbols_list, name);
> }
>
> static int map__process_kallsym_symbol(void *arg, const char *name,
> --
> 2.25.0
>