From: Simon Horman <simon.horman@netronome.com>
To: Chris Mi <chrism@mellanox.com>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com,
xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net,
mawilcox@microsoft.com
Subject: Re: [patch net-next 2/3] net/sched: Change cls_flower to use IDR
Date: Mon, 28 Aug 2017 13:37:22 +0200 [thread overview]
Message-ID: <20170828113721.GA14697@vergenet.net> (raw)
In-Reply-To: <1503902477-39829-3-git-send-email-chrism@mellanox.com>
On Mon, Aug 28, 2017 at 02:41:16AM -0400, Chris Mi wrote:
> Currently, all filters with the same priority are linked in a doubly
> linked list. Every filter should have a unique handle. To make the
> handle unique, we need to iterate the list every time to see if the
> handle exists or not when inserting a new filter. It is time-consuming.
> For example, it takes about 5m3.169s to insert 64K rules.
>
> This patch changes cls_flower to use IDR. With this patch, it
> takes about 0m1.127s to insert 64K rules. The improvement is huge.
Very nice :)
> But please note that in this testing, all filters share the same action.
> If every filter has a unique action, that is another bottleneck.
> Follow-up patch in this patchset addresses that.
>
> Signed-off-by: Chris Mi <chrism@mellanox.com>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> ---
> net/sched/cls_flower.c | 55 +++++++++++++++++++++-----------------------------
> 1 file changed, 23 insertions(+), 32 deletions(-)
>
> diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
> index bd9dab4..3d041d2 100644
> --- a/net/sched/cls_flower.c
> +++ b/net/sched/cls_flower.c
...
> @@ -890,6 +870,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
> struct cls_fl_filter *fnew;
> struct nlattr **tb;
> struct fl_flow_mask mask = {};
> + unsigned long idr_index;
> int err;
>
> if (!tca[TCA_OPTIONS])
> @@ -920,13 +901,21 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
> goto errout;
>
> if (!handle) {
> - handle = fl_grab_new_handle(tp, head);
> - if (!handle) {
> - err = -EINVAL;
> + err = idr_alloc_ext(&head->handle_idr, fnew, &idr_index,
> + 1, 0x80000000, GFP_KERNEL);
> + if (err)
> goto errout;
> - }
> + fnew->handle = idr_index;
> + }
> +
> + /* user specifies a handle and it doesn't exist */
> + if (handle && !fold) {
> + err = idr_alloc_ext(&head->handle_idr, fnew, &idr_index,
> + handle, handle + 1, GFP_KERNEL);
> + if (err)
> + goto errout;
> + fnew->handle = idr_index;
> }
> - fnew->handle = handle;
>
> if (tb[TCA_FLOWER_FLAGS]) {
> fnew->flags = nla_get_u32(tb[TCA_FLOWER_FLAGS]);
> @@ -980,6 +969,8 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
> *arg = fnew;
>
> if (fold) {
> + fnew->handle = handle;
Can it be the case that fold is non-NULL and handle is zero?
The handling of that case seem to have changed in this patch.
> + idr_replace_ext(&head->handle_idr, fnew, fnew->handle);
> list_replace_rcu(&fold->list, &fnew->list);
> tcf_unbind_filter(tp, &fold->res);
> call_rcu(&fold->rcu, fl_destroy_filter);
> --
> 1.8.3.1
>
next prev parent reply other threads:[~2017-08-28 11:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-28 6:41 [patch net-next 0/3] net/sched: Improve getting objects by indexes Chris Mi
2017-08-28 6:41 ` [patch net-next 1/3] idr: Add new APIs to support unsigned long Chris Mi
2017-08-29 7:14 ` Hannes Frederic Sowa
2017-08-29 7:34 ` Chris Mi
2017-08-29 7:57 ` Jiri Pirko
2017-08-29 8:00 ` Chris Mi
2017-08-29 7:56 ` Jiri Pirko
2017-08-28 6:41 ` [patch net-next 2/3] net/sched: Change cls_flower to use IDR Chris Mi
2017-08-28 11:37 ` Simon Horman [this message]
2017-08-29 3:25 ` Chris Mi
2017-08-30 10:30 ` Simon Horman
2017-08-28 21:55 ` Jamal Hadi Salim
2017-08-29 1:34 ` Chris Mi
2017-08-28 6:41 ` [patch net-next 3/3] net/sched: Change act_api and act_xxx modules " Chris Mi
2017-08-28 21:56 ` Jamal Hadi Salim
-- strict thread matches above, loose matches on Subject: below --
2017-08-16 2:12 [patch net-next 0/3] net/sched: Improve getting objects by indexes Chris Mi
[not found] ` <1502849538-14284-1-git-send-email-chrism-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-08-16 2:12 ` [patch net-next 2/3] net/sched: Change cls_flower to use IDR Chris Mi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170828113721.GA14697@vergenet.net \
--to=simon.horman@netronome.com \
--cc=chrism@mellanox.com \
--cc=davem@davemloft.net \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=mawilcox@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).