Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/806400/?format=api
{ "id": 806400, "url": "http://patchwork.ozlabs.org/api/patches/806400/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1503902477-39829-3-git-send-email-chrism@mellanox.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": "<1503902477-39829-3-git-send-email-chrism@mellanox.com>", "list_archive_url": null, "date": "2017-08-28T06:41:16", "name": "[net-next,2/3] net/sched: Change cls_flower to use IDR", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "f56549c3a1e705eaaed4afcd918c5822a7e74a1f", "submitter": { "id": 72170, "url": "http://patchwork.ozlabs.org/api/people/72170/?format=api", "name": "Chris Mi", "email": "chrism@mellanox.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/1503902477-39829-3-git-send-email-chrism@mellanox.com/mbox/", "series": [ { "id": 87, "url": "http://patchwork.ozlabs.org/api/series/87/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=87", "date": "2017-08-28T06:41:15", "name": "net/sched: Improve getting objects by indexes", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/87/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/806400/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/806400/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 3xghy34Wk1z9sNq\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 28 Aug 2017 16:41:47 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751237AbdH1Glq (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 28 Aug 2017 02:41:46 -0400", "from mail-il-dmz.mellanox.com ([193.47.165.129]:48392 \"EHLO\n\tmellanox.co.il\" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org\n\twith ESMTP id S1750767AbdH1Glo (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 28 Aug 2017 02:41:44 -0400", "from Internal Mail-Server by MTLPINE1 (envelope-from\n\tchrism@mellanox.com)\n\twith ESMTPS (AES256-SHA encrypted); 28 Aug 2017 09:41:41 +0300", "from bjglab-18.mtbc.labs.mlnx (bjglab-18.mtbc.labs.mlnx\n\t[10.200.0.168])\n\tby labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v7S6fPZo022940;\n\tMon, 28 Aug 2017 09:41:39 +0300" ], "From": "Chris Mi <chrism@mellanox.com>", "To": "netdev@vger.kernel.org", "Cc": "jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,\n\tdavem@davemloft.net, mawilcox@microsoft.com", "Subject": "[patch net-next 2/3] net/sched: Change cls_flower to use IDR", "Date": "Mon, 28 Aug 2017 02:41:16 -0400", "Message-Id": "<1503902477-39829-3-git-send-email-chrism@mellanox.com>", "X-Mailer": "git-send-email 1.8.3.1", "In-Reply-To": "<1503902477-39829-1-git-send-email-chrism@mellanox.com>", "References": "<1503902477-39829-1-git-send-email-chrism@mellanox.com>", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "Currently, all filters with the same priority are linked in a doubly\nlinked list. Every filter should have a unique handle. To make the\nhandle unique, we need to iterate the list every time to see if the\nhandle exists or not when inserting a new filter. It is time-consuming.\nFor example, it takes about 5m3.169s to insert 64K rules.\n\nThis patch changes cls_flower to use IDR. With this patch, it\ntakes about 0m1.127s to insert 64K rules. The improvement is huge.\n\nBut please note that in this testing, all filters share the same action.\nIf every filter has a unique action, that is another bottleneck.\nFollow-up patch in this patchset addresses that.\n\nSigned-off-by: Chris Mi <chrism@mellanox.com>\nSigned-off-by: Jiri Pirko <jiri@mellanox.com>\n---\n net/sched/cls_flower.c | 55 +++++++++++++++++++++-----------------------------\n 1 file changed, 23 insertions(+), 32 deletions(-)", "diff": "diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c\nindex bd9dab4..3d041d2 100644\n--- a/net/sched/cls_flower.c\n+++ b/net/sched/cls_flower.c\n@@ -68,7 +68,6 @@ struct cls_fl_head {\n \tstruct rhashtable ht;\n \tstruct fl_flow_mask mask;\n \tstruct flow_dissector dissector;\n-\tu32 hgen;\n \tbool mask_assigned;\n \tstruct list_head filters;\n \tstruct rhashtable_params ht_params;\n@@ -76,6 +75,7 @@ struct cls_fl_head {\n \t\tstruct work_struct work;\n \t\tstruct rcu_head\trcu;\n \t};\n+\tstruct idr handle_idr;\n };\n \n struct cls_fl_filter {\n@@ -210,6 +210,7 @@ static int fl_init(struct tcf_proto *tp)\n \n \tINIT_LIST_HEAD_RCU(&head->filters);\n \trcu_assign_pointer(tp->root, head);\n+\tidr_init(&head->handle_idr);\n \n \treturn 0;\n }\n@@ -295,6 +296,9 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)\n \n static void __fl_delete(struct tcf_proto *tp, struct cls_fl_filter *f)\n {\n+\tstruct cls_fl_head *head = rtnl_dereference(tp->root);\n+\n+\tidr_remove_ext(&head->handle_idr, f->handle);\n \tlist_del_rcu(&f->list);\n \tif (!tc_skip_hw(f->flags))\n \t\tfl_hw_destroy_filter(tp, f);\n@@ -327,6 +331,7 @@ static void fl_destroy(struct tcf_proto *tp)\n \n \tlist_for_each_entry_safe(f, next, &head->filters, list)\n \t\t__fl_delete(tp, f);\n+\tidr_destroy(&head->handle_idr);\n \n \t__module_get(THIS_MODULE);\n \tcall_rcu(&head->rcu, fl_destroy_rcu);\n@@ -335,12 +340,8 @@ static void fl_destroy(struct tcf_proto *tp)\n static void *fl_get(struct tcf_proto *tp, u32 handle)\n {\n \tstruct cls_fl_head *head = rtnl_dereference(tp->root);\n-\tstruct cls_fl_filter *f;\n \n-\tlist_for_each_entry(f, &head->filters, list)\n-\t\tif (f->handle == handle)\n-\t\t\treturn f;\n-\treturn NULL;\n+\treturn idr_find_ext(&head->handle_idr, handle);\n }\n \n static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = {\n@@ -859,27 +860,6 @@ static int fl_set_parms(struct net *net, struct tcf_proto *tp,\n \treturn 0;\n }\n \n-static u32 fl_grab_new_handle(struct tcf_proto *tp,\n-\t\t\t struct cls_fl_head *head)\n-{\n-\tunsigned int i = 0x80000000;\n-\tu32 handle;\n-\n-\tdo {\n-\t\tif (++head->hgen == 0x7FFFFFFF)\n-\t\t\thead->hgen = 1;\n-\t} while (--i > 0 && fl_get(tp, head->hgen));\n-\n-\tif (unlikely(i == 0)) {\n-\t\tpr_err(\"Insufficient number of handles\\n\");\n-\t\thandle = 0;\n-\t} else {\n-\t\thandle = head->hgen;\n-\t}\n-\n-\treturn handle;\n-}\n-\n static int fl_change(struct net *net, struct sk_buff *in_skb,\n \t\t struct tcf_proto *tp, unsigned long base,\n \t\t u32 handle, struct nlattr **tca,\n@@ -890,6 +870,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,\n \tstruct cls_fl_filter *fnew;\n \tstruct nlattr **tb;\n \tstruct fl_flow_mask mask = {};\n+\tunsigned long idr_index;\n \tint err;\n \n \tif (!tca[TCA_OPTIONS])\n@@ -920,13 +901,21 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,\n \t\tgoto errout;\n \n \tif (!handle) {\n-\t\thandle = fl_grab_new_handle(tp, head);\n-\t\tif (!handle) {\n-\t\t\terr = -EINVAL;\n+\t\terr = idr_alloc_ext(&head->handle_idr, fnew, &idr_index,\n+\t\t\t\t 1, 0x80000000, GFP_KERNEL);\n+\t\tif (err)\n \t\t\tgoto errout;\n-\t\t}\n+\t\tfnew->handle = idr_index;\n+\t}\n+\n+\t/* user specifies a handle and it doesn't exist */\n+\tif (handle && !fold) {\n+\t\terr = idr_alloc_ext(&head->handle_idr, fnew, &idr_index,\n+\t\t\t\t handle, handle + 1, GFP_KERNEL);\n+\t\tif (err)\n+\t\t\tgoto errout;\n+\t\tfnew->handle = idr_index;\n \t}\n-\tfnew->handle = handle;\n \n \tif (tb[TCA_FLOWER_FLAGS]) {\n \t\tfnew->flags = nla_get_u32(tb[TCA_FLOWER_FLAGS]);\n@@ -980,6 +969,8 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,\n \t*arg = fnew;\n \n \tif (fold) {\n+\t\tfnew->handle = handle;\n+\t\tidr_replace_ext(&head->handle_idr, fnew, fnew->handle);\n \t\tlist_replace_rcu(&fold->list, &fnew->list);\n \t\ttcf_unbind_filter(tp, &fold->res);\n \t\tcall_rcu(&fold->rcu, fl_destroy_filter);\n", "prefixes": [ "net-next", "2/3" ] }