Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2755570ybk; Mon, 18 May 2020 07:12:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7Oge99lOeLkblkIV0asotl+XbJ5atPY2bUcCdH1oUQ7nfSnuyfnAYYOGFQ6gS0fgM89aA X-Received: by 2002:a17:906:a88c:: with SMTP id ha12mr15363235ejb.220.1589811169844; Mon, 18 May 2020 07:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589811169; cv=none; d=google.com; s=arc-20160816; b=kdkf6j2I0CGTkZEFJUAuce6sCTfphCnyEqkqxLH7Ka2epueHPxd2wabmkHwS00uH1J zRmTCqHJf8T7ra/U335CRNZRwB79xaSuAPkaPAg0fcsGfTK9nMQCfdrbSdJ7ELnOM0UY ebc+8BE3ASffmBJNhINFrquQGyES5mzE02VJ6DpauvbCJfqngb+3QmejB7scla9Mgzls 8p00Jxq8M/M8E64RcZhIghQJ8jvd8FXieyN/w/fftDSXKwhEyp/wO9MqdttryA/IkToz l0Y5JjECPoBbRIY31IiaSbYymA5aGFm2pW/0iq8xaLzeWq22hvZSBI2Vi/BJWoy/mUTL Tc0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=uxQMuWPNf/nE5bxTqk8rCNGwX3MhOcwbAAeXqQlJvPQ=; b=XUBKR7krAIQdUC/9ZsZNey+w8snzdUiIvg2o8/blZxpbe5GGKqhUOZAdYcANKna38u QccmRu4qVVTqxkn0JIe4o2NEvcgkt+Foxw2TX8Qok3j+Wnf/mZjfiDsoZPFUtHOzNnbO SYELER5bpBNR0dyWoh6L3vdwqFWKZh1Zo2Uhg27wApJPlagc50RLZLXOoE0xHtrSYj4l joCyeNjpgKhmXh6Upi6lIosuvONcOTxQqS+mtYYuqqnjJTUAynKELT8/zqB74evs5Xps UWXoZC4fURakCrhYzhB04gWN/6t0c1+d1W646YcPwIhRSPi4KAkMg99D6KFUNIp+E6g0 7uig== 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 o14si6720367ejx.69.2020.05.18.07.12.24; Mon, 18 May 2020 07:12:49 -0700 (PDT) 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 S1727122AbgEROKi convert rfc822-to-8bit (ORCPT + 99 others); Mon, 18 May 2020 10:10:38 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:54984 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726945AbgEROKi (ORCPT ); Mon, 18 May 2020 10:10:38 -0400 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-294-Rc9al0JYPzyOmqTSwBUjXQ-1; Mon, 18 May 2020 10:10:32 -0400 X-MC-Unique: Rc9al0JYPzyOmqTSwBUjXQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D090D835B8B; Mon, 18 May 2020 14:10:30 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.196.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id C71332CD69; Mon, 18 May 2020 14:10:28 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [RFC] perf trace: Fix compilation error for make NO_LIBBPF=1 DEBUG=1 Date: Mon, 18 May 2020 16:10:27 +0200 Message-Id: <20200518141027.3765877-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I haven't tested if this breaks some perf trace functionality, hence RFC ;-) The perf compilation fails for NO_LIBBPF=1 DEBUG=1 with: $ make NO_LIBBPF=1 DEBUG=1 BUILD: Doing 'make -j8' parallel build CC builtin-trace.o LD perf-in.o LINK perf /usr/bin/ld: perf-in.o: in function `trace__find_bpf_map_by_name': /home/jolsa/kernel/linux-perf/tools/perf/builtin-trace.c:4608: undefined reference to `bpf_object__find_map_by_name' collect2: error: ld returned 1 exit status make[2]: *** [Makefile.perf:631: perf] Error 1 make[1]: *** [Makefile.perf:225: sub-make] Error 2 make: *** [Makefile:70: all] Error 2 Moving trace__find_bpf_map_by_name calls under HAVE_LIBBPF_SUPPORT ifdef and add make test for this. Signed-off-by: Jiri Olsa --- tools/perf/builtin-trace.c | 54 ++++++++++++++++++++++++-------------- tools/perf/tests/make | 1 + 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 56bcf1ab19f8..61bafca1018a 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3174,6 +3174,26 @@ static int trace__set_ev_qualifier_tp_filter(struct trace *trace) } #ifdef HAVE_LIBBPF_SUPPORT +static struct bpf_map *trace__find_bpf_map_by_name(struct trace *trace, const char *name) +{ + if (trace->bpf_obj == NULL) + return NULL; + + return bpf_object__find_map_by_name(trace->bpf_obj, name); +} + +static void trace__set_bpf_map_filtered_pids(struct trace *trace) +{ + trace->filter_pids.map = trace__find_bpf_map_by_name(trace, "pids_filtered"); +} + +static void trace__set_bpf_map_syscalls(struct trace *trace) +{ + trace->syscalls.map = trace__find_bpf_map_by_name(trace, "syscalls"); + trace->syscalls.prog_array.sys_enter = trace__find_bpf_map_by_name(trace, "syscalls_sys_enter"); + trace->syscalls.prog_array.sys_exit = trace__find_bpf_map_by_name(trace, "syscalls_sys_exit"); +} + static struct bpf_program *trace__find_bpf_program_by_title(struct trace *trace, const char *name) { if (trace->bpf_obj == NULL) @@ -3512,6 +3532,20 @@ static void trace__delete_augmented_syscalls(struct trace *trace) trace->bpf_obj = NULL; } #else // HAVE_LIBBPF_SUPPORT +static struct bpf_map *trace__find_bpf_map_by_name(struct trace *trace __maybe_unused, + const char *name __maybe_unused) +{ + return NULL; +} + +static void trace__set_bpf_map_filtered_pids(struct trace *trace __maybe_unused) +{ +} + +static void trace__set_bpf_map_syscalls(struct trace *trace __maybe_unused) +{ +} + static int trace__set_ev_qualifier_bpf_filter(struct trace *trace __maybe_unused) { return 0; @@ -4600,26 +4634,6 @@ static int trace__parse_cgroups(const struct option *opt, const char *str, int u return 0; } -static struct bpf_map *trace__find_bpf_map_by_name(struct trace *trace, const char *name) -{ - if (trace->bpf_obj == NULL) - return NULL; - - return bpf_object__find_map_by_name(trace->bpf_obj, name); -} - -static void trace__set_bpf_map_filtered_pids(struct trace *trace) -{ - trace->filter_pids.map = trace__find_bpf_map_by_name(trace, "pids_filtered"); -} - -static void trace__set_bpf_map_syscalls(struct trace *trace) -{ - trace->syscalls.map = trace__find_bpf_map_by_name(trace, "syscalls"); - trace->syscalls.prog_array.sys_enter = trace__find_bpf_map_by_name(trace, "syscalls_sys_enter"); - trace->syscalls.prog_array.sys_exit = trace__find_bpf_map_by_name(trace, "syscalls_sys_exit"); -} - static int trace__config(const char *var, const char *value, void *arg) { struct trace *trace = arg; diff --git a/tools/perf/tests/make b/tools/perf/tests/make index 5d0c3a9c47a1..c3c59def9f87 100644 --- a/tools/perf/tests/make +++ b/tools/perf/tests/make @@ -84,6 +84,7 @@ make_no_libaudit := NO_LIBAUDIT=1 make_no_libbionic := NO_LIBBIONIC=1 make_no_auxtrace := NO_AUXTRACE=1 make_no_libbpf := NO_LIBBPF=1 +make_no_libbpf_DEBUG := NO_LIBBPF=1 DEBUG=1 make_no_libcrypto := NO_LIBCRYPTO=1 make_with_babeltrace:= LIBBABELTRACE=1 make_no_sdt := NO_SDT=1 -- 2.25.4