Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp399192rdb; Thu, 15 Feb 2024 03:52:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXfngb7LSp5cUwFQh4YRuRwT96XW6oCA6V2Py2MfyADUkAXVBfN3zq/F+OcO7SULdc84ZS89PpIszMjrpCqSRot/+ZM6l+jlWMOVbyQUA== X-Google-Smtp-Source: AGHT+IF/G+XE72mfFeqnXmX2ZRqRnE//T8XjKiE2b1+Ye4GvJgRIpsva8rLD8u7CdEMNzLytrhyK X-Received: by 2002:a05:6e02:58b:b0:363:e21e:f3c5 with SMTP id c11-20020a056e02058b00b00363e21ef3c5mr1497891ils.4.1707997962842; Thu, 15 Feb 2024 03:52:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707997962; cv=pass; d=google.com; s=arc-20160816; b=IF6qb5+F/w2rLdk+/Ljau6Z3GGVsZbuqM3ML9xOjcveSa2+V75gpbM+YLHQF0hVhAy Al9Aj0UTVe7Y6ZSbrUL88IINa9Bn2S5zxScxddtt7Wr8/v6OV//P9xqk60IiCxqGh8K8 FyO+or+4QRHdT4u+TSyazpxRTNXDrC3iNjc9RbQjVk2bioLu/Q/eJNsahfwbtC2KoGmD oOhU0N1g4kzjNc9Rfzv0SrKuXA60STO8VLDX6xkJOUsfaj4FiOn5zWHKgv6s8WUv/e+6 BCBPdEi+L8caUo721O02eMIq/2n754N5seHhQkVoYS4UWzdwU54LRzZ6Aklwm0CqhiSh n6EQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=5Y09j1ngc6D4JfQjGhKOAspK/YYGYWEbXTOGP8EVOtw=; fh=YMJkLiWKIDNUjN6GacPIOsEAKR1hI+DlXcKJnm8K7do=; b=SVCV7eeBYWR5P7psGzb0k8SCibEs+UIgLqasDtJ3O/GSL0mQ+K9W+3Nf3p3Si3BaOh JwhS8xg5KkDSvBI3tTjsmaG7ZMZTuSOcVHxNPpg2VOc/Dg289A1VdejGabvgGNTY8FLY bgJJXcOvYEmyoBA/P9OFnTsAFX9hTHH7D4RyM3C1fG0442G7xhpBqRgLecfgougKtuu0 grBoiqFitArxc70w6aWu6LbPRWYFdUoy0Uuyk0Lr2s+1VMRy4oeNslmolPlDgzDYL8Vo BvnM4GCq0YJ5heZfL6cHpCwGjCoDQSniAT+Dm/cMrOWz5m2g/qaZvFD3ZfsW67RgCnvx GUog==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-66790-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66790-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r185-20020a632bc2000000b005dc957fe128si981224pgr.74.2024.02.15.03.52.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 03:52:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66790-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-66790-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66790-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6BCDE291CFF for ; Thu, 15 Feb 2024 11:28:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03D8E12B16D; Thu, 15 Feb 2024 11:28:22 +0000 (UTC) Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C421612AADB; Thu, 15 Feb 2024 11:28:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707996501; cv=none; b=XbzfzNm34l6qFzEOn9M5Wjnp2CJXiamcOnTrhBzP+x2EyNSwVJoYMMl70Z8GF1tYrSW9E3LR5i0y8rLL4v8+UMxcYoxG7HaqPK7oCf4vbIIlisJyXO569npS+AHcijzRIwJLkqJSZ1uSYCBmn4o2wdV8dwYIQ4Q/lncDo5ZUBXs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707996501; c=relaxed/simple; bh=Dp+Cq84Wj+5NY9LGhzGsuOIbQ+NVEu+tERFpSmpZ9PI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=bx3MqfVcB3cuyoprteJ0c8fstmdiSvROFBK8wJaRhutS5URnC0WZtI4ZT1HzaJlo6WJgFtcWD8M+tORc2ZXy+HZZ/4HtC20jBt2d/q5q6WzxRGST79FhGcan/e/m4k7/UWANlPwKPorVdS4tSYluBb/BiLNzWmncDCRtMqXGMZE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-563b7b3e3ecso436640a12.0; Thu, 15 Feb 2024 03:28:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707996498; x=1708601298; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5Y09j1ngc6D4JfQjGhKOAspK/YYGYWEbXTOGP8EVOtw=; b=OGL4QzOIv1+H2KjlM/e3aEDGxkgPn/8pZDIxwmEjU7SspwRICD6htjVHlWH/8T5siy 55FZsB3DPAl1E07INN3IuOfUlgeUN9sL3IjU02hxyHpQIEffnEXKNoQjRWXqf0+U4jcB mV75lvbO4iriXwlzvqX/bVo4WfxzKqlGG0xYjFJ9m5ifQrxz61Qqkm/lFBFayowhBQVR td1sVSmZQ++zaF8QGGGoCGaXoz44qSr9lOJzVWl3rFs6suv49CB2eaFtZaH9S/P314d9 QuoIKw3h0k1tJ+izfwbl3+nakOAiI5QH2l4T2+tJDI+tuEVRfqX6OQ7DgTfPgM7mj0yz K3lQ== X-Forwarded-Encrypted: i=1; AJvYcCVYPZ3qfME41O0FIObKVrSL+D4mtVaCy1rKDrh6Parbcq5dUXnd2KqTNZO4n2FSWUp+eJv2tpS1uEAf+Y5TNUYGdsFaiznEtvG8VcKv X-Gm-Message-State: AOJu0YxenkwZGGnrdwHAEV+pLL3uCcxrEI5fNHEXMfXM/sDLubHwHRUL vJtUliIADxmPLEgUpPEnptOr5grKpYFLbTekF4ozk7hF1N8q+1nV X-Received: by 2002:a50:fb03:0:b0:55c:7b3b:5990 with SMTP id d3-20020a50fb03000000b0055c7b3b5990mr932623edq.7.1707996497835; Thu, 15 Feb 2024 03:28:17 -0800 (PST) Received: from localhost (fwdproxy-lla-009.fbsv.net. [2a03:2880:30ff:9::face:b00c]) by smtp.gmail.com with ESMTPSA id eo14-20020a056402530e00b005621a9b09fbsm447312edb.41.2024.02.15.03.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 03:28:17 -0800 (PST) From: Breno Leitao To: kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org, Johannes Berg , Amritha Nambiar Subject: [PATCH net-next] net: sysfs: Do not create sysfs for non BQL device Date: Thu, 15 Feb 2024 03:27:27 -0800 Message-Id: <20240215112729.1778958-1-leitao@debian.org> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Creation of sysfs entries is expensive, mainly for workloads that constantly creates netdev and netns often. Do not create BQL sysfs entries for devices that don't need, basically those that do not have a real queue, i.e, devices that has NETIF_F_LLTX and IFF_NO_QUEUE, such as `lo` interface. This will remove the /sys/class/net/eth0/queues/tx-X/byte_queue_limits/ directory for these devices. In the example below, eth0 has the `byte_queue_limits` directory but not `lo`. # ls /sys/class/net/lo/queues/tx-0/ traffic_class tx_maxrate tx_timeout xps_cpus xps_rxqs # ls /sys/class/net/eth0/queues/tx-0/byte_queue_limits/ hold_time inflight limit limit_max limit_min Suggested-by: Eric Dumazet Signed-off-by: Breno Leitao --- net/core/net-sysfs.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index a09d507c5b03..c79bc11a0347 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1417,6 +1417,15 @@ static ssize_t bql_show_inflight(struct netdev_queue *queue, return sysfs_emit(buf, "%u\n", dql->num_queued - dql->num_completed); } +static bool netdev_uses_bql(struct net_device *dev) +{ + if (dev->features & NETIF_F_LLTX || + dev->priv_flags & IFF_NO_QUEUE) + return false; + + return true; +} + static struct netdev_queue_attribute bql_inflight_attribute __ro_after_init = __ATTR(inflight, 0444, bql_show_inflight, NULL); @@ -1709,9 +1718,11 @@ static int netdev_queue_add_kobject(struct net_device *dev, int index) goto err; #ifdef CONFIG_BQL - error = sysfs_create_group(kobj, &dql_group); - if (error) - goto err; + if (netdev_uses_bql(dev)) { + error = sysfs_create_group(kobj, &dql_group); + if (error) + goto err; + } #endif kobject_uevent(kobj, KOBJ_ADD); @@ -1734,7 +1745,8 @@ static int tx_queue_change_owner(struct net_device *ndev, int index, return error; #ifdef CONFIG_BQL - error = sysfs_group_change_owner(kobj, &dql_group, kuid, kgid); + if (netdev_uses_bql(ndev)) + error = sysfs_group_change_owner(kobj, &dql_group, kuid, kgid); #endif return error; } @@ -1768,7 +1780,8 @@ netdev_queue_update_kobjects(struct net_device *dev, int old_num, int new_num) if (!refcount_read(&dev_net(dev)->ns.count)) queue->kobj.uevent_suppress = 1; #ifdef CONFIG_BQL - sysfs_remove_group(&queue->kobj, &dql_group); + if (netdev_uses_bql(dev)) + sysfs_remove_group(&queue->kobj, &dql_group); #endif kobject_put(&queue->kobj); } -- 2.39.3