From patchwork Thu Apr 5 15:16:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 895439 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40H61s44K2z9s0p for ; Fri, 6 Apr 2018 01:19:29 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751579AbeDEPQ7 (ORCPT ); Thu, 5 Apr 2018 11:16:59 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34448 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751179AbeDEPQ5 (ORCPT ); Thu, 5 Apr 2018 11:16:57 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39F4A40704BE; Thu, 5 Apr 2018 15:16:57 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7212AB400; Thu, 5 Apr 2018 15:16:53 +0000 (UTC) From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann Cc: lkml , netdev@vger.kernel.org, linux-kbuild@vger.kernel.org, Quentin Monnet , Eugene Syromiatnikov , Jiri Benc , Stanislav Kozina , Jerome Marchand , Arnaldo Carvalho de Melo , Masahiro Yamada , Michal Marek , Jiri Kosina Subject: [PATCH 2/9] perf tools: Add fetch_kernel_buildid function Date: Thu, 5 Apr 2018 17:16:38 +0200 Message-Id: <20180405151645.19130-3-jolsa@kernel.org> In-Reply-To: <20180405151645.19130-1-jolsa@kernel.org> References: <20180405151645.19130-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 05 Apr 2018 15:16:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 05 Apr 2018 15:16:57 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@kernel.org' RCPT:'' Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Adding fetch_kernel_buildid helper function to retrieve build id from running kernel. It will be used in following patches. Link: http://lkml.kernel.org/n/tip-at98orsncas8v2ito61u3qod@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/util.c | 18 ++++++++++++++++++ tools/perf/util/util.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 41fc61d941ef..26f93866bc02 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -495,6 +495,24 @@ int parse_notes_buildid(void *note_data, size_t note_len, void *bf, return -1; } +int fetch_kernel_buildid(char *buildid, int size) +{ + char path[PATH_MAX], *buf; + size_t len; + int err; + + scnprintf(path, PATH_MAX, "%s/kernel/notes", + sysfs__mountpoint()); + + if (filename__read_str(path, &buf, &len)) + return -EINVAL; + + err = parse_notes_buildid(buf, len, buildid, size, false); + + free(buf); + return err; +} + const char *perf_tip(const char *dirpath) { struct strlist *tips; diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 27106548396b..1ccaa957e3ab 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -48,6 +48,8 @@ extern int cacheline_size; int fetch_kernel_version(unsigned int *puint, char *str, size_t str_sz); +int fetch_kernel_buildid(char *buildid, int size); + int parse_notes_buildid(void *note_data, size_t note_len, void *bf, size_t size, bool need_swap);