Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3478539pxu; Tue, 15 Dec 2020 07:58:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwr7K5jfgrNWkIDfhBbhx3kLh3b1VIGischP4LLI6dFdnaUDubjrzSO9Trr62gJM0l3yHhS X-Received: by 2002:aa7:c0d6:: with SMTP id j22mr15492231edp.31.1608047907530; Tue, 15 Dec 2020 07:58:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608047907; cv=none; d=google.com; s=arc-20160816; b=KYW90R74/4iHjXe02nIu7l5lcddfuAlSPrTD+9grTKZ6cr/mdCzwD6mJTiw2DaDWZx KUhtz9V8BF2YPdiPFC5NULLqbyc8ZyKAN3Ffcx46oSnsp4cWnbmacHyfyUm0VhZKhXKC O6vgSdyIQPHLwmGT1+1qiIQiagOCK6TcDiQI8IcEecOwZc+S5f4cehGAQDFtPyeIPqz6 /SrneBJCFK+ru0W1Bev/UVa/SyCsp83KvlZ/0YpD8pXFuqDnsyt5FUIgiRbsMkTgO0c/ nisENKBOvpv86zZ5ibtw8c62xodF4ZAH0XJHBzGZZipGqWDaGe1hMh8YT87TbAApCord VQSw== 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:dkim-signature:date; bh=tuMXNrZn4HHVgJKgLzl1JAM+AsDvlvuIhW5ZNGKWaLU=; b=ztxLe4Lg1NEeuxTYt4gHWMSCtqH3Y+p4c2D40Dke74SQ76Eza41r746pS7YWdz7Afb +XNAZvN0oppkUSqzhDAQ1GB9JoA5XWG2cgkhv3MhW58uWLTQoBAwGaedPyy6slNZXT6C 6xCjzG5+XzjvJ9nTHeEvvwgTLcUuMv4Ce0O8Ji2n+bVyTOTtzaG9FJa0Ck49mji3nKeQ nw0tAXDg2MCWqUOLPDn3RWCa7kF/J4PkQ+oAouJorZREZT7oMivG56tEoH2iUF43mwKo /NXj1o8rqxu5y5OJoF3Y+QMUywhc+ZPspzz9R62ck+/omDk2+Ko9TnFLfenkn8D1mqot QKAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dWpcVdZC; 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 hs23si875609ejc.143.2020.12.15.07.58.04; Tue, 15 Dec 2020 07:58:27 -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=k20201202 header.b=dWpcVdZC; 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 S1728806AbgLOPzy (ORCPT + 99 others); Tue, 15 Dec 2020 10:55:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:41876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730304AbgLOPzb (ORCPT ); Tue, 15 Dec 2020 10:55:31 -0500 Date: Tue, 15 Dec 2020 12:55:03 -0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608047690; bh=sLW8lkGW0vdMuvlBeUnMF+afEVxJHcmfdiN4oFuShVU=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=dWpcVdZCft9LReyaAAncJweB9qsYbYOLamLRgDFlmj3vhXvnh47ijCGuNIsu75K9Q n6NO5mVXYobMqwrUEby1GGL0yIrWPl4bxnAoPSH5lFwKAANGXcImfDoctIBrNZKBq+ TiFqJr3bH63rA4b5GcdxNiDuH5kK/1nF5oPap000AOEMMI47xMqsDel8AY8CoKqBU+ xSqeIgK+vO/7BzBL3cBLK4LJ5TZ0sv3gvlTo7bxUWb4ujz3IA6SPWz8ckQDSWu3zYj mRHsb7dyKovbCf05vXj1Ls0xaquRWjEFF7TDB3TInTCbxhghZoHF2ErLtAciTpK2P+ JjL8VAphtYHig== 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 , Alexei Budankov , Andi Kleen , Adrian Hunter Subject: Re: [PATCH 06/15] perf tools: Add support to read build id from compressed elf Message-ID: <20201215155503.GM258566@kernel.org> References: <20201214105457.543111-1-jolsa@kernel.org> <20201214105457.543111-7-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201214105457.543111-7-jolsa@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Dec 14, 2020 at 11:54:48AM +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 Tentatively cherry picking this one. - Arnaldo > 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. > > 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..3d31c1d560d6 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* 2>/dev/null | 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