Linux USB
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: "Maciej Żenczykowski" <maze@google.com>,
	"Hiago De Franco" <hiagofranco@gmail.com>
Cc: Oliver Neukum <oneukum@suse.com>,
	Francesco Dolcini <francesco@dolcini.it>,
	davem@davemloft.net, edumazet@google.com,
	hiago.franco@toradex.com, kuba@kernel.org,
	linux-usb@vger.kernel.org, pabeni@redhat.com
Subject: Re: Question regarding CDC NCM and VNC performance issue
Date: Tue, 12 Dec 2023 10:48:01 +0100	[thread overview]
Message-ID: <4d046193-afa7-4341-b308-8b475c4e820a@suse.com> (raw)
In-Reply-To: <CANP3RGd-uMNYPNP2FYxPNL3x3RewNVR3VxZhwaii5mhQcQ7wXg@mail.gmail.com>

On 11.12.23 21:44, Maciej Żenczykowski wrote:
> On Mon, Dec 11, 2023 at 12:29 PM Hiago De Franco <hiagofranco@gmail.com> wrote:
>>
>> On Thu, Dec 07, 2023 at 08:37:09PM +0100, Maciej Żenczykowski wrote:
>>> On Thu, Dec 7, 2023 at 7:57 PM Hiago De Franco <hiagofranco@gmail.com> wrote:

Hi,

>>>> On Thu, Dec 07, 2023 at 12:07:25PM +0100, Oliver Neukum wrote:
>>>>> That suggests, but does not prove that the issue is on the host side.
>>>>> Could you post the result of "ethtool -S" after a test run? We should
>>>>> get statistics on the reasons for transmissions that way.

>>>> Finally, I changed from 8192 to 4096, and the perfomance was
>>>> better:
>>>>
>>>> $ sudo ethtool -S enx3a601e306de1
>>>> NIC statistics:
>>>>       tx_reason_ntb_full: 0
>>>>       tx_reason_ndp_full: 0
>>>>       tx_reason_timeout: 56067

This has grown two orders of magnitude.

>>>>       tx_reason_max_datagram: 0
>>>>       tx_overhead: 83630876
>>>>       tx_ntbs: 56064
>>>>       rx_overhead: 25437595
>>>>       rx_ntbs: 847920
>>>>
>>>> At 4096 I can use the VNC with my app, click on buttons and see the mouse
>>>> moving smoothly. Please note the device name changes because we're using
>>>> random MAC addresses. 'ethtool' was running on my Debian host PC. I tested
>>>> for 1min30s and then got the statics with ethtool for all 3 tests.

As you are testing for a constant time, the increase in transmissions
due to timeouts also decreases latency by two orders of magnitude.
Though this does not ultimately tell us which side is responsible.
>>>> While the flood is happening in parallel, the VNC runs very smoothly,
>>>> and, again, as soon as it stops, it's back to slow/frozen.
>>>>
>>>> I believe here the ping command is helping to fullfil the buffer, that's
>>>> why running it on parallel makes the VNC work...

Indeed. You can confirm this by running "ethool -S" before and after the ping.
During the ping tx_reason_timeout should stagnate and probably tx_reason_ndp_full
will go up.

>>>>> #define TX_TIMEOUT_NSECS 300000
>>>>> 300 us is too small to be noticeable by VNC imho, so I think something
>>>>> *must* be misbehaving.
>>>>> Perhaps timer resolution is bad and this 300us ends up being much larger...???

Now that you mention it and have taken a closer look I suspect this piece of code:

         } else if ((n < ctx->tx_max_datagrams) && (ready2send == 0) && (ctx->timer_interval > 0)) {
                 /* wait for more frames */
                 /* push variables */
                 ctx->tx_curr_skb = skb_out;
                 /* set the pending count */
                 if (n < CDC_NCM_RESTART_TIMER_DATAGRAM_CNT)
                         ctx->tx_timer_pending = CDC_NCM_TIMER_PENDING_CNT;
                 goto exit_no_skb;

Hiago, could you try lowering CDC_NCM_TIMER_PENDING_CNT, if need be all the way to 1?
It is defined in include/linux/usb/cdc_ncm.h as 3 currently
This applies to the host side.

	Regards
		Oliver

  reply	other threads:[~2023-12-12  9:48 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04 18:37 Question regarding CDC NCM and VNC performance issue Hiago De Franco
2023-12-05  9:50 ` Oliver Neukum
2023-12-05 12:22   ` Hiago De Franco
2023-12-05 12:38     ` Oliver Neukum
2023-12-05 12:55       ` Hiago De Franco
2023-12-05 20:14       ` Hiago De Franco
2023-12-06 12:21         ` Oliver Neukum
2023-12-06 16:23           ` Hiago De Franco
2023-12-07  9:41             ` Oliver Neukum
2023-12-07 10:03               ` Francesco Dolcini
2023-12-07 11:07                 ` Oliver Neukum
2023-12-07 11:38                   ` Maciej Żenczykowski
2023-12-07 18:57                     ` Hiago De Franco
2023-12-07 19:37                       ` Maciej Żenczykowski
2023-12-11 20:28                         ` Hiago De Franco
2023-12-11 20:44                           ` Maciej Żenczykowski
2023-12-12  9:48                             ` Oliver Neukum [this message]
2023-12-12 20:32                               ` Hiago De Franco
2023-12-12 21:21                                 ` Oliver Neukum
2023-12-13  1:11                                   ` Maciej Żenczykowski
2023-12-15 21:20                                     ` Hiago De Franco
2023-12-15 21:44                                       ` Maciej Żenczykowski
2023-12-18 14:34                                         ` Oliver Neukum
2023-12-18 20:59                                           ` Hiago De Franco
2023-12-18 23:00                                             ` Maciej Żenczykowski
2023-12-19  8:45                                               ` Oliver Neukum
2023-12-19 12:19                                                 ` Maciej Żenczykowski
2023-12-19 13:24                                                   ` Oliver Neukum
2023-12-19 16:25                                                     ` Maciej Żenczykowski

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=4d046193-afa7-4341-b308-8b475c4e820a@suse.com \
    --to=oneukum@suse.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=francesco@dolcini.it \
    --cc=hiago.franco@toradex.com \
    --cc=hiagofranco@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=maze@google.com \
    --cc=pabeni@redhat.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