From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760275AbdEVWsu (ORCPT ); Mon, 22 May 2017 18:48:50 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:42744 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752267AbdEVWsn (ORCPT ); Mon, 22 May 2017 18:48:43 -0400 Smtp-Origin-Hostprefix: devbig From: Alexei Starovoitov Smtp-Origin-Hostname: devbig500.prn1.facebook.com To: "David S . Miller" CC: Peter Zijlstra , Brendan Gregg , Daniel Borkmann , Teng Qin , , , Smtp-Origin-Cluster: prn1c29 Subject: [PATCH net-next 1/2] perf, bpf: add support for HW_CACHE and RAW events Date: Mon, 22 May 2017 15:48:39 -0700 Message-ID: <20170522224840.810121-2-ast@fb.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170522224840.810121-1-ast@fb.com> References: <20170522224840.810121-1-ast@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-05-22_11:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Teng Qin This commit adds support for attach BPF program to RAW and HW_CACHE type events, and support for read HW_CACHE type event counters in BPF program. Existing code logic already supports them, so this commit is just update Enum value checks. Signed-off-by: Teng Qin Signed-off-by: Alexei Starovoitov Acked-by: Daniel Borkmann --- kernel/bpf/arraymap.c | 1 + kernel/events/core.c | 4 +++- kernel/trace/bpf_trace.c | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index 5e00b2333c26..f32affe8c335 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -473,6 +473,7 @@ static void *perf_event_fd_array_get_ptr(struct bpf_map *map, goto err_out; /* fall-through */ case PERF_TYPE_RAW: + case PERF_TYPE_HW_CACHE: case PERF_TYPE_HARDWARE: ee = bpf_event_entry_gen(perf_file, map_file); if (ee) diff --git a/kernel/events/core.c b/kernel/events/core.c index 6e75a5c9412d..1b68cb751c03 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -8038,7 +8038,9 @@ static int perf_event_set_bpf_prog(struct perf_event *event, u32 prog_fd) struct bpf_prog *prog; if (event->attr.type == PERF_TYPE_HARDWARE || - event->attr.type == PERF_TYPE_SOFTWARE) + event->attr.type == PERF_TYPE_SOFTWARE || + event->attr.type == PERF_TYPE_HW_CACHE || + event->attr.type == PERF_TYPE_RAW) return perf_event_set_bpf_handler(event, prog_fd); if (event->attr.type != PERF_TYPE_TRACEPOINT) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 460a031c77e5..5cbda7962a32 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -249,6 +249,7 @@ BPF_CALL_2(bpf_perf_event_read, struct bpf_map *, map, u64, flags) event = ee->event; if (unlikely(event->attr.type != PERF_TYPE_HARDWARE && + event->attr.type != PERF_TYPE_HW_CACHE && event->attr.type != PERF_TYPE_RAW)) return -EINVAL; -- 2.9.3