netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yunsheng Lin <linyunsheng@huawei.com>
To: Cong Wang <xiyou.wangcong@gmail.com>, Jiri Kosina <jikos@kernel.org>
Cc: "Hillf Danton" <hdanton@sina.com>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Kehuan Feng" <kehuan.feng@gmail.com>,
	"Jike Song" <albcamus@gmail.com>,
	"Jonas Bonn" <jonas.bonn@netrounds.com>,
	"Michael Zhivich" <mzhivich@akamai.com>,
	"David Miller" <davem@davemloft.net>,
	LKML <linux-kernel@vger.kernel.org>,
	"Michal Kubecek" <mkubecek@suse.cz>,
	Netdev <netdev@vger.kernel.org>, "Josh Hunt" <johunt@akamai.com>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>
Subject: Re: Packet gets stuck in NOLOCK pfifo_fast qdisc
Date: Tue, 6 Apr 2021 10:46:29 +0800	[thread overview]
Message-ID: <2b99fce1-c235-6083-bd39-cece1f4a0343@huawei.com> (raw)
In-Reply-To: <CAM_iQpU+YD9AcX_77kqmQkqKMuOtnRh5xoGcz9dRRJTe1OnpBQ@mail.gmail.com>

On 2021/4/6 9:49, Cong Wang wrote:
> On Sat, Apr 3, 2021 at 5:23 AM Jiri Kosina <jikos@kernel.org> wrote:
>>
>> I am still planning to have Yunsheng Lin's (CCing) fix [1] tested in the
>> coming days. If it works, then we can consider proceeding with it,
>> otherwise I am all for reverting the whole NOLOCK stuff.
>>
>> [1] https://lore.kernel.org/linux-can/1616641991-14847-1-git-send-email-linyunsheng@huawei.com/T/#u
> 
> I personally prefer to just revert that bit, as it brings more troubles
> than gains. Even with Yunsheng's patch, there are still some issues.
> Essentially, I think the core qdisc scheduling code is not ready for
> lockless, just look at those NOLOCK checks in sch_generic.c. :-/

I am also awared of the NOLOCK checks too:), and I am willing to
take care of it if that is possible.

As the number of cores in a system is increasing, it is the trend
to become lockless, right? Even there is only one cpu involved, the
spinlock taking and releasing takes about 30ns on our arm64 system
when CONFIG_PREEMPT_VOLUNTARY is enable(ip forwarding testing).

Currently I has three ideas to optimize the lockless qdisc:
1. implement the qdisc bypass for lockless qdisc too, see [1].

2. implement lockless enqueuing for lockless qdisc using the idea
   from Jason and Toke. And it has a noticable proformance increase with
   1-4 threads running using the below prototype based on ptr_ring.

static inline int __ptr_ring_multi_produce(struct ptr_ring *r, void *ptr)
{

        int producer, next_producer;


        do {
                producer = READ_ONCE(r->producer);
                if (unlikely(!r->size) || r->queue[producer])
                        return -ENOSPC;
                next_producer = producer + 1;
                if (unlikely(next_producer >= r->size))
                        next_producer = 0;
        } while(cmpxchg_relaxed(&r->producer, producer, next_producer) != producer);

        /* Make sure the pointer we are storing points to a valid data. */
        /* Pairs with the dependency ordering in __ptr_ring_consume. */
        smp_wmb();

        WRITE_ONCE(r->queue[producer], ptr);
        return 0;
}

3. Maybe it is possible to remove the netif_tx_lock for lockless qdisc
   too, because dev_hard_start_xmit is also in the protection of
   qdisc_run_begin()/qdisc_run_end()(if there is only one qdisc using
   a netdev queue, which is true for pfifo_fast, I believe).


[1]. https://patchwork.kernel.org/project/netdevbpf/patch/1616404156-11772-1-git-send-email-linyunsheng@huawei.com/

> 
> Thanks.
> 
> .
> 


  reply	other threads:[~2021-04-06  2:46 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-09  6:46 Packet gets stuck in NOLOCK pfifo_fast qdisc Jonas Bonn
2019-10-09 19:14 ` Paolo Abeni
2019-10-10  6:27   ` Jonas Bonn
2019-10-11  0:39   ` Jonas Bonn
2020-06-23 13:42     ` Michael Zhivich
2020-06-30 19:14       ` Josh Hunt
2020-07-01  7:53         ` Jonas Bonn
2020-07-01 16:05         ` Cong Wang
2020-07-01 19:58           ` Cong Wang
2020-07-01 22:02             ` Josh Hunt
2020-07-02  6:14             ` Jonas Bonn
2020-07-02  9:45               ` Paolo Abeni
2020-07-02 18:08                 ` Josh Hunt
2020-07-07 14:18                   ` Paolo Abeni
2020-07-08 20:16                     ` Cong Wang
2020-07-09  9:20                       ` Paolo Abeni
2020-07-08 20:33                   ` Zhivich, Michael
2020-08-20  7:43                   ` Jike Song
2020-08-20 18:13                     ` Josh Hunt
     [not found]                     ` <20200822032800.16296-1-hdanton@sina.com>
2020-08-25  2:18                       ` Fengkehuan Feng
     [not found]                         ` <20200825032312.11776-1-hdanton@sina.com>
2020-08-25  7:14                           ` Fengkehuan Feng
     [not found]                             ` <20200825162329.11292-1-hdanton@sina.com>
2020-08-26  2:38                               ` Kehuan Feng
     [not found]                                 ` <CACS=qqKptAQQGiMoCs1Zgs9S4ZppHhasy1AK4df2NxnCDR+vCw@mail.gmail.com>
     [not found]                                   ` <5f46032e.1c69fb81.9880c.7a6cSMTPIN_ADDED_MISSING@mx.google.com>
2020-08-27  6:56                                     ` Kehuan Feng
     [not found]                                       ` <20200827125747.5816-1-hdanton@sina.com>
2020-08-28  1:45                                         ` Kehuan Feng
2020-09-03  5:01                                           ` Cong Wang
2020-09-03  8:39                                             ` Paolo Abeni
2020-09-03 17:43                                               ` Cong Wang
2020-09-04  5:07                                                 ` John Fastabend
2020-09-10 20:15                                                   ` Cong Wang
2020-09-10 21:07                                                     ` John Fastabend
2020-09-10 21:40                                                       ` Paolo Abeni
2021-04-02 19:25                                                   ` Jiri Kosina
2021-04-02 19:33                                                     ` Josh Hunt
     [not found]                                                     ` <20210403003537.2032-1-hdanton@sina.com>
2021-04-03 12:23                                                       ` Jiri Kosina
2021-04-06  0:55                                                         ` Yunsheng Lin
2021-04-06  7:06                                                           ` Michal Kubecek
2021-04-06 10:13                                                             ` Juergen Gross
2021-04-06 12:17                                                               ` Yunsheng Lin
2021-04-06  1:49                                                         ` Cong Wang
2021-04-06  2:46                                                           ` Yunsheng Lin [this message]
2021-04-06  7:31                                                             ` Michal Kubecek
2021-04-06 12:24                                                               ` Yunsheng Lin
     [not found]                                               ` <20200903101957.428-1-hdanton@sina.com>
2020-09-04  3:20                                                 ` Kehuan Feng
2020-09-10 20:19                                                   ` Cong Wang
2020-09-14  2:10                                                     ` Yunsheng Lin
2020-09-17 19:52                                                       ` Cong Wang
2020-09-18  2:06                                                         ` Kehuan Feng

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=2b99fce1-c235-6083-bd39-cece1f4a0343@huawei.com \
    --to=linyunsheng@huawei.com \
    --cc=Jason@zx2c4.com \
    --cc=albcamus@gmail.com \
    --cc=davem@davemloft.net \
    --cc=hdanton@sina.com \
    --cc=jikos@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=johunt@akamai.com \
    --cc=jonas.bonn@netrounds.com \
    --cc=kehuan.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkubecek@suse.cz \
    --cc=mzhivich@akamai.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=toke@redhat.com \
    --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).