Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/808826/?format=api
{ "id": 808826, "url": "http://patchwork.ozlabs.org/api/patches/808826/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170901165357.465121-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": "<20170901165357.465121-4-yhs@fb.com>", "list_archive_url": null, "date": "2017-09-01T16:53:56", "name": "[net-next,3/4] bpf: add helper bpf_perf_prog_read_time", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "189ba370845056c4aaff74fb904979c917ae7806", "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/20170901165357.465121-4-yhs@fb.com/mbox/", "series": [ { "id": 1077, "url": "http://patchwork.ozlabs.org/api/series/1077/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=1077", "date": "2017-09-01T16:53:53", "name": "bpf: add two helpers to read perf event enabled/running time", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/1077/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/808826/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/808826/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=\"Mn5hL7QU\";\n\tdkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xkQLr1p24z9t2x\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 2 Sep 2017 02:54:12 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752347AbdIAQyG (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 1 Sep 2017 12:54:06 -0400", "from mx0a-00082601.pphosted.com ([67.231.145.42]:54168 \"EHLO\n\tmx0a-00082601.pphosted.com\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S1752302AbdIAQyA (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Fri, 1 Sep 2017 12:54:00 -0400", "from pps.filterd (m0044008.ppops.net [127.0.0.1])\n\tby mx0a-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv81GnENU014110\n\tfor <netdev@vger.kernel.org>; Fri, 1 Sep 2017 09:54:00 -0700", "from mail.thefacebook.com ([199.201.64.23])\n\tby mx0a-00082601.pphosted.com with ESMTP id 2cqabj0c2t-2\n\t(version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT)\n\tfor <netdev@vger.kernel.org>; Fri, 01 Sep 2017 09:53:59 -0700", "from mx-out.facebook.com (192.168.52.123) by\n\tPRN-CHUB07.TheFacebook.com (192.168.16.17) with Microsoft SMTP Server\n\tid 14.3.319.2; Fri, 1 Sep 2017 09:53:58 -0700", "by devbig474.prn1.facebook.com (Postfix, from userid 128203) id\n\t0822646E02C5; Fri, 1 Sep 2017 09:53:57 -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=rF38j4qYHeNGFH+x4/sGhbVRApT+QYzBJDSC2h8CObg=; \n\tb=Mn5hL7QUFQ1fmpPPsLwV4zSA4Slw8uH59b+JqL7JZ7rTQEfgQJBHa78rTZjplkZ1MZue\n\taB84Xyaqu3OEascyEyXLkv+BaEeAS2yMClfSp+mWvs1iykN7ertPSFga0rQHMHZGG2N/\n\t9J7V/1/ODtrQ83oXveX9MjxBA1GrL9xrwOk= ", "X-ThriftRelayHost": "devbig474.prn1.facebook.com", "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 3/4] bpf: add helper bpf_perf_prog_read_time", "Date": "Fri, 1 Sep 2017 09:53:56 -0700", "Message-ID": "<20170901165357.465121-4-yhs@fb.com>", "X-Mailer": "git-send-email 2.9.5", "In-Reply-To": "<20170901165357.465121-1-yhs@fb.com>", "References": "<20170901165357.465121-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-01_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_time for perf event based bpf\nprograms, to read event 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 | 24 ++++++++++++++++++++++++\n 4 files changed, 34 insertions(+)", "diff": "diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h\nindex 7fd5e94..92955fc 100644\n--- a/include/linux/perf_event.h\n+++ b/include/linux/perf_event.h\n@@ -821,6 +821,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 9c23bef..1ae55c8 100644\n--- a/include/uapi/linux/bpf.h\n+++ b/include/uapi/linux/bpf.h\n@@ -590,6 +590,13 @@ union bpf_attr {\n * @counter_time_buf: buf to fill\n * @buf_size: size of the counter_time_buf\n * Return: 0 on success or negative error code\n+ *\n+ * int bpf_perf_prog_read_time(ctx, time_buf, buf_size)\n+ * Read perf event enabled and running time\n+ * @ctx: pointer to ctx\n+ * @time_buf: buf to fill\n+ * @buf_size: size of the time_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_read_counter_time),\t\t\\\n+\tFN(perf_prog_read_time),\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 ef5c7fb..1f16f1f 100644\n--- a/kernel/events/core.c\n+++ b/kernel/events/core.c\n@@ -8019,6 +8019,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 b807b1a..e97620a 100644\n--- a/kernel/trace/bpf_trace.c\n+++ b/kernel/trace/bpf_trace.c\n@@ -608,6 +608,19 @@ 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_time_tp, void *, ctx, struct bpf_perf_time *,\n+\ttime_buf, u32, size)\n+{\n+\tstruct bpf_perf_event_data_kern *kctx = (struct bpf_perf_event_data_kern *)ctx;\n+\tu64 now;\n+\n+\tif (size != sizeof(struct bpf_perf_time))\n+\t\treturn -EINVAL;\n+\n+\tcalc_timer_values(kctx->event, &now, &time_buf->enabled, &time_buf->running);\n+\treturn 0;\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@@ -617,6 +630,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_time_proto_tp = {\n+ .func = bpf_perf_prog_read_time_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@@ -624,6 +646,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_time:\n+\t\treturn &bpf_perf_prog_read_time_proto_tp;\n \tdefault:\n \t\treturn tracing_func_proto(func_id);\n \t}\n", "prefixes": [ "net-next", "3/4" ] }