All of lore.kernel.org
 help / color / mirror / Atom feed
From: "YU, Xiangning" <xiangning.yu@alibaba-inc.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v2 2/2] net: sched: Lockless Token Bucket (LTB) qdisc
Date: Thu, 09 Jul 2020 07:59:45 +0800	[thread overview]
Message-ID: <d1716bc1-a975-54a3-8b7e-a3d3bcac69c5@alibaba-inc.com> (raw)
In-Reply-To: <554197ce-cef1-0e75-06d7-56dbef7c13cc@gmail.com>



On 7/8/20 3:29 PM, Eric Dumazet wrote:
> 
> 
> On 7/8/20 9:38 AM, YU, Xiangning wrote:
>> Lockless Token Bucket (LTB) is a qdisc implementation that controls the
>> use of outbound bandwidth on a shared link. With the help of lockless
>> qdisc, and by decoupling rate limiting and bandwidth sharing, LTB is
>> designed to scale in the cloud data centers.
> 
>> +static int ltb_enqueue(struct sk_buff *skb, struct Qdisc *sch,
>> +		       spinlock_t *root_lock, struct sk_buff **to_free)
>> +{
>> +	struct ltb_sched *ltb = qdisc_priv(sch);
>> +	struct ltb_pcpu_sched *pcpu_q;
>> +	struct ltb_pcpu_data *pcpu;
>> +	struct ltb_class *cl;
>> +	int cpu;
>> +
>> +	pcpu = this_cpu_ptr(ltb->pcpu_data);
>> +	pcpu_q = qdisc_priv(pcpu->qdisc);
>> +	cpu = smp_processor_id();
>> +	ltb_skb_cb(skb)->cpu = cpu;
>> +
>> +	cl = ltb_classify(sch, ltb, skb);
>> +	if (unlikely(!cl)) {
>> +		kfree_skb(skb);
>> +		return NET_XMIT_DROP;
>> +	}
>> +
>> +	pcpu->active = true;
>> +	if (unlikely(kfifo_put(&cl->aggr_queues[cpu], skb) == 0)) {
>> +		kfree_skb(skb);
>> +		atomic64_inc(&cl->stat_drops);
> 
>             qdisc drop counter should also be incremented.
> 
>> +		return NET_XMIT_DROP;
>> +	}
>> +
> 
>> +	sch->q.qlen = 1;
> So, this is touching a shared cache line, why is it needed ? This looks some hack to me.
> 

Somehow I had the impression that if qlen is zero the qdisc won't be scheduled. We need to fix it. Thank you for catching this!

>> +	pcpu_q->qdisc->q.qlen++;
> 
>> +	tasklet_schedule(&cl->aggr_tasklet);
> 
> This is also touching a cache line.
> 
> I really have doubts about scheduling a tasklet for every sent packet.
> 
> (Particularly if majority of packets should not be rate limited)
> 

Yes, we are touching a cache line here to make sure aggregation tasklet is scheduled immediately. In most cases it is a call to test_and_set_bit(). 

We might be able to do some inline processing without tasklet here, still we need to make sure the aggregation won't run simultaneously on multiple CPUs. 

Thanks,
- Xiangning

  reply	other threads:[~2020-07-08 23:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 16:38 [PATCH net-next v2 2/2] net: sched: Lockless Token Bucket (LTB) qdisc YU, Xiangning
2020-07-08 16:47 ` Randy Dunlap
2020-07-08 21:14 ` Eric Dumazet
2020-07-08 21:38   ` YU, Xiangning
2020-07-08 21:37 ` Eric Dumazet
2020-07-08 22:01   ` YU, Xiangning
2020-07-08 22:08 ` Eric Dumazet
2020-07-08 22:29 ` Eric Dumazet
2020-07-08 23:59   ` YU, Xiangning [this message]
2020-07-09  0:08     ` Eric Dumazet
2020-07-09  0:58       ` YU, Xiangning
2020-07-09  1:24         ` Eric Dumazet
2020-07-09 17:04           ` YU, Xiangning
2020-07-09 17:15             ` Eric Dumazet
2020-07-09 18:20               ` YU, Xiangning
2020-07-09 22:22                 ` Eric Dumazet
2020-07-10  1:42                   ` YU, Xiangning
2020-07-09 10:19 ` kernel test robot
2020-07-09 10:19   ` kernel test robot
2020-08-04 10:37 ` Maxim Mikityanskiy
2020-08-04 21:27   ` YU, Xiangning

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=d1716bc1-a975-54a3-8b7e-a3d3bcac69c5@alibaba-inc.com \
    --to=xiangning.yu@alibaba-inc.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.