Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1154695pxu; Fri, 27 Nov 2020 00:39:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmTUfaL+qFOVmJ0ZvCJjvbNdptUZeDTQ4O0nwBHUUI2ATc/mWUpVh94fqpxyBvNhHUSdoq X-Received: by 2002:a50:a410:: with SMTP id u16mr6396920edb.274.1606466348241; Fri, 27 Nov 2020 00:39:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606466348; cv=none; d=google.com; s=arc-20160816; b=D4ykxkbAxjqgQWANacbVtMnYgWSd8sx8sBtitYKSYP8WNEXagBtBOgK6KgV4y1X5A7 eQFXmpuy+yhQMirFA2cJslvucNOXe8O7KZWweg2hpwxwl5xSfOwUY/UCS07JKlMRgeaT JYExF43EicuQf66CdBloN+siR8NH/iQCkHUIpJRPm59kPQ9+wg6Vf2V3ymSP5UNbVUqD ksNqPh7wfr/1U6tMaGeuAVxaB0Qp0mik5BBzctX55s9bUC1uokC/zqEDTOmncAJhKUp4 Us8YToqeXM9bD14UUx8ysubx/XknxVDAZHTrI2pyt8Lu9yoG0TpCn3JWwam8uEJzWjuj aThQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RcQM6sTMRt7B/SLuymaoFdg7OXMqXF1n4/pVrRI/0Dc=; b=xntClnmVFArHb6DImfbbnYB05R00Cul2KkYChGTug7edLfbzt3shl+nHvAjFm8dOth 2NBKaTmWjDWeBYJ3DMiM0J9XyDsO8nCga5awi6ZNytF6p0cjznlADX8hoCfyJ/QAVIjt N7tmQLNlcYnLiyTb4j2H0URZGbIp3tO04bOvyd9QNWG3e00KxOfDOFT5nff6g531BLGb yzWKIx7QO2NwY8zyh2wbr9wj0V6B9BcKAMM+jqWsg0IL4EghBNX7T2GLvQxEe5a9gwvu TdkisjrpA7niAp1jOpK3Uz7nsYW38bK2hzMvBBq0a0hu1FkphXLy3+AVbOuvq1y6Slxm 2Wsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X7S1oTcs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot12si4568786ejb.239.2020.11.27.00.38.45; Fri, 27 Nov 2020 00:39:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X7S1oTcs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404320AbgKZRoW (ORCPT + 99 others); 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