Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2147027imm; Thu, 9 Aug 2018 08:03:57 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw6XZvQSXAcMPNqccHFXHgp5JDYSMz9zlnGjOIPmxqW0lFUfN5If/w8WEsMuQ/+gKyCIGQa X-Received: by 2002:a63:f657:: with SMTP id u23-v6mr2560996pgj.258.1533827037338; Thu, 09 Aug 2018 08:03:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533827037; cv=none; d=google.com; s=arc-20160816; b=EaTmoRu773KyQo+quLT2Wj1JwhpNeZibsPjaieqHgvp3bCc3RevVF9xR7DxUYy598a zAMsNsU/mjftO2xwM/CeMUIWu2Zp8b42piw17tZE/bzsm6Xh74tcLiZwzNvMqgh4RgnF Uh2nxMSTACoYDnvl5Gczw3qWt3x2ua7C2Bq7SbnmiwVnZtocKCrcyjKVjKjjPLH5EkYO 0l6Yu4L2sQgiHV740I44IBdWw04zgXOVinXywhwgFo6oYN7UvIcJOe7Af7LKGosmaawH 9dqqebzMdtuk0sxkDoBiOyLTqbJdYaBLlLofXqwT6Rsnn9//k/grZ/urbmYYXLYTT/qM abUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=B/p9hLZxLvcMzClaWzfMlX3dp6RSO7D5MldESd0iNYg=; b=0kMXOJcr/E+3Xi+8CyZEAmsziKMN+1CODkV4omvuj4PYeS9/ptZgtGBLyiPvJK+rl9 7+jP0r4uNsdubKQvUuHnid1SDj1TlzpsiRCnt5ch7cx/MXix6RX13TdV5Jm8jm44EIVJ AR8E14Ynd9HBw0TU2MXFMM//nV0tiWMpGVE4I6EtITFKmACFIcgcZvKY1GoSGsY529Wy eix+qJoNqX+QNYKxNhBEMZynt1XIUtNOKPn6SgGtXpFE+ARdhIvihswQlqVw5HvaNJU7 dEUOj7fm3shTh81wHeLmNt7Jwul1EtciufMG0r/b07ot5qPloKpKpqDb8SUc/GVj53jU iZtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pSSQFlOl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id x17-v6si5524987pln.465.2018.08.09.08.03.42; Thu, 09 Aug 2018 08:03:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pSSQFlOl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1733141AbeHIR0r (ORCPT + 99 others); Thu, 9 Aug 2018 13:26:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:38818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730634AbeHIR0q (ORCPT ); Thu, 9 Aug 2018 13:26:46 -0400 Received: from jouet.infradead.org (179-240-153-38.3g.claro.net.br [179.240.153.38]) (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 2FCDE214FF; Thu, 9 Aug 2018 15:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533826888; bh=S6DDdvEAqSq2l2P4q2iqaUnrfpf5247BKjYniTcSYGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pSSQFlOlcfN1lcm6i51OJZsyuOXqW2CRsC+Cb+Ttl0pZIg4N7Jv9wHvjDKl1ronc+ 6Ystzn2OdFn8utzw+4QvmbPrVxxiJTuFbWigLkSRLd/Wz2d8raHegH68D2/L9DGxbN BGvLydH2zQPTFnj+YevIZ76lKjXxouWGTkXKHWSc= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Jiri Olsa , Namhyung Kim , Wang Nan Subject: [PATCH 36/44] perf bpf: Generalize bpf__setup_stdout() Date: Thu, 9 Aug 2018 11:58:14 -0300 Message-Id: <20180809145822.21391-37-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180809145822.21391-1-acme@kernel.org> References: <20180809145822.21391-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo We will use it to set up other bpf-output events, for instance to generate augmented syscall entry tracepoints with pointer contents. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-4r7kw0nsyi4vyz6xm1tzx6a3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 26 +++++++++++++++++--------- tools/perf/util/bpf-loader.h | 7 +++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index e864a7e0ff12..95a27bb6f1a1 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -1535,10 +1535,7 @@ int bpf__apply_obj_config(void) (strcmp(name, \ bpf_map__name(pos)) == 0)) -#define bpf__for_each_stdout_map(pos, obj, objtmp) \ - bpf__for_each_map_named(pos, obj, objtmp, "__bpf_stdout__") - -int bpf__setup_stdout(struct perf_evlist *evlist) +int bpf__setup_output_event(struct perf_evlist *evlist, const char *name) { struct bpf_map_priv *tmpl_priv = NULL; struct bpf_object *obj, *tmp; @@ -1547,7 +1544,7 @@ int bpf__setup_stdout(struct perf_evlist *evlist) int err; bool need_init = false; - bpf__for_each_stdout_map(map, obj, tmp) { + bpf__for_each_map_named(map, obj, tmp, name) { struct bpf_map_priv *priv = bpf_map__priv(map); if (IS_ERR(priv)) @@ -1567,17 +1564,23 @@ int bpf__setup_stdout(struct perf_evlist *evlist) return 0; if (!tmpl_priv) { - err = parse_events(evlist, "bpf-output/no-inherit=1,name=__bpf_stdout__/", - NULL); + char *event_definition = NULL; + + if (asprintf(&event_definition, "bpf-output/no-inherit=1,name=%s/", name) < 0) + return -ENOMEM; + + err = parse_events(evlist, event_definition, NULL); + free(event_definition); + if (err) { - pr_debug("ERROR: failed to create bpf-output event\n"); + pr_debug("ERROR: failed to create the \"%s\" bpf-output event\n", name); return -err; } evsel = perf_evlist__last(evlist); } - bpf__for_each_stdout_map(map, obj, tmp) { + bpf__for_each_map_named(map, obj, tmp, name) { struct bpf_map_priv *priv = bpf_map__priv(map); if (IS_ERR(priv)) @@ -1609,6 +1612,11 @@ int bpf__setup_stdout(struct perf_evlist *evlist) return 0; } +int bpf__setup_stdout(struct perf_evlist *evlist) +{ + return bpf__setup_output_event(evlist, "__bpf_stdout__"); +} + #define ERRNO_OFFSET(e) ((e) - __BPF_LOADER_ERRNO__START) #define ERRCODE_OFFSET(c) ERRNO_OFFSET(BPF_LOADER_ERRNO__##c) #define NR_ERRNO (__BPF_LOADER_ERRNO__END - __BPF_LOADER_ERRNO__START) diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h index 5d3aefd6fae7..6be0eec043c6 100644 --- a/tools/perf/util/bpf-loader.h +++ b/tools/perf/util/bpf-loader.h @@ -82,6 +82,7 @@ int bpf__apply_obj_config(void); int bpf__strerror_apply_obj_config(int err, char *buf, size_t size); int bpf__setup_stdout(struct perf_evlist *evlist); +int bpf__setup_output_event(struct perf_evlist *evlist, const char *name); int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err, char *buf, size_t size); @@ -138,6 +139,12 @@ bpf__setup_stdout(struct perf_evlist *evlist __maybe_unused) return 0; } +static inline int +bpf__setup_output_event(struct perf_evlist *evlist __maybe_unused, const char *name __maybe_unused) +{ + return 0; +} + static inline int __bpf_strerror(char *buf, size_t size) { -- 2.14.4