On Wed 21 Aug 2019 at 01:32, Matthew Wilcox <wi...@infradead.org> wrote:
> From: "Matthew Wilcox (Oracle)" <wi...@infradead.org>
>
> Instead of iterating over every filter attached to every mark, just
> iterate over each filter.
>
> Signed-off-by: Matthew Wilcox (Oracle) <wi...@infradead.org>
> ---
>  net/sched/cls_flower.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
> index 54026c9e9b05..2a1999d2b507 100644
> --- a/net/sched/cls_flower.c
> +++ b/net/sched/cls_flower.c
> @@ -575,18 +575,15 @@ static void fl_destroy(struct tcf_proto *tp, bool 
> rtnl_held,
>                      struct netlink_ext_ack *extack)
>  {
>       struct cls_fl_head *head = fl_head_dereference(tp);
> -     struct fl_flow_mask *mask, *next_mask;
> -     struct cls_fl_filter *f, *next;
> +     struct cls_fl_filter *f;
> +     unsigned long handle;
>       bool last;
>
> -     list_for_each_entry_safe(mask, next_mask, &head->masks, list) {
> -             list_for_each_entry_safe(f, next, &mask->filters, list) {
> -                     __fl_delete(tp, f, &last, rtnl_held, extack);
> -                     if (last)
> -                             break;
> -             }
> +     xa_for_each(&head->filters, handle, f) {
> +             __fl_delete(tp, f, &last, rtnl_held, extack);
> +             if (last)
> +                     break;
>       }
> -     xa_destroy(&head->filters);
>
>       __module_get(THIS_MODULE);
>       tcf_queue_work(&head->rwork, fl_destroy_sleepable);

What is the motivation for this change? You substitute O(n) iteration
over linked list with O(nlogn) iteration over xarray without any
apparent benefit.

Reply via email to