Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/815292/?format=api
{ "id": 815292, "url": "http://patchwork.ozlabs.org/api/patches/815292/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170919070413.3838201-4-yhs@fb.com/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170919070413.3838201-4-yhs@fb.com>", "list_archive_url": null, "date": "2017-09-19T07:04:12", "name": "[net-next,v4,3/4] bpf: add helper bpf_perf_prog_read_value", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "2cb56296b4e07dbd191165ead90be43e4f9717ca", "submitter": { "id": 71628, "url": "http://patchwork.ozlabs.org/api/people/71628/?format=api", "name": "Yonghong Song", "email": "yhs@fb.com" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/20170919070413.3838201-4-yhs@fb.com/mbox/", "series": [ { "id": 3788, "url": "http://patchwork.ozlabs.org/api/series/3788/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=3788", "date": "2017-09-19T07:04:10", "name": "bpf: add two helpers to read perf event enabled/running time", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/3788/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/815292/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/815292/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=fb.com header.i=@fb.com header.b=\"EiY05e05\";\n\tdkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xxDQF28SRz9s7B\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 19 Sep 2017 17:04:37 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751488AbdISHEe (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 19 Sep 2017 03:04:34 -0400", "from mx0b-00082601.pphosted.com ([67.231.153.30]:43886 \"EHLO\n\tmx0b-00082601.pphosted.com\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S1751053AbdISHEQ (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Tue, 19 Sep 2017 03:04:16 -0400", "from pps.filterd (m0109332.ppops.net [127.0.0.1])\n\tby mx0a-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8J73lDd023951\n\tfor <netdev@vger.kernel.org>; Tue, 19 Sep 2017 00:04:15 -0700", "from mail.thefacebook.com ([199.201.64.23])\n\tby mx0a-00082601.pphosted.com with ESMTP id 2d2wjs06ke-3\n\t(version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT)\n\tfor <netdev@vger.kernel.org>; Tue, 19 Sep 2017 00:04:15 -0700", "from mx-out.facebook.com (192.168.52.123) by\n\tPRN-CHUB10.TheFacebook.com (192.168.16.20) with Microsoft SMTP Server\n\tid 14.3.319.2; Tue, 19 Sep 2017 00:04:14 -0700", "by devbig474.prn1.facebook.com (Postfix, from userid 128203) id\n\tC994B46E04A4; Tue, 19 Sep 2017 00:04:13 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com;\n\th=from : to : cc : subject\n\t: date : message-id : in-reply-to : references : mime-version :\n\tcontent-type; s=facebook;\n\tbh=2NAScVo5DpXk6k529FwkFbzEqfHr2ZOYiZgsByBy7IA=; \n\tb=EiY05e05e5HG0muQ5TT/dUYeF6ZUL6LE/LS2gvwdz2IKfu1ysr2UpiObVqVi+pR8h1Uz\n\tbvFRLg2iWFrcqOG63k+21qC+VwkUcT34VSmJBz0tmAw0HU63tfXwqB2oKPBy28Frjgld\n\tVAnKY4laI6UvlhUZruo4VFLV4TI4Pog2jg4= ", "Smtp-Origin-Hostprefix": "devbig", "From": "Yonghong Song <yhs@fb.com>", "Smtp-Origin-Hostname": "devbig474.prn1.facebook.com", "To": "<peterz@infradead.org>, <rostedt@goodmis.org>, <ast@fb.com>,\n\t<daniel@iogearbox.net>, <netdev@vger.kernel.org>", "CC": "<kernel-team@fb.com>", "Smtp-Origin-Cluster": "prn1c29", "Subject": "[PATCH net-next v4 3/4] bpf: add helper bpf_perf_prog_read_value", "Date": "Tue, 19 Sep 2017 00:04:12 -0700", "Message-ID": "<20170919070413.3838201-4-yhs@fb.com>", "X-Mailer": "git-send-email 2.9.5", "In-Reply-To": "<20170919070413.3838201-1-yhs@fb.com>", "References": "<20170919070413.3838201-1-yhs@fb.com>", "X-FB-Internal": [ "Safe", "Safe" ], "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Proofpoint-Spam-Reason": "safe", "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-19_04:, , signatures=0", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "This patch adds helper bpf_perf_prog_read_cvalue for perf event based bpf\nprograms, to read event counter and enabled/running time.\nThe enabled/running time is accumulated since the perf event open.\n\nThe typical use case for perf event based bpf program is to attach itself\nto a single event. In such cases, if it is desirable to get scaling factor\nbetween two bpf invocations, users can can save the time values in a map,\nand use the value from the map and the current value to calculate\nthe scaling factor.\n\nSigned-off-by: Yonghong Song <yhs@fb.com>\n---\n include/linux/perf_event.h | 1 +\n include/uapi/linux/bpf.h | 8 ++++++++\n kernel/events/core.c | 1 +\n kernel/trace/bpf_trace.c | 23 +++++++++++++++++++++++\n 4 files changed, 33 insertions(+)", "diff": "diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h\nindex 21d8c12..79b18a2 100644\n--- a/include/linux/perf_event.h\n+++ b/include/linux/perf_event.h\n@@ -806,6 +806,7 @@ struct perf_output_handle {\n struct bpf_perf_event_data_kern {\n \tstruct pt_regs *regs;\n \tstruct perf_sample_data *data;\n+\tstruct perf_event *event;\n };\n \n #ifdef CONFIG_CGROUP_PERF\ndiff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h\nindex 2c68b9e..ba77022 100644\n--- a/include/uapi/linux/bpf.h\n+++ b/include/uapi/linux/bpf.h\n@@ -590,6 +590,13 @@ union bpf_attr {\n * @buf: buf to fill\n * @buf_size: size of the buf\n * Return: 0 on success or negative error code\n+ *\n+ * int bpf_perf_prog_read_value(ctx, buf, buf_size)\n+ * read perf prog attached perf event counter and enabled/running time\n+ * @ctx: pointer to ctx\n+ * @buf: buf to fill\n+ * @buf_size: size of the buf\n+ * Return : 0 on success or negative error code\n */\n #define __BPF_FUNC_MAPPER(FN)\t\t\\\n \tFN(unspec),\t\t\t\\\n@@ -647,6 +654,7 @@ union bpf_attr {\n \tFN(sk_redirect_map),\t\t\\\n \tFN(sock_map_update),\t\t\\\n \tFN(perf_event_read_value),\t\t\\\n+\tFN(perf_prog_read_value),\t\t\\\n \n /* integer value in 'imm' field of BPF_CALL instruction selects which helper\n * function eBPF program intends to call\ndiff --git a/kernel/events/core.c b/kernel/events/core.c\nindex 2d5bbe5..d039086 100644\n--- a/kernel/events/core.c\n+++ b/kernel/events/core.c\n@@ -8081,6 +8081,7 @@ static void bpf_overflow_handler(struct perf_event *event,\n \tstruct bpf_perf_event_data_kern ctx = {\n \t\t.data = data,\n \t\t.regs = regs,\n+\t\t.event = event,\n \t};\n \tint ret = 0;\n \ndiff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c\nindex 39ce5d9..596b5c9 100644\n--- a/kernel/trace/bpf_trace.c\n+++ b/kernel/trace/bpf_trace.c\n@@ -603,6 +603,18 @@ BPF_CALL_3(bpf_get_stackid_tp, void *, tp_buff, struct bpf_map *, map,\n \t\t\t flags, 0, 0);\n }\n \n+BPF_CALL_3(bpf_perf_prog_read_value_tp, void *, ctx, struct bpf_perf_event_value *,\n+\tbuf, u32, size)\n+{\n+\tstruct bpf_perf_event_data_kern *kctx = (struct bpf_perf_event_data_kern *)ctx;\n+\n+\tif (size != sizeof(struct bpf_perf_event_value))\n+\t\treturn -EINVAL;\n+\n+\treturn perf_event_read_local(kctx->event, &buf->counter, &buf->enabled,\n+\t\t\t\t &buf->running);\n+}\n+\n static const struct bpf_func_proto bpf_get_stackid_proto_tp = {\n \t.func\t\t= bpf_get_stackid_tp,\n \t.gpl_only\t= true,\n@@ -612,6 +624,15 @@ static const struct bpf_func_proto bpf_get_stackid_proto_tp = {\n \t.arg3_type\t= ARG_ANYTHING,\n };\n \n+static const struct bpf_func_proto bpf_perf_prog_read_value_proto_tp = {\n+ .func = bpf_perf_prog_read_value_tp,\n+ .gpl_only = true,\n+ .ret_type = RET_INTEGER,\n+ .arg1_type = ARG_PTR_TO_CTX,\n+ .arg2_type = ARG_PTR_TO_UNINIT_MEM,\n+ .arg3_type = ARG_CONST_SIZE,\n+};\n+\n static const struct bpf_func_proto *tp_prog_func_proto(enum bpf_func_id func_id)\n {\n \tswitch (func_id) {\n@@ -619,6 +640,8 @@ static const struct bpf_func_proto *tp_prog_func_proto(enum bpf_func_id func_id)\n \t\treturn &bpf_perf_event_output_proto_tp;\n \tcase BPF_FUNC_get_stackid:\n \t\treturn &bpf_get_stackid_proto_tp;\n+\tcase BPF_FUNC_perf_prog_read_value:\n+\t\treturn &bpf_perf_prog_read_value_proto_tp;\n \tdefault:\n \t\treturn tracing_func_proto(func_id);\n \t}\n", "prefixes": [ "net-next", "v4", "3/4" ] }