Re: [PATCH v2 1/3] perf tools: Introduce dso__decompress_kmodule_{fd,path}

From: Jiri Olsa
Date: Mon Jun 05 2017 - 05:58:08 EST


On Sat, Jun 03, 2017 at 11:00:31AM +0900, Namhyung Kim wrote:
> Move decompress_kmodule() to util/dso.c and split it to two functions
> returning fd and (decompressed) file path. Existing user only wants the
> fd version but the path version will be used soon.
>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> ---
> tools/perf/util/dso.c | 51 ++++++++++++++++++++++++++++++++++++++++++++
> tools/perf/util/dso.h | 3 +++
> tools/perf/util/symbol-elf.c | 36 +------------------------------
> 3 files changed, 55 insertions(+), 35 deletions(-)
>
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index b27d127cdf68..fc4747a8c283 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -248,6 +248,57 @@ bool dso__needs_decompress(struct dso *dso)
> dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
> }
>
> +static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf)
> +{
> + int fd = -1;
> + struct kmod_path m;
> +
> + if (!dso__needs_decompress(dso))
> + return -1;

the original code had also DSO_BINARY_TYPE__BUILD_ID_CACHE check,
not sure why though.. ;-)

jirka