From owner-svn-src-all@freebsd.org  Mon Apr 29 21:14:23 2019
Return-Path: <owner-svn-src-all@freebsd.org>
Delivered-To: svn-src-all@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4802B159E443;
 Mon, 29 Apr 2019 21:14:23 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from smtp.freebsd.org (smtp.freebsd.org
 [IPv6:2610:1c1:1:606c::24b:4])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "smtp.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id E2C5275978;
 Mon, 29 Apr 2019 21:14:22 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from John-Baldwins-MacBook-Pro-3.local (ralph.baldwin.cx
 [66.234.199.215])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client did not present a certificate) (Authenticated sender: jhb)
 by smtp.freebsd.org (Postfix) with ESMTPSA id E82B411244;
 Mon, 29 Apr 2019 21:14:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Subject: Re: svn commit: r341586 - head/sys/dev/mlx5/mlx5_en
To: slavash@FreeBSD.org, Hans Petter Selasky <hps@selasky.org>,
 "Andrey V. Elsukov" <bu7cher@yandex.ru>, src-committers@freebsd.org,
 svn-src-all@freebsd.org, svn-src-head@freebsd.org
References: <201812051425.wB5EP38T004562@repo.freebsd.org>
 <a1ff0879-abae-25c5-9350-809186d2cf85@yandex.ru>
 <bc601976-7d6b-f849-0305-66feb11a7130@selasky.org>
 <7cea5305-4136-a0b6-487b-51307b1c6db9@FreeBSD.org>
 <123654bf-59f7-1db8-55ce-36306bdac43d@FreeBSD.org>
From: John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q3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO
 EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz
 hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX
 sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16
 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH
 aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx
 Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I
 SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf
 afMAg8QvmOWnHx3wl8WslCaXaE8=
Message-ID: <67b638e0-8e6f-f960-b263-62eed8ce28b7@FreeBSD.org>
Date: Mon, 29 Apr 2019 14:14:19 -0700
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0)
 Gecko/20100101 Thunderbird/60.6.1
MIME-Version: 1.0
In-Reply-To: <123654bf-59f7-1db8-55ce-36306bdac43d@FreeBSD.org>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Rspamd-Queue-Id: E2C5275978
X-Spamd-Bar: --
Authentication-Results: mx1.freebsd.org
X-Spamd-Result: default: False [-2.92 / 15.00];
 local_wl_from(0.00)[FreeBSD.org];
 NEURAL_HAM_MEDIUM(-1.00)[-0.999,0];
 NEURAL_HAM_LONG(-1.00)[-0.999,0];
 NEURAL_HAM_SHORT(-0.92)[-0.918,0];
 ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "SVN commit messages for the entire src tree \(except for &quot;
 user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all/>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 29 Apr 2019 21:14:23 -0000

On 4/25/19 12:10 AM, Slava Shwartsman wrote:
> 
> 
> On 17-Apr-19 00:28, John Baldwin wrote:
>> On 4/16/19 8:32 AM, Hans Petter Selasky wrote:
>>> On 4/16/19 4:39 PM, Andrey V. Elsukov wrote:
>>>> On 05.12.2018 17:25, Slava Shwartsman wrote:
>>>>> Author: slavash
>>>>> Date: Wed Dec  5 14:25:03 2018
>>>>> New Revision: 341586
>>>>> URL: https://svnweb.freebsd.org/changeset/base/341586
>>>>>
>>>>> Log:
>>>>>     mlx5en: Implement backpressure indication.
>>>>>     
>>>>>     The backpressure indication is implemented using an unlimited rate type of
>>>>>     mbuf send tag. When the upper layers typically the socket layer has obtained such
>>>>>     a tag, it can then query the destination driver queue for the current
>>>>>     amount of space available in the send queue.
>>>>>     
>>>>>     A single mbuf send tag may be referenced multiple times and a refcount has been added
>>>>>     to the mlx5e_priv structure to track its usage. Because the send tag resides
>>>>>     in the mlx5e_channel structure, there is no need to wait for refcounts to reach
>>>>>     zero until the mlx4en(4) driver is detached. The channels structure is persistant
>>>>>     during the lifetime of the mlx5en(4) driver it belongs to and can so be accessed
>>>>>     without any need of synchronization.
>>>>>     
>>>>>     The mlx5e_snd_tag structure was extended to contain a type field, because there are now
>>>>>     two different tag types which end up in the driver which need to be distinguished.
>>>>>     
>>>>>     Submitted by:   hselasky@
>>>>>     Approved by:    hselasky (mentor)
>>>>>     MFC after:      1 week
>>>>>     Sponsored by:   Mellanox Technologies
>>>>> @@ -587,27 +609,33 @@ mlx5e_xmit(struct ifnet *ifp, struct mbuf *mb)
>>>>>    	struct mlx5e_sq *sq;
>>>>>    	int ret;
>>>>>    
>>>>> -	sq = mlx5e_select_queue(ifp, mb);
>>>>> -	if (unlikely(sq == NULL)) {
>>>>> -#ifdef RATELIMIT
>>>>> -		/* Check for route change */
>>>>> -		if (mb->m_pkthdr.snd_tag != NULL &&
>>>>> -		    mb->m_pkthdr.snd_tag->ifp != ifp) {
>>>>> +	if (mb->m_pkthdr.snd_tag != NULL) {
>>>>> +		sq = mlx5e_select_queue_by_send_tag(ifp, mb);
>>>>> +		if (unlikely(sq == NULL)) {
>>>>> +			/* Check for route change */
>>>>> +			if (mb->m_pkthdr.snd_tag->ifp != ifp) {
>>>>> +				/* Free mbuf */
>>>>> +				m_freem(mb);
>>>>> +
>>>>> +				/*
>>>>> +				 * Tell upper layers about route
>>>>> +				 * change and to re-transmit this
>>>>> +				 * packet:
>>>>> +				 */
>>>>> +				return (EAGAIN);
>>>>> +			}
>>>>
>>>> Hi,
>>>>
>>>> I just discovered something strange and found that this commit is the
>>>> cause.
>>>> The test system has mlx5en 100G interface. It has two vlans: vlan500 and
>>>> vlan100.
>>>> Via vlan500 it receives some packets flows. Then it routes these packets
>>>> into vlan100.
>>>> But packets are dropped in mlx5e_xmit() with EAGAIN error code.
>>>>
>>>> # dtrace -n 'fbt::ip6_output:return {printf("%d", arg1);}'
>>>> dtrace: description 'fbt::ip6_output:return ' matched 1 probe
>>>> CPU     ID                    FUNCTION:NAME
>>>>    23  54338                ip6_output:return 35
>>>>    16  54338                ip6_output:return 35
>>>>    21  54338                ip6_output:return 35
>>>>    22  54338                ip6_output:return 35
>>>>    24  54338                ip6_output:return 35
>>>>    23  54338                ip6_output:return 35
>>>>    14  54338                ip6_output:return 35
>>>> ^C
>>>>
>>>> # dtrace -n 'fbt::mlx5e_xmit:return {printf("%d", arg1);}'
>>>> dtrace: description 'fbt::mlx5e_xmit:return ' matched 1 probe
>>>> CPU     ID                    FUNCTION:NAME
>>>>    16  69030                mlx5e_xmit:return 35
>>>>    23  69030                mlx5e_xmit:return 35
>>>>    26  69030                mlx5e_xmit:return 35
>>>>    25  69030                mlx5e_xmit:return 35
>>>>    24  69030                mlx5e_xmit:return 35
>>>>    21  69030                mlx5e_xmit:return 35
>>>>    26  69030                mlx5e_xmit:return 35
>>>> ^C
>>>>
>>>> The kernel config is GENERIC.
>>>> 13.0-CURRENT #9 r345758+82f3d57(svn_head)-dirty
>>>>
>>>
>>> Hi,
>>>
>>> This might be a case where rcvif in the mbuf's pktheader is not cleared
>>> before the packet is fed back on the wire.
>>>
>>> John Baldwin is working on the send tags implementation, to eliminate
>>> the EAGAIN handling in the network drivers.
>>
>> I will try to push this branch sooner then since it affects more than just
>> TLS.  Part of the change includes a new flag we can use to assert that we
> Thanks John!
>> aren't just getting a stale rcvif (though there are also now assertions in
>> ip_output that should catch this case I think).
>>
> 
> 
> 
> Hi Andrey,
> 
> Yes, we were able to reproduce this issue in house. If you don't mind, I 
> prefer to wait for John's update - where he eliminates the EAGAIN 
> handling in the network drivers.

I have rebased the branch for this, but for now it will just panic sooner
I believe by tripping an assertion.  Can you grab the diff (or just the branch)
from the 'send_tags' branch at github/bsdjhb/freebsd and reproduce under a
kernel with INVARIANTS?  I think we will have to explicitly clear the 'rcvif'
pointer somewhere, but I want to see what the stack trace looks like so I can
think about the "right" place to clear it.

-- 
John Baldwin