get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 815204,
    "url": "http://patchwork.ozlabs.org/api/patches/815204/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170918230553.1624357-3-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": "<20170918230553.1624357-3-yhs@fb.com>",
    "list_archive_url": null,
    "date": "2017-09-18T23:05:51",
    "name": "[net-next,v3,2/4] bpf: add a test case for helper bpf_perf_event_read_value",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d3fa6de23a8586dd087611bf9031a735a71f75c5",
    "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/20170918230553.1624357-3-yhs@fb.com/mbox/",
    "series": [
        {
            "id": 3748,
            "url": "http://patchwork.ozlabs.org/api/series/3748/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=3748",
            "date": "2017-09-18T23:05:50",
            "name": "bpf: add two helpers to read perf event enabled/running time",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/3748/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/815204/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/815204/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=\"aZHK4vOD\";\n\tdkim-atps=neutral"
        ],
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xx1pK1wDrz9s2G\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 19 Sep 2017 09:06:17 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751408AbdIRXGF (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 18 Sep 2017 19:06:05 -0400",
            "from mx0b-00082601.pphosted.com ([67.231.153.30]:37430 \"EHLO\n\tmx0b-00082601.pphosted.com\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S1751283AbdIRXFz (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 18 Sep 2017 19:05:55 -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\tv8IN3fXa031772\n\tfor <netdev@vger.kernel.org>; Mon, 18 Sep 2017 16:05:54 -0700",
            "from mail.thefacebook.com ([199.201.64.23])\n\tby mx0a-00082601.pphosted.com with ESMTP id 2d2jfw1m8g-2\n\t(version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT)\n\tfor <netdev@vger.kernel.org>; Mon, 18 Sep 2017 16:05:54 -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; Mon, 18 Sep 2017 16:05:53 -0700",
            "by devbig474.prn1.facebook.com (Postfix, from userid 128203)  id\n\t345BA46E047A; Mon, 18 Sep 2017 16:05:53 -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=XLmfGm34mWTrARJNPF25EYo/YNZK0x3kAfZzghLxaJo=; \n\tb=aZHK4vOD9CrcEKZOsqrbJVjudqBjgp4sJqadK+NFitByu8L/kraxoEGkNCmxrwHa0VBg\n\tYcIdxIEok595oHBsQB3ruwNpB7pmqbMM77B0+rT60v06gs4bx+i8PjFbxd29msgjOb5G\n\tT8JWdEJCW39R1zhhJ+N34/R96Ad5049os1E= ",
        "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 v3 2/4] bpf: add a test case for helper\n\tbpf_perf_event_read_value",
        "Date": "Mon, 18 Sep 2017 16:05:51 -0700",
        "Message-ID": "<20170918230553.1624357-3-yhs@fb.com>",
        "X-Mailer": "git-send-email 2.9.5",
        "In-Reply-To": "<20170918230553.1624357-1-yhs@fb.com>",
        "References": "<20170918230553.1624357-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-18_11:, , signatures=0",
        "Sender": "netdev-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netdev.vger.kernel.org>",
        "X-Mailing-List": "netdev@vger.kernel.org"
    },
    "content": "The bpf sample program tracex6 is enhanced to use the new\nhelper to read enabled/running time as well.\n\nSigned-off-by: Yonghong Song <yhs@fb.com>\n---\n samples/bpf/tracex6_kern.c                | 26 ++++++++++++++++++++++++++\n samples/bpf/tracex6_user.c                | 13 ++++++++++++-\n tools/include/uapi/linux/bpf.h            |  3 ++-\n tools/testing/selftests/bpf/bpf_helpers.h |  3 +++\n 4 files changed, 43 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/samples/bpf/tracex6_kern.c b/samples/bpf/tracex6_kern.c\nindex e7d1803..46c557a 100644\n--- a/samples/bpf/tracex6_kern.c\n+++ b/samples/bpf/tracex6_kern.c\n@@ -15,6 +15,12 @@ struct bpf_map_def SEC(\"maps\") values = {\n \t.value_size = sizeof(u64),\n \t.max_entries = 64,\n };\n+struct bpf_map_def SEC(\"maps\") values2 = {\n+\t.type = BPF_MAP_TYPE_HASH,\n+\t.key_size = sizeof(int),\n+\t.value_size = sizeof(struct bpf_perf_event_value),\n+\t.max_entries = 64,\n+};\n \n SEC(\"kprobe/htab_map_get_next_key\")\n int bpf_prog1(struct pt_regs *ctx)\n@@ -37,5 +43,25 @@ int bpf_prog1(struct pt_regs *ctx)\n \treturn 0;\n }\n \n+SEC(\"kprobe/htab_map_lookup_elem\")\n+int bpf_prog2(struct pt_regs *ctx)\n+{\n+\tu32 key = bpf_get_smp_processor_id();\n+\tstruct bpf_perf_event_value *val, buf;\n+\tint error;\n+\n+\terror = bpf_perf_event_read_value(&counters, key, &buf, sizeof(buf));\n+\tif (error)\n+\t\treturn 0;\n+\n+\tval = bpf_map_lookup_elem(&values2, &key);\n+\tif (val)\n+\t\t*val = buf;\n+\telse\n+\t\tbpf_map_update_elem(&values2, &key, &buf, BPF_NOEXIST);\n+\n+\treturn 0;\n+}\n+\n char _license[] SEC(\"license\") = \"GPL\";\n u32 _version SEC(\"version\") = LINUX_VERSION_CODE;\ndiff --git a/samples/bpf/tracex6_user.c b/samples/bpf/tracex6_user.c\nindex a05a99a..3341a96 100644\n--- a/samples/bpf/tracex6_user.c\n+++ b/samples/bpf/tracex6_user.c\n@@ -22,6 +22,7 @@\n \n static void check_on_cpu(int cpu, struct perf_event_attr *attr)\n {\n+\tstruct bpf_perf_event_value value2;\n \tint pmu_fd, error = 0;\n \tcpu_set_t set;\n \t__u64 value;\n@@ -46,8 +47,18 @@ static void check_on_cpu(int cpu, struct perf_event_attr *attr)\n \t\tfprintf(stderr, \"Value missing for CPU %d\\n\", cpu);\n \t\terror = 1;\n \t\tgoto on_exit;\n+\t} else {\n+\t\tfprintf(stderr, \"CPU %d: %llu\\n\", cpu, value);\n+\t}\n+\t/* The above bpf_map_lookup_elem should trigger the second kprobe */\n+\tif (bpf_map_lookup_elem(map_fd[2], &cpu, &value2)) {\n+\t\tfprintf(stderr, \"Value2 missing for CPU %d\\n\", cpu);\n+\t\terror = 1;\n+\t\tgoto on_exit;\n+\t} else {\n+\t\tfprintf(stderr, \"CPU %d: counter: %llu, enabled: %llu, running: %llu\\n\", cpu,\n+\t\t\tvalue2.counter, value2.enabled, value2.running);\n \t}\n-\tfprintf(stderr, \"CPU %d: %llu\\n\", cpu, value);\n \n on_exit:\n \tassert(bpf_map_delete_elem(map_fd[0], &cpu) == 0 || error);\ndiff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h\nindex 461811e..79eb529 100644\n--- a/tools/include/uapi/linux/bpf.h\n+++ b/tools/include/uapi/linux/bpf.h\n@@ -632,7 +632,8 @@ union bpf_attr {\n \tFN(skb_adjust_room),\t\t\\\n \tFN(redirect_map),\t\t\\\n \tFN(sk_redirect_map),\t\t\\\n-\tFN(sock_map_update),\n+\tFN(sock_map_update),\t\t\\\n+\tFN(perf_event_read_value),\n \n /* integer value in 'imm' field of BPF_CALL instruction selects which helper\n  * function eBPF program intends to call\ndiff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h\nindex 36fb916..c866682 100644\n--- a/tools/testing/selftests/bpf/bpf_helpers.h\n+++ b/tools/testing/selftests/bpf/bpf_helpers.h\n@@ -70,6 +70,9 @@ static int (*bpf_sk_redirect_map)(void *map, int key, int flags) =\n static int (*bpf_sock_map_update)(void *map, void *key, void *value,\n \t\t\t\t  unsigned long long flags) =\n \t(void *) BPF_FUNC_sock_map_update;\n+static int (*bpf_perf_event_read_value)(void *map, unsigned long long flags,\n+\t\t\t\t       void *buf, unsigned int buf_size) =\n+\t(void *) BPF_FUNC_perf_event_read_value;\n \n \n /* llvm builtin functions that eBPF C program may use to\n",
    "prefixes": [
        "net-next",
        "v3",
        "2/4"
    ]
}