Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/815176/?format=api
{ "id": 815176, "url": "http://patchwork.ozlabs.org/api/patches/815176/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170918210711.10202-5-fw@strlen.de/", "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": "<20170918210711.10202-5-fw@strlen.de>", "list_archive_url": null, "date": "2017-09-18T21:07:11", "name": "[net-next,4/4] test_rhashtable: add test case for rhl_table interface", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "1a1bb4d4d8d6b835961407137f3b3dbdb056821d", "submitter": { "id": 1025, "url": "http://patchwork.ozlabs.org/api/people/1025/?format=api", "name": "Florian Westphal", "email": "fw@strlen.de" }, "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/20170918210711.10202-5-fw@strlen.de/mbox/", "series": [ { "id": 3736, "url": "http://patchwork.ozlabs.org/api/series/3736/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=3736", "date": "2017-09-18T21:07:07", "name": "test_rhashtable: add test case for rhl table", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/3736/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/815176/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/815176/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>)", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwz8w2Lzhz9s7m\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 19 Sep 2017 07:07:12 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751476AbdIRVHK (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 18 Sep 2017 17:07:10 -0400", "from Chamillionaire.breakpoint.cc ([146.0.238.67]:51764 \"EHLO\n\tChamillionaire.breakpoint.cc\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S1750972AbdIRVHH (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 18 Sep 2017 17:07:07 -0400", "from fw by Chamillionaire.breakpoint.cc with local (Exim 4.84_2)\n\t(envelope-from <fw@breakpoint.cc>)\n\tid 1du3Cp-0008CJ-Nv; Mon, 18 Sep 2017 23:03:51 +0200" ], "From": "Florian Westphal <fw@strlen.de>", "To": "<netdev@vger.kernel.org>", "Cc": "Florian Westphal <fw@strlen.de>", "Subject": "[PATCH net-next 4/4] test_rhashtable: add test case for rhl_table\n\tinterface", "Date": "Mon, 18 Sep 2017 23:07:11 +0200", "Message-Id": "<20170918210711.10202-5-fw@strlen.de>", "X-Mailer": "git-send-email 2.13.5", "In-Reply-To": "<20170918210711.10202-1-fw@strlen.de>", "References": "<20170918210711.10202-1-fw@strlen.de>", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "also test rhltable. rhltable remove operations are slow as\ndeletions require a list walk, thus test with 1/16th of the given\nentry count number to get a run duration similar to rhashtable one.\n\nSigned-off-by: Florian Westphal <fw@strlen.de>\n---\n lib/test_rhashtable.c | 196 +++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 194 insertions(+), 2 deletions(-)", "diff": "diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c\nindex 1eee90e6e394..b40b2880403e 100644\n--- a/lib/test_rhashtable.c\n+++ b/lib/test_rhashtable.c\n@@ -23,6 +23,7 @@\n #include <linux/semaphore.h>\n #include <linux/slab.h>\n #include <linux/sched.h>\n+#include <linux/random.h>\n #include <linux/vmalloc.h>\n \n #define MAX_ENTRIES\t1000000\n@@ -66,6 +67,11 @@ struct test_obj {\n \tstruct rhash_head\tnode;\n };\n \n+struct test_obj_rhl {\n+\tstruct test_obj_val\tvalue;\n+\tstruct rhlist_head\tlist_node;\n+};\n+\n struct thread_data {\n \tunsigned int entries;\n \tint id;\n@@ -246,6 +252,186 @@ static s64 __init test_rhashtable(struct rhashtable *ht, struct test_obj *array,\n \n static struct rhashtable ht;\n \n+static int __init test_rhltable(unsigned int entries)\n+{\n+\tstruct test_obj_rhl *rhl_test_objects;\n+\tunsigned long *obj_in_table;\n+\tstruct rhltable rhlt;\n+\tunsigned int i, j, k;\n+\tint ret, err;\n+\n+\tif (entries == 0)\n+\t\tentries = 1;\n+\n+\trhl_test_objects = vzalloc(sizeof(*rhl_test_objects) * entries);\n+\tif (!rhl_test_objects)\n+\t\treturn -ENOMEM;\n+\n+\tret = -ENOMEM;\n+\tobj_in_table = vzalloc(BITS_TO_LONGS(entries) * sizeof(unsigned long));\n+\tif (!obj_in_table)\n+\t\tgoto out_free;\n+\n+\t/* nulls_base not supported in rhlist interface */\n+\ttest_rht_params.nulls_base = 0;\n+\terr = rhltable_init(&rhlt, &test_rht_params);\n+\tif (WARN_ON(err))\n+\t\tgoto out_free;\n+\n+\tk = prandom_u32();\n+\tret = 0;\n+\tfor (i = 0; i < entries; i++) {\n+\t\trhl_test_objects[i].value.id = k;\n+\t\terr = rhltable_insert(&rhlt, &rhl_test_objects[i].list_node,\n+\t\t\t\t test_rht_params);\n+\t\tif (WARN(err, \"error %d on element %d\\n\", err, i))\n+\t\t\tbreak;\n+\t\tif (err == 0)\n+\t\t\tset_bit(i, obj_in_table);\n+\t}\n+\n+\tif (err)\n+\t\tret = err;\n+\n+\tpr_info(\"test %d add/delete pairs into rhlist\\n\", entries);\n+\tfor (i = 0; i < entries; i++) {\n+\t\tstruct rhlist_head *h, *pos;\n+\t\tstruct test_obj_rhl *obj;\n+\t\tstruct test_obj_val key = {\n+\t\t\t.id = k,\n+\t\t};\n+\t\tbool found;\n+\n+\t\trcu_read_lock();\n+\t\th = rhltable_lookup(&rhlt, &key, test_rht_params);\n+\t\tif (WARN(!h, \"key not found during iteration %d of %d\", i, entries)) {\n+\t\t\trcu_read_unlock();\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (i) {\n+\t\t\tj = i - 1;\n+\t\t\trhl_for_each_entry_rcu(obj, pos, h, list_node) {\n+\t\t\t\tif (WARN(pos == &rhl_test_objects[j].list_node, \"old element found, should be gone\"))\n+\t\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tcond_resched_rcu();\n+\n+\t\tfound = false;\n+\n+\t\trhl_for_each_entry_rcu(obj, pos, h, list_node) {\n+\t\t\tif (pos == &rhl_test_objects[i].list_node) {\n+\t\t\t\tfound = true;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\trcu_read_unlock();\n+\n+\t\tif (WARN(!found, \"element %d not found\", i))\n+\t\t\tbreak;\n+\n+\t\terr = rhltable_remove(&rhlt, &rhl_test_objects[i].list_node, test_rht_params);\n+\t\tWARN(err, \"rhltable_remove: err %d for iteration %d\\n\", err, i);\n+\t\tif (err == 0)\n+\t\t\tclear_bit(i, obj_in_table);\n+\t}\n+\n+\tif (ret == 0 && err)\n+\t\tret = err;\n+\n+\tfor (i = 0; i < entries; i++) {\n+\t\tWARN(test_bit(i, obj_in_table), \"elem %d allegedly still present\", i);\n+\n+\t\terr = rhltable_insert(&rhlt, &rhl_test_objects[i].list_node,\n+\t\t\t\t test_rht_params);\n+\t\tif (WARN(err, \"error %d on element %d\\n\", err, i))\n+\t\t\tbreak;\n+\t\tif (err == 0)\n+\t\t\tset_bit(i, obj_in_table);\n+\t}\n+\n+\tpr_info(\"test %d random rhlist add/delete operations\\n\", entries);\n+\tfor (j = 0; j < entries; j++) {\n+\t\tu32 i = prandom_u32_max(entries);\n+\t\tu32 prand = prandom_u32();\n+\n+\t\tcond_resched();\n+\n+\t\tif (prand == 0)\n+\t\t\tprand = prandom_u32();\n+\n+\t\tif (prand & 1) {\n+\t\t\tprand >>= 1;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\terr = rhltable_remove(&rhlt, &rhl_test_objects[i].list_node, test_rht_params);\n+\t\tif (test_bit(i, obj_in_table)) {\n+\t\t\tclear_bit(i, obj_in_table);\n+\t\t\tif (WARN(err, \"cannot remove element at slot %d\", i))\n+\t\t\t\tcontinue;\n+\t\t} else {\n+\t\t\tif (WARN(err != -ENOENT, \"removed non-existant element %d, error %d not %d\",\n+\t\t\t i, err, -ENOENT))\n+\t\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (prand & 1) {\n+\t\t\tprand >>= 1;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\terr = rhltable_insert(&rhlt, &rhl_test_objects[i].list_node, test_rht_params);\n+\t\tif (err == 0) {\n+\t\t\tif (WARN(test_and_set_bit(i, obj_in_table), \"succeeded to insert same object %d\", i))\n+\t\t\t\tcontinue;\n+\t\t} else {\n+\t\t\tif (WARN(!test_bit(i, obj_in_table), \"failed to insert object %d\", i))\n+\t\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (prand & 1) {\n+\t\t\tprand >>= 1;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\ti = prandom_u32_max(entries);\n+\t\tif (test_bit(i, obj_in_table)) {\n+\t\t\terr = rhltable_remove(&rhlt, &rhl_test_objects[i].list_node, test_rht_params);\n+\t\t\tWARN(err, \"cannot remove element at slot %d\", i);\n+\t\t\tif (err == 0)\n+\t\t\t\tclear_bit(i, obj_in_table);\n+\t\t} else {\n+\t\t\terr = rhltable_insert(&rhlt, &rhl_test_objects[i].list_node, test_rht_params);\n+\t\t\tWARN(err, \"failed to insert object %d\", i);\n+\t\t\tif (err == 0)\n+\t\t\t\tset_bit(i, obj_in_table);\n+\t\t}\n+\t}\n+\n+\tfor (i = 0; i < entries; i++) {\n+\t\tcond_resched();\n+\t\terr = rhltable_remove(&rhlt, &rhl_test_objects[i].list_node, test_rht_params);\n+\t\tif (test_bit(i, obj_in_table)) {\n+\t\t\tif (WARN(err, \"cannot remove element at slot %d\", i))\n+\t\t\t\tcontinue;\n+\t\t} else {\n+\t\t\tif (WARN(err != -ENOENT, \"removed non-existant element, error %d not %d\",\n+\t\t\t\t err, -ENOENT))\n+\t\t\tcontinue;\n+\t\t}\n+\t}\n+\n+\trhltable_destroy(&rhlt);\n+out_free:\n+\tvfree(rhl_test_objects);\n+\tvfree(obj_in_table);\n+\treturn ret;\n+}\n+\n static int __init test_rhashtable_max(struct test_obj *array,\n \t\t\t\t unsigned int entries)\n {\n@@ -480,11 +666,17 @@ static int __init test_rht_init(void)\n \t\t\tfailed_threads++;\n \t\t}\n \t}\n-\tpr_info(\"Started %d threads, %d failed\\n\",\n-\t started_threads, failed_threads);\n \trhashtable_destroy(&ht);\n \tvfree(tdata);\n \tvfree(objs);\n+\n+\t/*\n+\t * rhltable_remove is very expensive, default values can cause test\n+\t * to run for 2 minutes or more, use a smaller number instead.\n+\t */\n+\terr = test_rhltable(entries / 16);\n+\tpr_info(\"Started %d threads, %d failed, rhltable test returns %d\\n\",\n+\t started_threads, failed_threads, err);\n \treturn 0;\n }\n \n", "prefixes": [ "net-next", "4/4" ] }