Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2798087pxf; Sun, 21 Mar 2021 07:14:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJrIo7Xrkl5XWMswrwDliSBI2s9fpjGVTRkcDfp3YbI/ZeuXBeoD7N1+DZrlsFDeb0fq3/ X-Received: by 2002:a05:6402:518d:: with SMTP id q13mr20868666edd.313.1616336077205; Sun, 21 Mar 2021 07:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616336077; cv=none; d=google.com; s=arc-20160816; b=tWKT88VsDoKOJUwuSmbvRhAo8BQhvOaxv5CNQq+AmZz4YkGKb3wjCYDSTbNWOH7x9+ SL1zbFsHMrjR5dYgOWv0y4qiYLSS8t9g1OHNZ1h6uKE17nak7qU5qNxY24ZmT19OVCkx rXs1DgZbVlP/9VsT2soeDLr9oFH4z/3Un6mqDQJNheg62YaaNc2tlEe1MjoUByuHIamj jG2+cXR5ImSotpxsmQ1eIvDpVAm1UYE7wqXzPHit8eZDEooEOkGYyfRl5GCpaxVeCJM9 kL/2pExdtFc2KqpLrdhcIFL+oc09ESH1KB3lwMPqKx/9YnnYZ0OQF6r2fZy8AYK8ywGy ziPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HhSxOB4537drtHkVdvclY0rkLeKmA5WCwS6DBJr09w8=; b=QES7gQzHE70qGY7pM00eR7LWwKC+m57ZGNwGh3fL2+852YtoJSmQ00S1bw9ClGutYT JsmThdvCRySLEERDiT0m3xTjlWe8zSOznWjuS2gNjS3BX1owAxm18a859kxAfPCrNqWO nF6g095JoS14DdA19w8c/DNvbCE6u33nnC8mdDbuPf5arbaYE8h1OtDpiK89ZaOtUeBK 726MjC5BiN/ydarssONyOMBqClxDSbGJwgdtT1/dSIJQ4CWV1ifBzKphUQnsnE8XGWS3 LdKJ5e86LMacaiST7TahvBCuOYKUM9upniHshR4o1GeojmBi7ZG1jrL8pNM9kYWB/eEH EPLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gx22si9273381ejb.415.2021.03.21.07.14.14; Sun, 21 Mar 2021 07:14:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230011AbhCUNtw (ORCPT + 99 others); Sun, 21 Mar 2021 09:49:52 -0400 Received: from smtp07.smtpout.orange.fr ([80.12.242.129]:23755 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbhCUNtc (ORCPT ); Sun, 21 Mar 2021 09:49:32 -0400 Received: from tomoyo.flets-east.jp ([153.202.107.157]) by mwinf5d13 with ME id j1oz240023PnFJp031pT0a; Sun, 21 Mar 2021 14:49:30 +0100 X-ME-Helo: tomoyo.flets-east.jp X-ME-Auth: bWFpbGhvbC52aW5jZW50QHdhbmFkb28uZnI= X-ME-Date: Sun, 21 Mar 2021 14:49:30 +0100 X-ME-IP: 153.202.107.157 From: Vincent Mailhol To: Marc Kleine-Budde , linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Eric Dumazet , Dave Taht Cc: Peter Zijlstra , Randy Dunlap , "David S . Miller" , Jakub Kicinski , Vincent Mailhol Subject: [PATCH v3 1/1] netdev: add netdev_queue_set_dql_min_limit() Date: Sun, 21 Mar 2021 22:48:49 +0900 Message-Id: <20210321134849.463560-2-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210321134849.463560-1-mailhol.vincent@wanadoo.fr> References: <20210321134849.463560-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a function to set the dynamic queue limit minimum value. Some specific drivers might have legitimate reasons to configure dql.min_limit to a given value. Typically, this is the case when the PDU of the protocol is smaller than the packet size to used to carry those frames to the device. Concrete example: a CAN (Control Area Network) device with an USB 2.0 interface. The PDU of classical CAN protocol are roughly 16 bytes but the USB packet size (which is used to carry the CAN frames to the device) might be up to 512 bytes. Wen small traffic burst occurs, BQL algorithm is not able to immediately adjust and this would result in having to send many small USB packets (i.e packet of 16 bytes for each CAN frame). Filling up the USB packet with CAN frames is relatively fast (small latency issue) but the gain of not having to send several small USB packets is huge (big throughput increase). In this case, forcing dql.min_limit to a given value that would allow to stuff the USB packet is always a win. This function is to be used by network drivers which are able to prove through a rationale and through empirical tests on several environment (with other applications, heavy context switching, virtualization...), that they constantly reach better performances with a specific predefined dql.min_limit value with no noticeable latency impact. Signed-off-by: Vincent Mailhol --- include/linux/netdevice.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ddf4cfc12615..c3511263b15a 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3389,6 +3389,24 @@ netif_xmit_frozen_or_drv_stopped(const struct netdev_queue *dev_queue) return dev_queue->state & QUEUE_STATE_DRV_XOFF_OR_FROZEN; } +/** + * netdev_queue_set_dql_min_limit - set dql minimum limit + * @dev_queue: pointer to transmit queue + * @min_limit: dql minimum limit + * + * Forces xmit_more() to return true until the minimum threshold + * defined by @min_limit is reached (or until the tx queue is + * empty). Warning: to be use with care, misuse will impact the + * latency. + */ +static inline void netdev_queue_set_dql_min_limit(struct netdev_queue *dev_queue, + unsigned int min_limit) +{ +#ifdef CONFIG_BQL + dev_queue->dql.min_limit = min_limit; +#endif +} + /** * netdev_txq_bql_enqueue_prefetchw - prefetch bql data for write * @dev_queue: pointer to transmit queue -- 2.26.2