Lets make wifi fast again!
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <jbrouer@redhat.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jonathan Morton <chromatix99@gmail.com>,
	make-wifi-fast@lists.bufferbloat.net,
	"codel@lists.bufferbloat.net" <codel@lists.bufferbloat.net>,
	ath10k <ath10k@lists.infradead.org>
Subject: Re: [Make-wifi-fast] [Codel] fq_codel_drop vs a udp flood
Date: Mon, 2 May 2016 09:47:18 +0200	[thread overview]
Message-ID: <20160502094718.56d8e7b0@redhat.com> (raw)
In-Reply-To: <1462132553.5535.207.camel@edumazet-glaptop3.roam.corp.google.com>

On Sun, 01 May 2016 12:55:53 -0700
Eric Dumazet <eric.dumazet@gmail.com> wrote:

> On Sun, 2016-05-01 at 11:46 -0700, Eric Dumazet wrote:
> 
> > Just drop half backlog packets instead of 1, (maybe add a cap of 64
> > packets to avoid too big burts of kfree_skb() which might add cpu
> > spikes) and problem is gone.
> >   
> 
> I used following patch and it indeed solved the issue in my tests.
> 
> (Not the DDOS case, but when few fat flows are really bad citizens)
> 
> diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
> index a5e420b3d4ab..0cb8699624bc 100644
> --- a/net/sched/sch_fq_codel.c
> +++ b/net/sched/sch_fq_codel.c
> @@ -135,11 +135,11 @@ static inline void flow_queue_add(struct fq_codel_flow *flow,
>  	skb->next = NULL;
>  }
>  
> -static unsigned int fq_codel_drop(struct Qdisc *sch)
> +static unsigned int fq_codel_drop(struct Qdisc *sch, unsigned int max)
>  {
>  	struct fq_codel_sched_data *q = qdisc_priv(sch);
>  	struct sk_buff *skb;
> -	unsigned int maxbacklog = 0, idx = 0, i, len;
> +	unsigned int maxbacklog = 0, idx = 0, i, len = 0;
>  	struct fq_codel_flow *flow;
>  
>  	/* Queue is full! Find the fat flow and drop packet from it.
> @@ -153,15 +153,26 @@ static unsigned int fq_codel_drop(struct Qdisc *sch)
>  			idx = i;
>  		}
>  	}
> +	/* As the search was painful, drop half bytes of this fat flow.
> +	 * Limit to max packets to not inflict too big latencies,
> +	 * as kfree_skb() might be quite expensive.
> +	 */
> +	maxbacklog >>= 1;
> +
>  	flow = &q->flows[idx];
> -	skb = dequeue_head(flow);
> -	len = qdisc_pkt_len(skb);
> +	for (i = 0; i < max;) {
> +		skb = dequeue_head(flow);
> +		len += qdisc_pkt_len(skb);
> +		kfree_skb(skb);
> +		i++;
> +		if (len >= maxbacklog)
> +			break;
> +	}

What about using bulk free of SKBs here?

There is a very high probability that we are hitting SLUB slowpath,
which involves a locked cmpxchg_double per packet.  Instead we can
amortize this cost via kmem_cache_free_bulk().

Maybe extend kfree_skb_list() to hide the slab/kmem_cache call?


> +	sch->qstats.drops += i;
> +	sch->qstats.backlog -= len;
>  	q->backlogs[idx] -= len;
> -	sch->q.qlen--;
> -	qdisc_qstats_drop(sch);
> -	qdisc_qstats_backlog_dec(sch, skb);
> -	kfree_skb(skb);
> -	flow->dropped++;
> +	sch->q.qlen -= i;
> +	flow->dropped += i;
>  	return idx;
>  }


-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  Author of http://www.iptv-analyzer.org
  LinkedIn: http://www.linkedin.com/in/brouer

  reply	other threads:[~2016-05-02  7:47 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-01  3:41 [Make-wifi-fast] " Dave Taht
2016-05-01  4:46 ` Jonathan Morton
2016-05-01  5:08 ` Ben Greear
2016-05-01  5:23   ` Dave Taht
2016-05-01 14:47     ` dpreed
     [not found]       ` <CAJq5cE2woA3yb6i_7NLPpxjzvhsVk5uL8BnSTAY7Lp-M0KiPNg@mail.gmail.com>
     [not found]         ` <CAJq5cE2K0yrz6ALAoKWu23RSJZX9Y_P7Mqcy9ba8e-L3AVhOaA@mail.gmail.com>
2016-05-01 15:51           ` Jonathan Morton
2016-05-02 14:03       ` Roman Yeryomin
2016-05-02 18:40         ` Dave Taht
2016-05-02 20:17           ` [Make-wifi-fast] [Codel] " Isaac Konikoff
2016-05-05 13:55           ` [Make-wifi-fast] " Roman Yeryomin
2016-05-05 14:55             ` Roman Yeryomin
2016-05-02 19:47         ` David Lang
2016-05-01 17:59 ` [Make-wifi-fast] [Codel] " Eric Dumazet
2016-05-01 18:20   ` Jonathan Morton
2016-05-01 18:46     ` Eric Dumazet
2016-05-01 19:55       ` Eric Dumazet
2016-05-02  7:47         ` Jesper Dangaard Brouer [this message]
2016-05-01 20:35       ` Jonathan Morton
2016-05-01 20:55         ` Eric Dumazet
2016-05-02 14:18           ` Roman Yeryomin
2016-05-02 15:07             ` Eric Dumazet
2016-05-02 15:43               ` Roman Yeryomin
2016-05-02 16:14                 ` Eric Dumazet
2016-05-02 17:08                   ` Dave Taht
2016-05-02 17:44                     ` Eric Dumazet
2016-05-05 14:32                     ` Roman Yeryomin
2016-05-05 14:53                   ` Roman Yeryomin
2016-05-05 15:32                     ` Dave Taht
2016-05-05 16:07                       ` Roman Yeryomin
2016-05-05 16:59                         ` Jonathan Morton
2016-05-05 17:39                           ` Roman Yeryomin
2016-05-05 18:16                             ` Dave Taht
2016-05-05 18:33                           ` Dave Taht
2016-05-05 16:12                     ` Eric Dumazet
2016-05-05 16:25                       ` Roman Yeryomin
2016-05-05 16:42                         ` Roman Yeryomin
2016-05-06 10:55                           ` Roman Yeryomin
2016-05-05 19:23                         ` Eric Dumazet
2016-05-05 19:41                           ` Dave Taht
2016-05-06  8:41                             ` moeller0
2016-05-06 11:33                               ` Jesper Dangaard Brouer
2016-05-06 11:46                                 ` moeller0
2016-05-06 13:25                                   ` Eric Dumazet
2016-05-06 15:25                                     ` moeller0
2016-05-06 15:58                                       ` Eric Dumazet
2016-05-06 16:30                                         ` moeller0
2016-05-06  9:42                           ` [Make-wifi-fast] OpenWRT wrong adjustment of fq_codel defaults (Was: [Codel] fq_codel_drop vs a udp flood) Jesper Dangaard Brouer
2016-05-06 12:47                             ` Jesper Dangaard Brouer
2016-05-06 18:43                               ` Roman Yeryomin
2016-05-06 18:56                                 ` Roman Yeryomin
2016-05-06 19:43                                   ` Dave Taht
2016-05-15 22:34                                     ` Roman Yeryomin
2016-05-15 23:07                                       ` Eric Dumazet
2016-05-15 23:27                                         ` Roman Yeryomin
2016-05-16  8:12                                       ` David Lang
2016-05-16  8:26                                         ` Roman Yeryomin
2016-05-16  8:46                                           ` David Lang
2016-05-16 10:34                                             ` [Make-wifi-fast] [OpenWrt-Devel] " Sebastian Moeller
2016-05-16  8:14                                       ` [Make-wifi-fast] " Roman Yeryomin
2016-05-16 14:23                                         ` Eric Dumazet
2016-05-16 16:04                                         ` Dave Taht
2016-05-16 19:46                                           ` Roman Yeryomin
2016-05-07  9:57                             ` Kevin Darbyshire-Bryant
2016-05-15 22:47                               ` Roman Yeryomin
2016-05-03  2:26     ` [Make-wifi-fast] [Codel] fq_codel_drop vs a udp flood Dave Taht
2016-05-03  5:21       ` Dave Taht
2016-05-03 12:39         ` Agarwal, Anil
2016-05-03 12:50           ` Agarwal, Anil
2016-05-03 13:35             ` Eric Dumazet
2016-05-03 15:37               ` Agarwal, Anil
2016-05-03 17:37               ` Dave Taht
2016-05-03 17:54                 ` Eric Dumazet
2016-05-03 18:11                   ` Dave Taht
2016-05-01 18:26   ` Dave Taht
2016-05-01 22:30     ` Eric Dumazet
2016-05-02 14:09   ` Roman Yeryomin
2016-05-02 15:04     ` Eric Dumazet
2016-05-02 15:42       ` Roman Yeryomin
2016-05-02 13:47 ` [Make-wifi-fast] " Roman Yeryomin
2016-05-02 15:01   ` Eric Dumazet

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

  List information: https://lists.bufferbloat.net/postorius/lists/make-wifi-fast.lists.bufferbloat.net/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160502094718.56d8e7b0@redhat.com \
    --to=jbrouer@redhat.com \
    --cc=ath10k@lists.infradead.org \
    --cc=chromatix99@gmail.com \
    --cc=codel@lists.bufferbloat.net \
    --cc=eric.dumazet@gmail.com \
    --cc=make-wifi-fast@lists.bufferbloat.net \
    /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