From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B3F5C63697 for ; Thu, 26 Nov 2020 17:44:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23DD221D7E for ; Thu, 26 Nov 2020 17:44:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="X7S1oTcs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404436AbgKZRoW (ORCPT ); Thu, 26 Nov 2020 12:44:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:38954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403951AbgKZRoV (ORCPT ); Thu, 26 Nov 2020 12:44:21 -0500 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE163207BC; Thu, 26 Nov 2020 17:44:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606412661; bh=yay4r5Dlw7NPaG6pSjpBUo5Y6nle77nuPt4XIUjjDP8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=X7S1oTcsXeqBMWGQyqKDvstzHeKUclPlhfwXZfcx+t4FMdxTPF8DVcYmlOj0xq822 ltxRa6idjcStcA6X+PWtlqpsLewhmkmhgqh9SQK13ryuETDVYNyxCPBH40F6afOHhm QifgnhrcJ/oMiv5dC8VYXUYTp1cGRvXOFl66Bn24= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 10E8C40E29; Thu, 26 Nov 2020 14:44:18 -0300 (-03) Date: Thu, 26 Nov 2020 14:44:18 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Ian Rogers , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: Re: [PATCH 08/25] perf tools: Add filename__decompress function Message-ID: <20201126174418.GJ53384@kernel.org> References: <20201126170026.2619053-1-jolsa@kernel.org> <20201126170026.2619053-9-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126170026.2619053-9-jolsa@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Nov 26, 2020 at 06:00:09PM +0100, Jiri Olsa escreveu: > Factor filename__decompress from decompress_kmodule function. > It can decompress files with compressions supported in perf - > xz and gz, the support needs to be compiled in. > > It will to be used in following changes to get build id out of > compressed elf objects. Thanks, applied. - Arnaldo > Signed-off-by: Jiri Olsa > --- > tools/perf/util/dso.c | 31 +++++++++++++++++++------------ > tools/perf/util/dso.h | 2 ++ > 2 files changed, 21 insertions(+), 12 deletions(-) > > diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c > index 89b5fd2b5de3..d786cf6b0cfa 100644 > --- a/tools/perf/util/dso.c > +++ b/tools/perf/util/dso.c > @@ -279,18 +279,12 @@ 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 *pathname, size_t len) > +int filename__decompress(const char *name, char *pathname, > + size_t len, int comp, int *err) > { > char tmpbuf[] = KMOD_DECOMP_NAME; > int fd = -1; > > - if (!dso__needs_decompress(dso)) > - return -1; > - > - if (dso->comp == COMP_ID__NONE) > - return -1; > - > /* > * We have proper compression id for DSO and yet the file > * behind the 'name' can still be plain uncompressed object. > @@ -304,17 +298,17 @@ static int decompress_kmodule(struct dso *dso, const char *name, > * To keep this transparent, we detect this and return the file > * descriptor to the uncompressed file. > */ > - if (!compressions[dso->comp].is_compressed(name)) > + if (!compressions[comp].is_compressed(name)) > return open(name, O_RDONLY); > > fd = mkstemp(tmpbuf); > if (fd < 0) { > - dso->load_errno = errno; > + *err = errno; > return -1; > } > > - if (compressions[dso->comp].decompress(name, fd)) { > - dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE; > + if (compressions[comp].decompress(name, fd)) { > + *err = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE; > close(fd); > fd = -1; > } > @@ -328,6 +322,19 @@ static int decompress_kmodule(struct dso *dso, const char *name, > return fd; > } > > +static int decompress_kmodule(struct dso *dso, const char *name, > + char *pathname, size_t len) > +{ > + if (!dso__needs_decompress(dso)) > + return -1; > + > + if (dso->comp == COMP_ID__NONE) > + return -1; > + > + return filename__decompress(name, pathname, len, dso->comp, > + &dso->load_errno); > +} > + > int dso__decompress_kmodule_fd(struct dso *dso, const char *name) > { > return decompress_kmodule(dso, name, NULL, 0); > diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h > index d8cb4f5680a4..cd2fe64a3c5d 100644 > --- a/tools/perf/util/dso.h > +++ b/tools/perf/util/dso.h > @@ -274,6 +274,8 @@ bool dso__needs_decompress(struct dso *dso); > int dso__decompress_kmodule_fd(struct dso *dso, const char *name); > int dso__decompress_kmodule_path(struct dso *dso, const char *name, > char *pathname, size_t len); > +int filename__decompress(const char *name, char *pathname, > + size_t len, int comp, int *err); > > #define KMOD_DECOMP_NAME "/tmp/perf-kmod-XXXXXX" > #define KMOD_DECOMP_LEN sizeof(KMOD_DECOMP_NAME) > -- > 2.26.2 > -- - Arnaldo