Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3821116pxb; Tue, 17 Nov 2020 04:35:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFVK3fgs2XT/o2lkOGDN060TY5VuQoToCoiyo3hsEjhncDqyOMTgNs+Nrz/Ewhs8fC/N0A X-Received: by 2002:a17:906:4ed7:: with SMTP id i23mr10063708ejv.172.1605616558380; Tue, 17 Nov 2020 04:35:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605616558; cv=none; d=google.com; s=arc-20160816; b=gVEyNtU/MOoxHxmxWInx66ANSeQTJESYRNE8vY+zgVo6bf3uqtFlyCVrLf9ZmxfAI9 alaACoNujyzddm5UOnz1qmj6hCAfueyLOSFzrlhSxVpjB7+sHnxZ1ZB+/hWVrc7O1g1/ aXxB2X4amoYZMmHxsS6d7ua7+CFFAWPFwTDhFX0+5WqYyxyBILyx7W4/1+L4b5vMxfcs 9gNCynyIObw/HJxH/TBlcmd+07SglKPE9WOB4ai5m78J18UIAGmkFrGDN3LZzys6QopF 5+A7aGfJbcQnRurUvLIjEndYNmzjPEvcsmwCR3qLriYlun+gDcRfiAzdRBDT9xoOZ8Yy o2bQ== 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=Sg1n7PJgu7xxg2y1TCyaOIfiTReGNYTb2dXSIkAD9cs=; b=yJ+k1et4ZaNHpf9pyN50/+/qa2B6qa7j++f38G1GDN2yer6i1vd48y3OF93ZQJUJ3/ 92eo8hrJzm/RCaWP3ZvYvRSUevznoK+BZWr8mS2m7/PnY+trt8WuxrCQ+9FbzZxj4YZ/ ++kXf+ErhngDl41NlvRytpxqvVdEHcT64Wj0/vjTIc2OlY+l1b7EwpiuUo2AVOCGcjpT E4SpHWMikuTTsmubgztIR83U49/OGKRAj+avoQ/GpRhfM5UN2qyLGSdzqnSZa7tIjLan apszmyIeXteCLfTn3AclYVbWPRYeLWn3HG1IbakGwuTbEcm/X749sX1ZxEq7FV4gYvGs v1YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Bp/qErDw"; 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 h2si13348165ejd.547.2020.11.17.04.35.36; Tue, 17 Nov 2020 04:35:58 -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="Bp/qErDw"; 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 S1728015AbgKQMd1 (ORCPT + 99 others); Tue, 17 Nov 2020 07:33:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:44754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727272AbgKQMd1 (ORCPT ); Tue, 17 Nov 2020 07:33:27 -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 745602222A; Tue, 17 Nov 2020 12:33:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605616406; bh=a9U740DOhAgvSETdSFX2dByGdJRi8rwwrKDsyYyqZwo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Bp/qErDw6v3Ql3SwuLn6uKPPCDwYEW5m+AigWZjVwAMkNnroDicwr9fq8enu7Ow9f 2HejWUXrsDwHfNDBQMuAhxAG5ZktEGN7qM0mNI0XqEF3g0mWPeDYYIURdUKqEx6C1h DIlgo/J0glX610rHISxokRrfswWd2sIG0YkU6uEQ= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 5474440E29; Tue, 17 Nov 2020 09:33:24 -0300 (-03) Date: Tue, 17 Nov 2020 09:33:24 -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/24] perf tools: Add support to read build id from compressed elf Message-ID: <20201117123324.GL614220@kernel.org> References: <20201117110053.1303113-1-jolsa@kernel.org> <20201117110053.1303113-9-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201117110053.1303113-9-jolsa@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Nov 17, 2020 at 12:00:37PM +0100, Jiri Olsa escreveu: > Adding support to decompress file before reading build id. > > Adding filename__read_build_id and change its current > versions to read_build_id. > > Shutting down stderr output of perf list in the shell test: > 82: Check open filename arg using perf trace + vfs_getname : Ok > > because with decompression code in the place we the > filename__read_build_id function is more verbose in case > of error and the test did not account for that. --- because with decompression code in place filename__read_build_id() is more verbose in case of an error and the test didn't account for that. --- I'll fix it up when applying :-) - Arnaldo > Signed-off-by: Jiri Olsa > --- > .../tests/shell/trace+probe_vfs_getname.sh | 2 +- > tools/perf/util/symbol-elf.c | 37 ++++++++++++++++++- > 2 files changed, 36 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/tests/shell/trace+probe_vfs_getname.sh b/tools/perf/tests/shell/trace+probe_vfs_getname.sh > index 11cc2af13f2b..3660fcc02fef 100755 > --- a/tools/perf/tests/shell/trace+probe_vfs_getname.sh > +++ b/tools/perf/tests/shell/trace+probe_vfs_getname.sh > @@ -20,7 +20,7 @@ skip_if_no_perf_trace || exit 2 > file=$(mktemp /tmp/temporary_file.XXXXX) > > trace_open_vfs_getname() { > - evts=$(echo $(perf list syscalls:sys_enter_open* 2>&1 | egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/') > + evts=$(echo $(perf list syscalls:sys_enter_open* >&1 2>/dev/nul | egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/') > perf trace -e $evts touch $file 2>&1 | \ > egrep " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ open(at)?\((dfd: +CWD, +)?filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$" > } > diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c > index 44dd86a4f25f..f3577f7d72fe 100644 > --- a/tools/perf/util/symbol-elf.c > +++ b/tools/perf/util/symbol-elf.c > @@ -534,7 +534,7 @@ static int elf_read_build_id(Elf *elf, void *bf, size_t size) > > #ifdef HAVE_LIBBFD_BUILDID_SUPPORT > > -int filename__read_build_id(const char *filename, struct build_id *bid) > +static int read_build_id(const char *filename, struct build_id *bid) > { > size_t size = sizeof(bid->data); > int err = -1; > @@ -563,7 +563,7 @@ int filename__read_build_id(const char *filename, struct build_id *bid) > > #else // HAVE_LIBBFD_BUILDID_SUPPORT > > -int filename__read_build_id(const char *filename, struct build_id *bid) > +static int read_build_id(const char *filename, struct build_id *bid) > { > size_t size = sizeof(bid->data); > int fd, err = -1; > @@ -595,6 +595,39 @@ int filename__read_build_id(const char *filename, struct build_id *bid) > > #endif // HAVE_LIBBFD_BUILDID_SUPPORT > > +int filename__read_build_id(const char *filename, struct build_id *bid) > +{ > + struct kmod_path m = { .name = NULL, }; > + char path[PATH_MAX]; > + int err; > + > + if (!filename) > + return -EFAULT; > + > + err = kmod_path__parse(&m, filename); > + if (err) > + return -1; > + > + if (m.comp) { > + int error = 0, fd; > + > + fd = filename__decompress(filename, path, sizeof(path), m.comp, &error); > + if (fd < 0) { > + pr_debug("Failed to decompress (error %d) %s\n", > + error, filename); > + return -1; > + } > + close(fd); > + filename = path; > + } > + > + err = read_build_id(filename, bid); > + > + if (m.comp) > + unlink(filename); > + return err; > +} > + > int sysfs__read_build_id(const char *filename, struct build_id *bid) > { > size_t size = sizeof(bid->data); > -- > 2.26.2 > -- - Arnaldo