Commit 74293ea1 authored by Breno Leitao's avatar Breno Leitao Committed by Jakub Kicinski

net: sysfs: Do not create sysfs for non BQL device

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

This also removes the #ifdefs, since we can also use netdev_uses_bql() to
check if the config is enabled. (as suggested by Jakub).
Suggested-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
Link: https://lore.kernel.org/r/20240216094154.3263843-1-leitao@debian.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f853fa5c
...@@ -1459,6 +1459,9 @@ static const struct attribute_group dql_group = { ...@@ -1459,6 +1459,9 @@ static const struct attribute_group dql_group = {
.name = "byte_queue_limits", .name = "byte_queue_limits",
.attrs = dql_attrs, .attrs = dql_attrs,
}; };
#else
/* Fake declaration, all the code using it should be dead */
extern const struct attribute_group dql_group;
#endif /* CONFIG_BQL */ #endif /* CONFIG_BQL */
#ifdef CONFIG_XPS #ifdef CONFIG_XPS
...@@ -1696,6 +1699,15 @@ static const struct kobj_type netdev_queue_ktype = { ...@@ -1696,6 +1699,15 @@ static const struct kobj_type netdev_queue_ktype = {
.get_ownership = netdev_queue_get_ownership, .get_ownership = netdev_queue_get_ownership,
}; };
static bool netdev_uses_bql(const struct net_device *dev)
{
if (dev->features & NETIF_F_LLTX ||
dev->priv_flags & IFF_NO_QUEUE)
return false;
return IS_ENABLED(CONFIG_BQL);
}
static int netdev_queue_add_kobject(struct net_device *dev, int index) static int netdev_queue_add_kobject(struct net_device *dev, int index)
{ {
struct netdev_queue *queue = dev->_tx + index; struct netdev_queue *queue = dev->_tx + index;
...@@ -1713,11 +1725,11 @@ static int netdev_queue_add_kobject(struct net_device *dev, int index) ...@@ -1713,11 +1725,11 @@ static int netdev_queue_add_kobject(struct net_device *dev, int index)
if (error) if (error)
goto err; goto err;
#ifdef CONFIG_BQL if (netdev_uses_bql(dev)) {
error = sysfs_create_group(kobj, &dql_group); error = sysfs_create_group(kobj, &dql_group);
if (error) if (error)
goto err; goto err;
#endif }
kobject_uevent(kobj, KOBJ_ADD); kobject_uevent(kobj, KOBJ_ADD);
return 0; return 0;
...@@ -1738,9 +1750,9 @@ static int tx_queue_change_owner(struct net_device *ndev, int index, ...@@ -1738,9 +1750,9 @@ static int tx_queue_change_owner(struct net_device *ndev, int index,
if (error) if (error)
return error; return error;
#ifdef CONFIG_BQL if (netdev_uses_bql(ndev))
error = sysfs_group_change_owner(kobj, &dql_group, kuid, kgid); error = sysfs_group_change_owner(kobj, &dql_group, kuid, kgid);
#endif
return error; return error;
} }
#endif /* CONFIG_SYSFS */ #endif /* CONFIG_SYSFS */
...@@ -1772,9 +1784,10 @@ netdev_queue_update_kobjects(struct net_device *dev, int old_num, int new_num) ...@@ -1772,9 +1784,10 @@ netdev_queue_update_kobjects(struct net_device *dev, int old_num, int new_num)
if (!refcount_read(&dev_net(dev)->ns.count)) if (!refcount_read(&dev_net(dev)->ns.count))
queue->kobj.uevent_suppress = 1; queue->kobj.uevent_suppress = 1;
#ifdef CONFIG_BQL
if (netdev_uses_bql(dev))
sysfs_remove_group(&queue->kobj, &dql_group); sysfs_remove_group(&queue->kobj, &dql_group);
#endif
kobject_put(&queue->kobj); kobject_put(&queue->kobj);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment