net: sysfs: Do not create sysfs for non BQL device
authorBreno Leitao <leitao@debian.org>
Fri, 16 Feb 2024 09:41:52 +0000 (01:41 -0800)
committerJakub Kicinski <kuba@kernel.org>
Mon, 19 Feb 2024 20:30:44 +0000 (12:30 -0800)
commit74293ea1c4db62cb969e741fbfd479a34d935024
treef48de0ccdd139bd38afbec4759ff6ed02c55fbf7
parentf853fa5c54e7a0364a52125074dedeaf2c7ddace
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: Eric Dumazet <edumazet@google.com>
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://lore.kernel.org/r/20240216094154.3263843-1-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/net-sysfs.c