All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Måns Rullgård" <mans@mansr.com>
To: David Miller <davem@davemloft.net>
Cc: romieu@fr.zoreil.com, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, slash.tmp@free.fr
Subject: Re: [PATCH v5] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
Date: Wed, 11 Nov 2015 18:25:05 +0000	[thread overview]
Message-ID: <yw1xk2poo0la.fsf@unicorn.mansr.com> (raw)
In-Reply-To: <20151111.112423.1751428739163066569.davem@davemloft.net> (David Miller's message of "Wed, 11 Nov 2015 11:24:23 -0500 (EST)")

David Miller <davem@davemloft.net> writes:

> From: Måns Rullgård <mans@mansr.com>
> Date: Wed, 11 Nov 2015 13:04:07 +0000
>
>> Måns Rullgård <mans@mansr.com> writes:
>> 
>>> David Miller <davem@davemloft.net> writes:
>>>
>>>> From: Måns Rullgård <mans@mansr.com>
>>>> Date: Wed, 11 Nov 2015 00:40:09 +0000
>>>>
>>>>> When the DMA complete interrupt arrives, the next chain should be
>>>>> kicked off as quickly as possible, and I don't see why that would
>>>>> benefit from being done in napi context.
>>>>
>>>> NAPI isn't about low latency, it's about fairness and interrupt
>>>> mitigation.
>>>>
>>>> You probably don't even realize that all of the TX SKB freeing you do
>>>> in the hardware interrupt handler end up being actually processed by a
>>>> scheduled software interrupt anyways.
>>>>
>>>> So you are gaining almost nothing by not doing TX completion in NAPI
>>>> context, whereas by doing so you would be gaining a lot including
>>>> more simplified locking or even the ability to do no locking at all.
>>>
>>> TX completion is separate from restarting the DMA, and moving that to
>>> NAPI may well be a good idea.  Should I simply napi_schedule() if the
>>> hardware indicates TX is complete and do the cleanup in the NAPI poll
>>> function?
>> 
>> I tried that, and throughput (as measured by iperf3) dropped by 2%.
>> Maybe I did something wrong.
>
> Did you fix all the locking in that change?
>
> Since all of your TX handling runs in software interrupt context, you
> can stop using IRQ locking and use BH locking driver-wide instead.
>
> And actually, no locking is really needed for TX processing.  With
> proper memory barriers and properly crafter queue state tests, you
> can run completely lockless.
>
> Again, look at example drivers.  I know, for example, that
> drivers/net/ethernet/broadcom/tg3.c runs TX lockless.  You'll
> see that tg3_tx() takes no locks at all.

The way the hardware works, once a DMA operation has been started,
adding more packets to the active chain can't be done reliably.  For
that reason, if start_xmit is called (with xmit_more zero) while a DMA
operation is in progress, the new packet(s) must be queued until the
hardware raises the DMA complete interrupt.  At that time, the next
pending DMA chain, if any, can be kicked off.  If the TX DMA channel is
idle when start_xmit is called, it can be started immediately.  Checking
the DMA status and starting it if idle has to be done atomically
somehow.

There is a separate indication for actual TX completion, and the
interrupt for that can be set to only fire every 7 frames or when a
timeout expires.  When this happens, the TX cleanup needs to run, and
that can obviously be done from NAPI without using any locks.

Bear in mind that this hardware is quite primitive compared to modern
high-performance Ethernet controllers from the likes of Intel and
Broadcom.  The documentation I have is dated 2003.

-- 
Måns Rullgård
mans@mansr.com

  reply	other threads:[~2015-11-11 18:25 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-10 16:14 [PATCH v5] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller Mans Rullgard
2015-11-10 17:55 ` Eric Dumazet
2015-11-10 18:05   ` Måns Rullgård
2015-11-10 20:04     ` David Miller
2015-11-10 20:53       ` Måns Rullgård
2015-11-10 21:06         ` David Miller
2015-11-10 21:21           ` Måns Rullgård
2015-11-10 21:51             ` Eric Dumazet
2015-11-11 13:41               ` Mason
2015-11-11 13:54                 ` Måns Rullgård
2015-11-11 14:10                   ` Eric Dumazet
2015-11-11 14:06                 ` Eric Dumazet
2015-11-10 17:58 ` Eric Dumazet
2015-11-10 18:07   ` Måns Rullgård
2015-11-10 19:13 ` Mason
2015-11-10 19:25   ` Måns Rullgård
2015-11-12 13:33     ` Mason
2015-11-12 14:04       ` Måns Rullgård
2015-11-12 16:19         ` Mason
2015-11-12 16:57           ` Måns Rullgård
2015-11-12 17:20             ` Måns Rullgård
2015-11-10 22:09 ` Andy Shevchenko
2015-11-10 22:34   ` Måns Rullgård
2015-11-10 22:40     ` Andy Shevchenko
2015-11-10 23:07       ` Måns Rullgård
2015-11-11  0:36         ` Andy Shevchenko
2015-11-11  0:44           ` Måns Rullgård
2015-11-10 23:34 ` Francois Romieu
2015-11-11  0:40   ` Måns Rullgård
2015-11-11  2:11     ` David Miller
2015-11-11 12:22       ` Måns Rullgård
2015-11-11 13:04         ` Måns Rullgård
2015-11-11 13:29           ` Eric Dumazet
2015-11-11 13:48             ` Måns Rullgård
2015-11-11 14:09               ` Eric Dumazet
2015-11-11 14:15                 ` Måns Rullgård
2015-11-11 14:35                   ` Måns Rullgård
2015-11-11 14:44                     ` Eric Dumazet
2015-11-11 14:42                   ` Eric Dumazet
2015-11-11 16:24           ` David Miller
2015-11-11 18:25             ` Måns Rullgård [this message]
2015-11-11 19:02               ` David Miller
2015-11-11 19:09                 ` Måns Rullgård
2015-11-11 19:13                   ` David Miller
2015-11-11 19:17                     ` Måns Rullgård
2015-11-11 19:19                       ` David Miller
2015-11-11 19:25                         ` Måns Rullgård
2015-11-11 19:26                           ` David Miller
2015-11-11 19:35                             ` Måns Rullgård
2015-11-11 19:48                               ` David Miller
2015-11-11 20:47                                 ` Måns Rullgård
2015-11-11 16:20         ` David Miller

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=yw1xk2poo0la.fsf@unicorn.mansr.com \
    --to=mans@mansr.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=romieu@fr.zoreil.com \
    --cc=slash.tmp@free.fr \
    /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.