get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/809044/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 809044,
    "url": "http://patchwork.ozlabs.org/api/patches/809044/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170902054824.371962-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": "<20170902054824.371962-4-yhs@fb.com>",
    "list_archive_url": null,
    "date": "2017-09-02T05:48:23",
    "name": "[v2,net-next,3/4] bpf: add helper bpf_perf_prog_read_time",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "11bd4ad0a45c8d0909e34936805401f2b8eda5fa",
    "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/20170902054824.371962-4-yhs@fb.com/mbox/",
    "series": [
        {
            "id": 1139,
            "url": "http://patchwork.ozlabs.org/api/series/1139/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=1139",
            "date": "2017-09-02T05:48:21",
            "name": "bpf: add two helpers to read perf event enabled/running time",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/1139/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/809044/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/809044/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=\"Azoin2EX\";\n\tdkim-atps=neutral"
        ],
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xklXb1yB7z9s78\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  2 Sep 2017 15:48:47 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751510AbdIBFs2 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSat, 2 Sep 2017 01:48:28 -0400",
            "from mx0a-00082601.pphosted.com ([67.231.145.42]:53450 \"EHLO\n\tmx0a-00082601.pphosted.com\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S1750980AbdIBFs0 (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Sat, 2 Sep 2017 01:48:26 -0400",
            "from pps.filterd (m0109333.ppops.net [127.0.0.1])\n\tby mx0a-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv82557Le018906\n\tfor <netdev@vger.kernel.org>; Fri, 1 Sep 2017 22:48:25 -0700",
            "from mail.thefacebook.com ([199.201.64.23])\n\tby mx0a-00082601.pphosted.com with ESMTP id 2cqkgd0bug-3\n\t(version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT)\n\tfor <netdev@vger.kernel.org>; Fri, 01 Sep 2017 22:48:25 -0700",
            "from mx-out.facebook.com (192.168.52.123) by\n\tPRN-CHUB14.TheFacebook.com (192.168.16.24) with Microsoft SMTP Server\n\tid 14.3.319.2; Fri, 1 Sep 2017 22:48:24 -0700",
            "by devbig474.prn1.facebook.com (Postfix, from userid 128203)  id\n\t9409246E0484; Fri,  1 Sep 2017 22:48:24 -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=l+tNk1f1Ygzd0dKIDR3HDN5nbi3pqn/1FZ2/cbMwGTY=; \n\tb=Azoin2EXLShLpxI3trd6K5M/cn/psWc3fxpg4ws5I4PcDKNjx9k48mFbkNcfEH18HDtP\n\tl5tUh7Mz0otPgbX86T2lewugMDE9yyqKYrPx+OFQCJnIzua34uQBr3/6HOddJUstxy++\n\twCE4nsjsJzOMzm6qxsv2zxq7LO7eMqVI5Vo= ",
        "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 v2 net-next 3/4] bpf: add helper bpf_perf_prog_read_time",
        "Date": "Fri, 1 Sep 2017 22:48:23 -0700",
        "Message-ID": "<20170902054824.371962-4-yhs@fb.com>",
        "X-Mailer": "git-send-email 2.9.5",
        "In-Reply-To": "<20170902054824.371962-1-yhs@fb.com>",
        "References": "<20170902054824.371962-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-02_01:, , 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   | 23 +++++++++++++++++++++++\n 4 files changed, 33 insertions(+)",
    "diff": "diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h\nindex 5a50808..6756ae7 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 20c4039..338f564 100644\n--- a/kernel/events/core.c\n+++ b/kernel/events/core.c\n@@ -8026,6 +8026,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 7ef953f..89b0744 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_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+\n+\tif (size != sizeof(struct bpf_perf_time))\n+\t\treturn -EINVAL;\n+\n+\treturn perf_event_read_local(kctx->event, NULL, &time_buf->enabled,\n+\t\t\t\t     &time_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_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@@ -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_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": [
        "v2",
        "net-next",
        "3/4"
    ]
}