Received: by 10.223.185.116 with SMTP id b49csp6981508wrg; Wed, 28 Feb 2018 20:23:57 -0800 (PST) X-Google-Smtp-Source: AG47ELvwm3OArjMQMxcayT05K8QxAILtosTl6uVqQJEDBK5EsPX9Q2foEy6TpAX7Uv5G64fi2gWn X-Received: by 10.99.186.88 with SMTP id l24mr446671pgu.369.1519878237021; Wed, 28 Feb 2018 20:23:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519878236; cv=none; d=google.com; s=arc-20160816; b=T3w7g3d9tetoo6hVmo9ZOYVfC65I/QQqsxW6HWCUvgUtIYoeviGeDE+FJpWlfKlxnK vZsh+9f3Xk3F5hhBeypAruvq+UB7iNMZkq/m+wXuIDPmF7UQMKS8cxW2Rx0uobwVXFXo 26ec+qanlmOU6nwzKzioyxD6H4LVcd7wBjV+tyJNKfWI4p9RASfSs4UqB/rSNxd3NTJR TFJuLr1XVwJiWJY87247PiKJSORMB3OHIg+qCY1SeecHHzfQXDF6082vdmZNEcxRLBib ZK3Qd2oHU/Ghy277OHQxSOicwOSsj5WeaBlObz6ws02zm4H2XPiwthBVgjwPYVu8sN+f rqXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:smtp-origin-cluster:cc:to :smtp-origin-hostname:from:smtp-origin-hostprefix :arc-authentication-results; bh=lK1T7xi1wjvgCjZWqEpF2Dg4Fswck8qSOH5VfD/mCjw=; b=IavLyv4MGjEVLE4G52MAYO0SuPzGBQTFHF0Etg4OAikWcLX7fJ1k3Htv0BBF0TgVex hkPQRa78o/EAScEJLnm8iNIVqYNCExmIsPZdZtRGYtdglWFTb3NTZuR0S94j4kdCpSHC BlNLmmPzSl7NK/zXw/BiZ7zdE4Thtcm4dHxBIbyhzAl/+aUiCUFfwBelEg0g8DbvMbWT c30AyYJW/MnAn/7dLU1O3qy/iMIhz47Bscj9h+fz2a2xTkifocx2gunteE0MCb9HnCfU dsZ+2ZHCHyOZ1mH0OTazeMlNS9oZZNugclrMzATOJkB8xMV/G+/YkHeVcm9smbP8rdPF RPYA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20si1955835pgc.137.2018.02.28.20.23.42; Wed, 28 Feb 2018 20:23:56 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965905AbeCAEUd (ORCPT + 99 others); Wed, 28 Feb 2018 23:20:33 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:47914 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965854AbeCAET7 (ORCPT ); Wed, 28 Feb 2018 23:19:59 -0500 Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w214FTrf016770 for ; Wed, 28 Feb 2018 20:19:59 -0800 Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2ge943863b-6 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 28 Feb 2018 20:19:59 -0800 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB03.TheFacebook.com (192.168.16.13) with Microsoft SMTP Server id 14.3.361.1; Wed, 28 Feb 2018 20:19:58 -0800 Received: by devbig500.prn1.facebook.com (Postfix, from userid 572438) id 99FCF2181285; Wed, 28 Feb 2018 20:19:57 -0800 (PST) Smtp-Origin-Hostprefix: devbig From: Alexei Starovoitov Smtp-Origin-Hostname: devbig500.prn1.facebook.com To: CC: , , , , , , , , Smtp-Origin-Cluster: prn1c29 Subject: [PATCH bpf-next 5/5] samples/bpf: raw tracepoint test Date: Wed, 28 Feb 2018 20:19:57 -0800 Message-ID: <20180301041957.399230-6-ast@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180301041957.399230-1-ast@kernel.org> References: <20180301041957.399230-1-ast@kernel.org> X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-01_02:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org empty raw_tracepoint bpf program to test overhead Signed-off-by: Alexei Starovoitov --- samples/bpf/Makefile | 1 + samples/bpf/bpf_load.c | 13 +++++++++++++ samples/bpf/test_overhead_raw_tp_kern.c | 17 +++++++++++++++++ samples/bpf/test_overhead_user.c | 12 ++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 samples/bpf/test_overhead_raw_tp_kern.c diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 2c2a587e0942..4d6a6edd4bf6 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -119,6 +119,7 @@ always += offwaketime_kern.o always += spintest_kern.o always += map_perf_test_kern.o always += test_overhead_tp_kern.o +always += test_overhead_raw_tp_kern.o always += test_overhead_kprobe_kern.o always += parse_varlen.o parse_simple.o parse_ldabs.o always += test_cgrp2_tc_kern.o diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c index 69806d74fa53..46e9195dc665 100644 --- a/samples/bpf/bpf_load.c +++ b/samples/bpf/bpf_load.c @@ -61,6 +61,7 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size) bool is_kprobe = strncmp(event, "kprobe/", 7) == 0; bool is_kretprobe = strncmp(event, "kretprobe/", 10) == 0; bool is_tracepoint = strncmp(event, "tracepoint/", 11) == 0; + bool is_raw_tracepoint = strncmp(event, "raw_tracepoint/", 15) == 0; bool is_xdp = strncmp(event, "xdp", 3) == 0; bool is_perf_event = strncmp(event, "perf_event", 10) == 0; bool is_cgroup_skb = strncmp(event, "cgroup/skb", 10) == 0; @@ -84,6 +85,8 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size) prog_type = BPF_PROG_TYPE_KPROBE; } else if (is_tracepoint) { prog_type = BPF_PROG_TYPE_TRACEPOINT; + } else if (is_raw_tracepoint) { + prog_type = BPF_PROG_TYPE_RAW_TRACEPOINT; } else if (is_xdp) { prog_type = BPF_PROG_TYPE_XDP; } else if (is_perf_event) { @@ -128,6 +131,15 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size) return populate_prog_array(event, fd); } + if (is_raw_tracepoint) { + efd = bpf_raw_tracepoint_open(event + 15); + if (efd < 0) { + printf("tracepoint %s %s\n", event + 15, strerror(errno)); + return -1; + } + return bpf_prog_attach(fd, efd, BPF_RAW_TRACEPOINT, 0); + } + if (is_kprobe || is_kretprobe) { if (is_kprobe) event += 7; @@ -584,6 +596,7 @@ static int do_load_bpf_file(const char *path, fixup_map_cb fixup_map) if (memcmp(shname, "kprobe/", 7) == 0 || memcmp(shname, "kretprobe/", 10) == 0 || memcmp(shname, "tracepoint/", 11) == 0 || + memcmp(shname, "raw_tracepoint/", 15) == 0 || memcmp(shname, "xdp", 3) == 0 || memcmp(shname, "perf_event", 10) == 0 || memcmp(shname, "socket", 6) == 0 || diff --git a/samples/bpf/test_overhead_raw_tp_kern.c b/samples/bpf/test_overhead_raw_tp_kern.c new file mode 100644 index 000000000000..d2af8bc1c805 --- /dev/null +++ b/samples/bpf/test_overhead_raw_tp_kern.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2018 Facebook */ +#include +#include "bpf_helpers.h" + +SEC("raw_tracepoint/task_rename") +int prog(struct bpf_raw_tracepoint_args *ctx) +{ + return 0; +} + +SEC("raw_tracepoint/urandom_read") +int prog2(struct bpf_raw_tracepoint_args *ctx) +{ + return 0; +} +char _license[] SEC("license") = "GPL"; diff --git a/samples/bpf/test_overhead_user.c b/samples/bpf/test_overhead_user.c index d291167fd3c7..e1d35e07a10e 100644 --- a/samples/bpf/test_overhead_user.c +++ b/samples/bpf/test_overhead_user.c @@ -158,5 +158,17 @@ int main(int argc, char **argv) unload_progs(); } + if (test_flags & 0xC0) { + snprintf(filename, sizeof(filename), + "%s_raw_tp_kern.o", argv[0]); + if (load_bpf_file(filename)) { + printf("%s", bpf_log_buf); + return 1; + } + printf("w/RAW_TRACEPOINT\n"); + run_perf_test(num_cpu, test_flags >> 6); + unload_progs(); + } + return 0; } -- 2.9.5