Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3535265pxb; Mon, 9 Nov 2020 13:57:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuYIHOzk+jqIE3bx1ZDrXkxsLfOtIveNAdGRezQhQtHlvV5XgW7Rjoa89AbhkIQKVT6X1U X-Received: by 2002:aa7:d548:: with SMTP id u8mr17412793edr.321.1604959033536; Mon, 09 Nov 2020 13:57:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604959033; cv=none; d=google.com; s=arc-20160816; b=Z8u9TJIHnVdBvOR4fnNk0nm/uUBdhgCpOZgavckar/Az9r/UoixybNqUJiA50lrrE6 1y6kPf17GiWL13Fb7oz1Vsg6QE9fWLROjf/FrxcuR04nWmrMI75/+69V+6gcXxOds0IL RP1s5wH1oXXskmwq53MvglHwXZw4bRns/LnshYt4NWTmyKoTwbCvXegWhiRHmc/IW4Yf 0DOhz7E6mgl/El4JmhaBBFWYW8hDHzpZ9vNWj2N7yhHBSb9gYM1NjOgiYKZtvXKEBjED bLcQS2wMbIhIq8nCIutM7GyzIuWMHntCjzay7WD8HIX64IFQx4Q1eIjk68W1HxYNJmO5 kLeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=v7B87+rI3Rzdr5EhH+GfYomgGuAnV93W067stlAoXnI=; b=MQt4KrNFVtAY9v6YOKhDstgdutqgixjQyQ8w/CnL5p2U8ergnE2AEmNq1FkCyZtp5D mu4SDWC5T2NTsrLTKxVNL2/1ruqbkNrKxBp2XTiL8dUMoEgD8HdTNRmNCETgAOUswNWI YdEhzMgY/QCAmb3Z3qB+rbVBsoZKtR5j3d2YOnVy5TGJVDwc9ee3yXJ/Ey9rONx/r95f 4W4P5WyogRaZ0AYn5gu2mBeUke28UcN7UDG/wQeZcioe2f/EZi1j/G9Lp/kQfetCTU7N gDqe921dKKeEXvZI/YSiCGzBnLRj5zhRkQCfXFxI8Np/8DxT1hZyC+OXN8Rq+aVeXObI jvqw== ARC-Authentication-Results: i=1; mx.google.com; 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 b11si6412620ejz.50.2020.11.09.13.56.50; Mon, 09 Nov 2020 13:57:13 -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; 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 S1731388AbgKIVzD convert rfc822-to-8bit (ORCPT + 99 others); Mon, 9 Nov 2020 16:55:03 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:46017 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731376AbgKIVzB (ORCPT ); Mon, 9 Nov 2020 16:55:01 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-5-44kcLhkuPOqPXORLa_Us3A-1; Mon, 09 Nov 2020 16:54:54 -0500 X-MC-Unique: 44kcLhkuPOqPXORLa_Us3A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 182905F9D6; Mon, 9 Nov 2020 21:54:52 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BE316EF46; Mon, 9 Nov 2020 21:54:48 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo 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: [PATCH 08/24] perf tools: Add support to read build id from compressed elf Date: Mon, 9 Nov 2020 22:53:59 +0100 Message-Id: <20201109215415.400153-9-jolsa@kernel.org> In-Reply-To: <20201109215415.400153-1-jolsa@kernel.org> References: <20201109215415.400153-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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