Received: by 10.213.65.68 with SMTP id h4csp36059imn; Wed, 21 Mar 2018 11:45:10 -0700 (PDT) X-Google-Smtp-Source: AG47ELu4yWwP2SzVa6AZbqce/+SkdRKNw0yZ9DFoEsQn6gqna/eYT7NBX6jRDWEv0JqSQjDqybhT X-Received: by 10.98.137.90 with SMTP id v87mr17840162pfd.80.1521657910075; Wed, 21 Mar 2018 11:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521657910; cv=none; d=google.com; s=arc-20160816; b=blgx3zRvkwBtajDFwnF6M5heO4+Xr+StaJ0Vkj9M1I49yWx4oE9Vt38lYdMnben4hX K0xA3dh12HcTkDbryeuWrMKYC4MtHBlzBy6Qh+3qasE7r5AuVPUQ2enfb4LcT/fv7xk1 6GAI6XGJbLkU7jKQTTkjiw1Rbc9zTd8ZPOdlOBsoH8tJkHyHW+2T6NmZ+f0kgmHHVita 3Q7sRTT6dwbJqVJ/weA5r6CCzh8nbOj7su9OYx384e5hVg7mf7LSjR2fYUG6vdHI6tYG WMg4w2C2n0ZXwaewn9r8OyUr74PzvQKNOXKiN53CBJY4AqMcwjoHKtd4A/lx/GoyEYID yn3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=G4bFh8HD4g3DzlAllS3LbAo3NThmux9JSWbIgrMUX6Q=; b=o/ylOJwwqXXW4W3xCTtOMz/w3hf9shKWaethFIOSW1TnFT5w9ccErlZVw6RtYryXKu iyWXLBnwdd/FLPyWaCG67GxQ/5GPi4RyE40E+WdgU7T06nxwZ5wmOlM8TOCGqSdKY8ou 5ouZKERynIIs0y7X/Qko1xl+O4ZxHqP/ui4souXMqdajL/Aim6/+fXk6LuMjoNds8CjL 4DJ7LGp3MZXQ9kCCmX9olZxSRZ7CvENKYU7i3W5ojniYurTMwNjS+7+XFzxpO5zZjvj6 BWMNaFHu8vXemWdaAPLA2ApfwN0WwqH8AcDEhR60Y+g78fJa/kso0NWrjb0jQuFMTZk6 YXDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZNJC7dLU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z16-v6si4768013pll.36.2018.03.21.11.44.47; Wed, 21 Mar 2018 11:45:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZNJC7dLU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752798AbeCUSnX (ORCPT + 99 others); Wed, 21 Mar 2018 14:43:23 -0400 Received: from mail-pl0-f49.google.com ([209.85.160.49]:44035 "EHLO mail-pl0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752616AbeCUSnT (ORCPT ); Wed, 21 Mar 2018 14:43:19 -0400 Received: by mail-pl0-f49.google.com with SMTP id 9-v6so3666978ple.11; Wed, 21 Mar 2018 11:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=G4bFh8HD4g3DzlAllS3LbAo3NThmux9JSWbIgrMUX6Q=; b=ZNJC7dLUhjMTvy+PcarYa8/F54zybUkvJftFzEXESG1pl1huz/HyaQ4/B5CJDj3USi pa8Si6lBQy7OsQctaSlLrSNJtja1IoGiao1NXQJ28luMa0xmh7kujL9RxWBj1s2pyz8v PH/uvfuDzC7Ixy+MS+0LCsfI0X/x7VwR9Gmfh0YB2WNZ8VKryF0iOkpy7DtGHDKp19GW 83GuaaKvAg7Agd+GV5yaEhVXAPC2JfF8d1TBNQLj9Cyr1O0D2a05+posRRNEj3q6MP73 aqHLYK7egOVPrKnsjV/ZVFZ1nqAs/4MhuZQA5q2C8BeLav1UP1sbQjrAU9qrQHj6owGl FiOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=G4bFh8HD4g3DzlAllS3LbAo3NThmux9JSWbIgrMUX6Q=; b=lf83N0P14EnLue3ErMa8dCuvSvz29nyyo4xLb8KcnqXj4jEF8kmQAYrzd4c+Ul7rDI NY/E+JjbPv7xJ7GM+9IhxW5Fwa2SqltDf11ZE2M6+99f+ydUU2faXoeGBd8/ZJj1RO6S FWrbSFE2IvRjxolWlNrJ0W7mKB8R2ciAjoCzwHvnk5q+O3t9gQ3ke48y1VdQZOCfYznU gKLeKT0DORaIVTj5P0JW7GzSLIH0ovnmMtzG4XbBiITq+TqicTW9Kvoe7Cok7aiZKxNv MNUh53qAN2SiGLJHAfT12DaH4L/LxIrJmdtbURE2KGGnRCzcYUtBLrLZoZmpwAT3gFkg g+fQ== X-Gm-Message-State: AElRT7EXZtD0eAqgT+S00Tf0aI0iw4bRrIyi2lXAgb54xoC3Lmbm9zAw T/dmxDMeP6eQjpArUBGEkYU= X-Received: by 2002:a17:902:6bca:: with SMTP id m10-v6mr14267862plt.387.1521657798588; Wed, 21 Mar 2018 11:43:18 -0700 (PDT) Received: from [192.168.86.235] ([75.106.27.153]) by smtp.gmail.com with ESMTPSA id o66sm10790797pfg.90.2018.03.21.11.43.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Mar 2018 11:43:17 -0700 (PDT) Subject: Re: [bug, bisected] pfifo_fast causes packet reordering To: Jakob Unterwurzacher , Dave Taht Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "David S. Miller" , "linux-can@vger.kernel.org" , Martin Elshuber References: <946dbe16-a2eb-eca8-8069-468859ccc78d@theobroma-systems.com> <95844480-d020-9000-53ef-0da8b965ce6e@gmail.com> <3a959e50-8656-5d9c-97b9-227d733948f8@theobroma-systems.com> <5aeb54ba-2d96-4ab5-53c4-2d3691be7acc@gmail.com> <340a6c54-6031-5522-98f5-eafdd3a37a38@theobroma-systems.com> <00cc2d41-6861-9a9c-603f-ba8013b2e2ce@theobroma-systems.com> From: John Fastabend Message-ID: <4e33aae4-9e87-22b4-7f09-008183ea553a@gmail.com> Date: Wed, 21 Mar 2018 11:43:04 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <00cc2d41-6861-9a9c-603f-ba8013b2e2ce@theobroma-systems.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/21/2018 03:01 AM, Jakob Unterwurzacher wrote: > On 16.03.18 11:26, Jakob Unterwurzacher wrote: >> On 15.03.18 23:30, John Fastabend wrote: >>>> I have reproduced it using two USB network cards connected to each other. The test tool sends UDP packets containing a counter and listens on the other interface, it is available at >>>> https://github.com/jakob-tsd/pfifo_stress/blob/master/pfifo_stress.py >>> >>> Great thanks, can you also run this with taskset to bind to >>> a single CPU, >>> >>>   # taskset 0x1 ./pifof_stress.py >>> >>> And let me know if you still see the OOO. >> >> Interesting. Looks like it depends on which core it runs on. CPU0 is clean, CPU1 is not. > > So we are at v4.16-rc6 now - have you managed to reproduce this is or should I try to get the revert correct? I have a theory on what is going on here. Because we now run without locks we can have multiple qdisc_run() calls running in parallel. Possible if we send packets using multiple cores. --- application --- cpu0 cpu1 | | | | enqueue enqueue | | pfifo_fast | | dequeue dequeue \ / ndo_xmit The skb->ooo_okay flag will keep the enqueue side packets in order. So that is covered. But on the dequeue side if two cores dequeue in parallel we will race to ndo ops to ensure packets are in order. Rarely, I guess the second dequeue could actually call ndo hook before first dequeued packet. Because usually the dequeue happens on the same queue the enqueue happened on we don't see this very often. But there seems to be a case where the driver calls netif_tx_wake_queue() on a different core (from the rx interrupt context). The wake queue call then eventually runs the dequeue on a different core. So when taskset is aligned with the interrupt everything is in-order when it is moved to a different core we see the OOO. Thats my theory at least. Are you able to test a patch if I generate one to fix this? FWIW the revert on this is trivial, but I think we can fix this without too much work. Also, if you had a driver tx queue per core this would not be an issue. diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 190570f..171f470 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -792,7 +792,6 @@ struct Qdisc_ops pfifo_fast_ops __read_mostly = { .dump = pfifo_fast_dump, .change_tx_queue_len = pfifo_fast_change_tx_queue_len, .owner = THIS_MODULE, - .static_flags = TCQ_F_NOLOCK | TCQ_F_CPUSTATS, }; EXPORT_SYMBOL(pfifo_fast_ops); > > Best regards, > Jakob