get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 808535,
    "url": "http://patchwork.ozlabs.org/api/patches/808535/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170901062713.1842249-2-kafai@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": "<20170901062713.1842249-2-kafai@fb.com>",
    "list_archive_url": null,
    "date": "2017-09-01T06:27:11",
    "name": "[net-next,1/3] bpf: Add lru_hash_lookup performance test",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "dc8ea49df3aa961a2c0ee4c32b0aef396364bfce",
    "submitter": {
        "id": 64907,
        "url": "http://patchwork.ozlabs.org/api/people/64907/?format=api",
        "name": "Martin KaFai Lau",
        "email": "kafai@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/20170901062713.1842249-2-kafai@fb.com/mbox/",
    "series": [
        {
            "id": 953,
            "url": "http://patchwork.ozlabs.org/api/series/953/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=953",
            "date": "2017-09-01T06:27:10",
            "name": "bpf: Improve LRU map lookup performance",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/953/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/808535/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/808535/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=\"U02+gNBZ\";\n\tdkim-atps=neutral"
        ],
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xk8Rk6d2Yz9s72\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri,  1 Sep 2017 16:27:30 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751443AbdIAG12 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 1 Sep 2017 02:27:28 -0400",
            "from mx0b-00082601.pphosted.com ([67.231.153.30]:35261 \"EHLO\n\tmx0a-00082601.pphosted.com\" rhost-flags-OK-OK-OK-FAIL)\n\tby vger.kernel.org with ESMTP id S1751250AbdIAG1P (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Fri, 1 Sep 2017 02:27:15 -0400",
            "from pps.filterd (m0089730.ppops.net [127.0.0.1])\n\tby m0089730.ppops.net (8.16.0.21/8.16.0.21) with SMTP id\n\tv816NdwK013558\n\tfor <netdev@vger.kernel.org>; Thu, 31 Aug 2017 23:27:15 -0700",
            "from mail.thefacebook.com ([199.201.64.23])\n\tby m0089730.ppops.net with ESMTP id 2cq1810a2d-1\n\t(version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT)\n\tfor <netdev@vger.kernel.org>; Thu, 31 Aug 2017 23:27:15 -0700",
            "from mx-out.facebook.com (192.168.52.123) by\n\tPRN-CHUB06.TheFacebook.com (192.168.16.16) with Microsoft SMTP Server\n\tid 14.3.319.2; Thu, 31 Aug 2017 23:27:13 -0700",
            "by devbig738.prn1.facebook.com (Postfix, from userid 6611)    id\n\tADB2C45005A9; Thu, 31 Aug 2017 23:27: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=TNXHvWnrx/z+GcSMuKJ+/or3C708LitpC0DdiYNXQaA=; \n\tb=U02+gNBZHjTo3M+ClPG2Qh/ziIkrqdbnGjkBNImRSD9WvgglSpc1ZQnymHtN9O/CWROz\n\tgs9IJ+meVUEWLrf/jE1MZhQdvO0cE78C1Pjm6haY9rMuGFouoUwZwmy8/IBSZmtkw7am\n\taRW75ITG0UiO38mO3bQqEL3Z2ccgpFBnT2k= ",
        "X-ThriftRelayHost": "devbig738.prn1.facebook.com",
        "Smtp-Origin-Hostprefix": "devbig",
        "From": "Martin KaFai Lau <kafai@fb.com>",
        "Smtp-Origin-Hostname": "devbig738.prn1.facebook.com",
        "To": "<netdev@vger.kernel.org>",
        "CC": "Alexei Starovoitov <ast@fb.com>,\n\tDaniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>",
        "Smtp-Origin-Cluster": "prn1c29",
        "Subject": "[PATCH net-next 1/3] bpf: Add lru_hash_lookup performance test",
        "Date": "Thu, 31 Aug 2017 23:27:11 -0700",
        "Message-ID": "<20170901062713.1842249-2-kafai@fb.com>",
        "X-Mailer": "git-send-email 2.9.5",
        "In-Reply-To": "<20170901062713.1842249-1-kafai@fb.com>",
        "References": "<20170901062713.1842249-1-kafai@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_02:, , signatures=0",
        "Sender": "netdev-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netdev.vger.kernel.org>",
        "X-Mailing-List": "netdev@vger.kernel.org"
    },
    "content": "Create a new case to test the LRU lookup performance.\n\nAt the beginning, the LRU map is fully loaded (i.e. the number of keys\nis equal to map->max_entries).   The lookup is done through key 0\nto num_map_entries and then repeats from 0 again.\n\nThis patch also creates an anonymous struct to properly\nname the test params in stress_lru_hmap_alloc() in map_perf_test_kern.c.\n\nSigned-off-by: Martin KaFai Lau <kafai@fb.com>\n---\n samples/bpf/map_perf_test_kern.c | 44 +++++++++++++++++++----\n samples/bpf/map_perf_test_user.c | 77 ++++++++++++++++++++++++++++++++++++++--\n 2 files changed, 112 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/samples/bpf/map_perf_test_kern.c b/samples/bpf/map_perf_test_kern.c\nindex ca3b22ed577a..098c857f1eda 100644\n--- a/samples/bpf/map_perf_test_kern.c\n+++ b/samples/bpf/map_perf_test_kern.c\n@@ -88,6 +88,13 @@ struct bpf_map_def SEC(\"maps\") array_map = {\n \t.max_entries = MAX_ENTRIES,\n };\n \n+struct bpf_map_def SEC(\"maps\") lru_hash_lookup_map = {\n+\t.type = BPF_MAP_TYPE_LRU_HASH,\n+\t.key_size = sizeof(u32),\n+\t.value_size = sizeof(long),\n+\t.max_entries = MAX_ENTRIES,\n+};\n+\n SEC(\"kprobe/sys_getuid\")\n int stress_hmap(struct pt_regs *ctx)\n {\n@@ -148,12 +155,23 @@ int stress_percpu_hmap_alloc(struct pt_regs *ctx)\n SEC(\"kprobe/sys_connect\")\n int stress_lru_hmap_alloc(struct pt_regs *ctx)\n {\n+\tchar fmt[] = \"Failed at stress_lru_hmap_alloc. ret:%dn\";\n+\tunion {\n+\t\tu16 dst6[8];\n+\t\tstruct {\n+\t\t\tu16 magic0;\n+\t\t\tu16 magic1;\n+\t\t\tu16 tcase;\n+\t\t\tu16 unused16;\n+\t\t\tu32 unused32;\n+\t\t\tu32 key;\n+\t\t};\n+\t} test_params;\n \tstruct sockaddr_in6 *in6;\n-\tu16 test_case, dst6[8];\n+\tu16 test_case;\n \tint addrlen, ret;\n-\tchar fmt[] = \"Failed at stress_lru_hmap_alloc. ret:%d\\n\";\n \tlong val = 1;\n-\tu32 key = bpf_get_prandom_u32();\n+\tu32 key = 0;\n \n \tin6 = (struct sockaddr_in6 *)PT_REGS_PARM2(ctx);\n \taddrlen = (int)PT_REGS_PARM3(ctx);\n@@ -161,14 +179,18 @@ int stress_lru_hmap_alloc(struct pt_regs *ctx)\n \tif (addrlen != sizeof(*in6))\n \t\treturn 0;\n \n-\tret = bpf_probe_read(dst6, sizeof(dst6), &in6->sin6_addr);\n+\tret = bpf_probe_read(test_params.dst6, sizeof(test_params.dst6),\n+\t\t\t     &in6->sin6_addr);\n \tif (ret)\n \t\tgoto done;\n \n-\tif (dst6[0] != 0xdead || dst6[1] != 0xbeef)\n+\tif (test_params.magic0 != 0xdead ||\n+\t    test_params.magic1 != 0xbeef)\n \t\treturn 0;\n \n-\ttest_case = dst6[7];\n+\ttest_case = test_params.tcase;\n+\tif (test_case != 3)\n+\t\tkey = bpf_get_prandom_u32();\n \n \tif (test_case == 0) {\n \t\tret = bpf_map_update_elem(&lru_hash_map, &key, &val, BPF_ANY);\n@@ -188,6 +210,16 @@ int stress_lru_hmap_alloc(struct pt_regs *ctx)\n \n \t\tret = bpf_map_update_elem(nolocal_lru_map, &key, &val,\n \t\t\t\t\t  BPF_ANY);\n+\t} else if (test_case == 3) {\n+\t\tu32 i;\n+\n+\t\tkey = test_params.key;\n+\n+#pragma clang loop unroll(full)\n+\t\tfor (i = 0; i < 32; i++) {\n+\t\t\tbpf_map_lookup_elem(&lru_hash_lookup_map, &key);\n+\t\t\tkey++;\n+\t\t}\n \t} else {\n \t\tret = -EINVAL;\n \t}\ndiff --git a/samples/bpf/map_perf_test_user.c b/samples/bpf/map_perf_test_user.c\nindex bccbf8478e43..f388254896f6 100644\n--- a/samples/bpf/map_perf_test_user.c\n+++ b/samples/bpf/map_perf_test_user.c\n@@ -46,6 +46,7 @@ enum test_type {\n \tHASH_LOOKUP,\n \tARRAY_LOOKUP,\n \tINNER_LRU_HASH_PREALLOC,\n+\tLRU_HASH_LOOKUP,\n \tNR_TESTS,\n };\n \n@@ -60,6 +61,7 @@ const char *test_map_names[NR_TESTS] = {\n \t[HASH_LOOKUP] = \"hash_map\",\n \t[ARRAY_LOOKUP] = \"array_map\",\n \t[INNER_LRU_HASH_PREALLOC] = \"inner_lru_hash_map\",\n+\t[LRU_HASH_LOOKUP] = \"lru_hash_lookup_map\",\n };\n \n static int test_flags = ~0;\n@@ -67,6 +69,8 @@ static uint32_t num_map_entries;\n static uint32_t inner_lru_hash_size;\n static int inner_lru_hash_idx = -1;\n static int array_of_lru_hashs_idx = -1;\n+static int lru_hash_lookup_idx = -1;\n+static int lru_hash_lookup_test_entries = 32;\n static uint32_t max_cnt = 1000000;\n \n static int check_test_flags(enum test_type t)\n@@ -86,6 +90,32 @@ static void test_hash_prealloc(int cpu)\n \t       cpu, max_cnt * 1000000000ll / (time_get_ns() - start_time));\n }\n \n+static int pre_test_lru_hash_lookup(int tasks)\n+{\n+\tint fd = map_fd[lru_hash_lookup_idx];\n+\tuint32_t key;\n+\tlong val = 1;\n+\tint ret;\n+\n+\tif (num_map_entries > lru_hash_lookup_test_entries)\n+\t\tlru_hash_lookup_test_entries = num_map_entries;\n+\n+\t/* Populate the lru_hash_map for LRU_HASH_LOOKUP perf test.\n+\t *\n+\t * It is fine that the user requests for a map with\n+\t * num_map_entries < 32 and some of the later lru hash lookup\n+\t * may return not found.  For LRU map, we are not interested\n+\t * in such small map performance.\n+\t */\n+\tfor (key = 0; key < lru_hash_lookup_test_entries; key++) {\n+\t\tret = bpf_map_update_elem(fd, &key, &val, BPF_NOEXIST);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static void do_test_lru(enum test_type test, int cpu)\n {\n \tstatic int inner_lru_map_fds[MAX_NR_CPUS];\n@@ -135,13 +165,17 @@ static void do_test_lru(enum test_type test, int cpu)\n \n \tif (test == LRU_HASH_PREALLOC) {\n \t\ttest_name = \"lru_hash_map_perf\";\n-\t\tin6.sin6_addr.s6_addr16[7] = 0;\n+\t\tin6.sin6_addr.s6_addr16[2] = 0;\n \t} else if (test == NOCOMMON_LRU_HASH_PREALLOC) {\n \t\ttest_name = \"nocommon_lru_hash_map_perf\";\n-\t\tin6.sin6_addr.s6_addr16[7] = 1;\n+\t\tin6.sin6_addr.s6_addr16[2] = 1;\n \t} else if (test == INNER_LRU_HASH_PREALLOC) {\n \t\ttest_name = \"inner_lru_hash_map_perf\";\n-\t\tin6.sin6_addr.s6_addr16[7] = 2;\n+\t\tin6.sin6_addr.s6_addr16[2] = 2;\n+\t} else if (test == LRU_HASH_LOOKUP) {\n+\t\ttest_name = \"lru_hash_lookup_perf\";\n+\t\tin6.sin6_addr.s6_addr16[2] = 3;\n+\t\tin6.sin6_addr.s6_addr32[3] = 0;\n \t} else {\n \t\tassert(0);\n \t}\n@@ -150,6 +184,11 @@ static void do_test_lru(enum test_type test, int cpu)\n \tfor (i = 0; i < max_cnt; i++) {\n \t\tret = connect(-1, (const struct sockaddr *)&in6, sizeof(in6));\n \t\tassert(ret == -1 && errno == EBADF);\n+\t\tif (in6.sin6_addr.s6_addr32[3] <\n+\t\t    lru_hash_lookup_test_entries - 32)\n+\t\t\tin6.sin6_addr.s6_addr32[3] += 32;\n+\t\telse\n+\t\t\tin6.sin6_addr.s6_addr32[3] = 0;\n \t}\n \tprintf(\"%d:%s pre-alloc %lld events per sec\\n\",\n \t       cpu, test_name,\n@@ -171,6 +210,11 @@ static void test_inner_lru_hash_prealloc(int cpu)\n \tdo_test_lru(INNER_LRU_HASH_PREALLOC, cpu);\n }\n \n+static void test_lru_hash_lookup(int cpu)\n+{\n+\tdo_test_lru(LRU_HASH_LOOKUP, cpu);\n+}\n+\n static void test_percpu_hash_prealloc(int cpu)\n {\n \t__u64 start_time;\n@@ -243,6 +287,11 @@ static void test_array_lookup(int cpu)\n \t       cpu, max_cnt * 1000000000ll * 64 / (time_get_ns() - start_time));\n }\n \n+typedef int (*pre_test_func)(int tasks);\n+const pre_test_func pre_test_funcs[] = {\n+\t[LRU_HASH_LOOKUP] = pre_test_lru_hash_lookup,\n+};\n+\n typedef void (*test_func)(int cpu);\n const test_func test_funcs[] = {\n \t[HASH_PREALLOC] = test_hash_prealloc,\n@@ -255,8 +304,25 @@ const test_func test_funcs[] = {\n \t[HASH_LOOKUP] = test_hash_lookup,\n \t[ARRAY_LOOKUP] = test_array_lookup,\n \t[INNER_LRU_HASH_PREALLOC] = test_inner_lru_hash_prealloc,\n+\t[LRU_HASH_LOOKUP] = test_lru_hash_lookup,\n };\n \n+static int pre_test(int tasks)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < NR_TESTS; i++) {\n+\t\tif (pre_test_funcs[i] && check_test_flags(i)) {\n+\t\t\tint ret = pre_test_funcs[i](tasks);\n+\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n static void loop(int cpu)\n {\n \tcpu_set_t cpuset;\n@@ -277,6 +343,8 @@ static void run_perf_test(int tasks)\n \tpid_t pid[tasks];\n \tint i;\n \n+\tassert(!pre_test(tasks));\n+\n \tfor (i = 0; i < tasks; i++) {\n \t\tpid[i] = fork();\n \t\tif (pid[i] == 0) {\n@@ -344,6 +412,9 @@ static void fixup_map(struct bpf_map_data *map, int idx)\n \t\tarray_of_lru_hashs_idx = idx;\n \t}\n \n+\tif (!strcmp(\"lru_hash_lookup_map\", map->name))\n+\t\tlru_hash_lookup_idx = idx;\n+\n \tif (num_map_entries <= 0)\n \t\treturn;\n \n",
    "prefixes": [
        "net-next",
        "1/3"
    ]
}