Thread (2 messages) 2 messages, 2 authors, 2020-07-20

Re: [PATCH v2 net-next] net: hyperv: Add attributes to show TX indirection table

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2020-07-20 17:24:54
Also in: lkml, netdev

On Mon, 20 Jul 2020 00:12:10 -0700 (PDT)
Chi Song [off-list ref] wrote:
An imbalanced TX indirection table causes netvsc to have low
performance. This table is created and managed during runtime. To help
better diagnose performance issues caused by imbalanced tables, add
device attributes to show the content of TX indirection tables.

Signed-off-by: Chi Song <redacted>
---
quoted hunk ↗ jump to hunk
v2: remove RX as it's in ethtool already, show single value in each file,
 and update description.

Thank you for comments. Let me know, if I miss something.

---
 drivers/net/hyperv/netvsc_drv.c | 53 +++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
diff --git a/drivers/net/hyperv/netvsc_drv.c
b/drivers/net/hyperv/netvsc_drv.c
index 6267f706e8ee..222c2fad9300 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2370,6 +2370,55 @@ static int netvsc_unregister_vf(struct net_device
*vf_netdev)
 	return NOTIFY_OK;
 }

+static struct device_attribute
dev_attr_netvsc_dev_attrs[VRSS_SEND_TAB_SIZE];
+static struct attribute *netvsc_dev_attrs[VRSS_SEND_TAB_SIZE + 1];
+
+const struct attribute_group netvsc_dev_group = {
+	.name = NULL,
+	.attrs = netvsc_dev_attrs,
+};
+
+static ssize_t tx_indirection_table_show(struct device *dev,
+					 struct device_attribute
*dev_attr,
+					 char *buf)
+{
+	struct net_device *ndev = to_net_dev(dev);
+	struct net_device_context *ndc = netdev_priv(ndev);
+	ssize_t offset = 0;
useless initialization
+	int index = dev_attr - dev_attr_netvsc_dev_attrs;
+
+	offset = sprintf(buf, "%u\n", ndc->tx_table[index]);
+
+	return offset;
why not just
	return sprintf(buf, "%u\n", ndc->tx_table[index]);
+}
+
+static void netvsc_attrs_init(void)
+{
+	int i;
+	char buffer[32];
+
+	for (i = 0; i < VRSS_SEND_TAB_SIZE; i++) {
+		sprintf(buffer, "tx_indirection_table_%02u", i);
Although this has one value per file it leads to a mess.
Why not put it in a separate directory (/sys/class/net/eth0/tx_indirection/N)?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help