From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3864CA9EB6 for ; Wed, 23 Oct 2019 13:44:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97A9520663 for ; Wed, 23 Oct 2019 13:44:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cXqaHbD4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406010AbfJWNo0 (ORCPT ); Wed, 23 Oct 2019 09:44:26 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38008 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405958AbfJWNo0 (ORCPT ); Wed, 23 Oct 2019 09:44:26 -0400 Received: by mail-wm1-f67.google.com with SMTP id 3so19735855wmi.3; Wed, 23 Oct 2019 06:44:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kOZNOUL7Crs+vgeopZXTqJHfGfBbo4sRox+E2s/0PYc=; b=cXqaHbD47dElXBXIwj9WpEP9i9EEzoab/fA2mAS3AXK3Ud40BI68ZzUJNFw0DgCWo2 BMXKYDiZfdTAaYDg3b89qrRRsWL1anjp5CBsJoH2S4Pn0N+6gCjBx+D06MFJRVla86Fl HvkayEv8aCczmkCdkk0+T5Ji0N7acjbTHPjDt2Nbk/L62E06vqw1HCuSufWCV4yuCBEq w/G9aXPwbXmoA3+yFVa9N+PyFZfhH6ddrFRmLCuviRqsYhLHqfO22zAkpEFSf/tppLxh LdTEe0y9hMvEad9XoMYJukVQ75R8A+Ym7F7NG1a1E1qgd/JxrR0ST7BTJ77ydGLYGNMX 3Gnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kOZNOUL7Crs+vgeopZXTqJHfGfBbo4sRox+E2s/0PYc=; b=sFiOLtVcP93+AqTlSZqqMKkbBwOVIagvZ9RtmCYu0xYorTDdHcOwmjHzgrOAmcR79C hnceAI1TrhRYMg8WSH/SliN+i1U40VvdjQVgGArG9WPaKEfhAanK/PdwyV3b5mXYs63w IGq0AMEH9cU1lC5rdS11UF5bC00QM+QsUEzUGs/btWSWvJHIV/7CcmrKinsWDfrL7ezR 7vpR/bkTah6zhTSsfdE7ucvpSzhGsdXdEnNLKO+QzkMulFPrQklcfnCnW5QSc/7fJSt1 ggy3/1jueWj90/f3zjUPPKPJEXKUicfZdIzoVduXaQ1trYZJWDB2V8uadz46aww5SbZZ 8bIQ== X-Gm-Message-State: APjAAAWM4zHxf6gT64/MKVJqKLXC+xHg0kQHa1V+e/5+W0MxpTtp/9JG CVb5GARicQ7jgQeQvrh8fJQ= X-Google-Smtp-Source: APXvYqx/+EFhS6vLTSVsls6EmtBiRjY5ntt9y8h6qB7h3ydj8zR+dIIK8yc7NwiC9Pupk0eee4/qFg== X-Received: by 2002:a05:600c:1150:: with SMTP id z16mr6666293wmz.153.1571838264574; Wed, 23 Oct 2019 06:44:24 -0700 (PDT) Received: from VM-VPR.corporate.saft.org (i19-lef01-ix2-176-180-80-120.dsl.dyn.abo.bbox.fr. [176.180.80.120]) by smtp.gmail.com with ESMTPSA id s10sm15375553wrn.46.2019.10.23.06.44.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Oct 2019 06:44:24 -0700 (PDT) From: Vincent Prince To: mkl@pengutronix.de Cc: dave.taht@gmail.com, davem@davemloft.net, jhs@mojatatu.com, jiri@resnulli.us, kernel@pengutronix.de, linux-can@vger.kernel.org, netdev@vger.kernel.org, xiyou.wangcong@gmail.com, Vincent Prince Subject: [PATCH v5] net: sch_generic: Use pfifo_fast as fallback scheduler for CAN hardware Date: Wed, 23 Oct 2019 15:44:20 +0200 Message-Id: <1571838260-19186-1-git-send-email-vincent.prince.fr@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20190327165632.10711-1-mkl@pengutronix.de> References: <20190327165632.10711-1-mkl@pengutronix.de> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There is networking hardware that isn't based on Ethernet for layers 1 and 2. For example CAN. CAN is a multi-master serial bus standard for connecting Electronic Control Units [ECUs] also known as nodes. A frame on the CAN bus carries up to 8 bytes of payload. Frame corruption is detected by a CRC. However frame loss due to corruption is possible, but a quite unusual phenomenon. While fq_codel works great for TCP/IP, it doesn't for CAN. There are a lot of legacy protocols on top of CAN, which are not build with flow control or high CAN frame drop rates in mind. When using fq_codel, as soon as the queue reaches a certain delay based length, skbs from the head of the queue are silently dropped. Silently meaning that the user space using a send() or similar syscall doesn't get an error. However TCP's flow control algorithm will detect dropped packages and adjust the bandwidth accordingly. When using fq_codel and sending raw frames over CAN, which is the common use case, the user space thinks the package has been sent without problems, because send() returned without an error. pfifo_fast will drop skbs, if the queue length exceeds the maximum. But with this scheduler the skbs at the tail are dropped, an error (-ENOBUFS) is propagated to user space. So that the user space can slow down the package generation. On distributions, where fq_codel is made default via CONFIG_DEFAULT_NET_SCH during compile time, or set default during runtime with sysctl net.core.default_qdisc (see [1]), we get a bad user experience. In my test case with pfifo_fast, I can transfer thousands of million CAN frames without a frame drop. On the other hand with fq_codel there is more then one lost CAN frame per thousand frames. As pointed out fq_codel is not suited for CAN hardware, so this patch changes attach_one_default_qdisc() to use pfifo_fast for "ARPHRD_CAN" network devices. During transition of a netdev from down to up state the default queuing discipline is attached by attach_default_qdiscs() with the help of attach_one_default_qdisc(). This patch modifies attach_one_default_qdisc() to attach the pfifo_fast (pfifo_fast_ops) if the network device type is "ARPHRD_CAN". [1] https://github.com/systemd/systemd/issues/9194 Suggested-by: Marc Kleine-Budde Signed-off-by: Marc Kleine-Budde Signed-off-by: Vincent Prince Acked-by: Dave Taht --- Changes in v5: - add previous ack Changes in v4: - add Marc credit to commit log Changes in v3: - add description Changes in v2: - reformat patch net/sched/sch_generic.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 77b289d..dfb2982 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -1008,6 +1008,8 @@ static void attach_one_default_qdisc(struct net_device *dev, if (dev->priv_flags & IFF_NO_QUEUE) ops = &noqueue_qdisc_ops; + else if(dev->type == ARPHRD_CAN) + ops = &pfifo_fast_ops; qdisc = qdisc_create_dflt(dev_queue, ops, TC_H_ROOT, NULL); if (!qdisc) { -- 2.7.4