linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 net-next] net: hyperv: Add attributes to show TX indirection table
@ 2020-07-21  4:58 Chi Song
  2020-07-21 19:21 ` Jakub Kicinski
  2020-07-21 21:54 ` Haiyang Zhang
  0 siblings, 2 replies; 5+ messages in thread
From: Chi Song @ 2020-07-21  4:58 UTC (permalink / raw)
  To: Stephen Hemminger, David Miller, Haiyang Zhang, KY Srinivasan,
	Stephen Hemminger, wei.liu, kuba, linux-hyperv
  Cc: netdev, linux-kernel

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 <chisong@microsoft.com>
---
v4: use a separated group to organize tx_indirection better, change 
 location of attributes init/exit to netvsc_drv_init/exit
v5: update variable orders
v6: update names to be more precise, remove useless assignment

Thank you all for comments, learned a lot.

 drivers/net/hyperv/netvsc_drv.c | 48 +++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 6267f706e8ee..f6ad13ed320f 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2370,6 +2370,50 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev)
 	return NOTIFY_OK;
 }
 
+static struct device_attribute dev_attr_tx_indirection_attrs[VRSS_SEND_TAB_SIZE];
+static struct attribute *tx_indirection_attrs[VRSS_SEND_TAB_SIZE + 1];
+
+const struct attribute_group tx_indirection_group = {
+	.name = "tx_indirection",
+	.attrs = tx_indirection_attrs,
+};
+
+static ssize_t tx_indirection_show(struct device *dev,
+				   struct device_attribute *dev_attr, char *buf)
+{
+	int index = dev_attr - dev_attr_tx_indirection_attrs;
+	struct net_device *ndev = to_net_dev(dev);
+	struct net_device_context *ndc = netdev_priv(ndev);
+
+	return sprintf(buf, "%u\n", ndc->tx_table[index]);
+}
+
+static void netvsc_attrs_init(void)
+{
+	char buffer[4];
+	int i;
+
+	for (i = 0; i < VRSS_SEND_TAB_SIZE; i++) {
+		sprintf(buffer, "%02u", i);
+		dev_attr_tx_indirection_attrs[i].attr.name =
+			kstrdup(buffer, GFP_KERNEL);
+		dev_attr_tx_indirection_attrs[i].attr.mode = 0444;
+		sysfs_attr_init(&dev_attr_tx_indirection_attrs[i].attr);
+
+		dev_attr_tx_indirection_attrs[i].show = tx_indirection_show;
+		tx_indirection_attrs[i] =
+			&dev_attr_tx_indirection_attrs[i].attr;
+	}
+}
+
+static void netvsc_attrs_exit(void)
+{
+	int i;
+
+	for (i = 0; i < VRSS_SEND_TAB_SIZE; i++)
+		kfree(dev_attr_tx_indirection_attrs[i].attr.name);
+}
+
 static int netvsc_probe(struct hv_device *dev,
 			const struct hv_vmbus_device_id *dev_id)
 {
@@ -2410,6 +2454,7 @@ static int netvsc_probe(struct hv_device *dev,
 
 	net->netdev_ops = &device_ops;
 	net->ethtool_ops = &ethtool_ops;
+	net->sysfs_groups[0] = &tx_indirection_group;
 	SET_NETDEV_DEV(net, &dev->device);
 
 	/* We always need headroom for rndis header */
@@ -2665,6 +2710,7 @@ static void __exit netvsc_drv_exit(void)
 {
 	unregister_netdevice_notifier(&netvsc_netdev_notifier);
 	vmbus_driver_unregister(&netvsc_drv);
+	netvsc_attrs_exit();
 }
 
 static int __init netvsc_drv_init(void)
@@ -2678,6 +2724,8 @@ static int __init netvsc_drv_init(void)
 	}
 	netvsc_ring_bytes = ring_size * PAGE_SIZE;
 
+	netvsc_attrs_init();
+
 	ret = vmbus_driver_register(&netvsc_drv);
 	if (ret)
 		return ret;
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v6 net-next] net: hyperv: Add attributes to show TX indirection table
  2020-07-21  4:58 [PATCH v6 net-next] net: hyperv: Add attributes to show TX indirection table Chi Song
@ 2020-07-21 19:21 ` Jakub Kicinski
  2020-07-21 19:24   ` Florian Fainelli
  2020-07-21 21:54 ` Haiyang Zhang
  1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2020-07-21 19:21 UTC (permalink / raw)
  To: Chi Song
  Cc: Stephen Hemminger, David Miller, Haiyang Zhang, KY Srinivasan,
	Stephen Hemminger, wei.liu, linux-hyperv, netdev, linux-kernel

On Tue, 21 Jul 2020 04:58:59 +0000 Chi Song 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 <chisong@microsoft.com>

Sorry for waiting until v6 but sysfs feel like a very strange place to
expose this. Especially under the netdev, not the bus device.

This looks like device specific state, perhaps ethtool -d is a more
appropriate place?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v6 net-next] net: hyperv: Add attributes to show TX indirection table
  2020-07-21 19:21 ` Jakub Kicinski
@ 2020-07-21 19:24   ` Florian Fainelli
  2020-07-22 23:42     ` Chi Song
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Fainelli @ 2020-07-21 19:24 UTC (permalink / raw)
  To: Jakub Kicinski, Chi Song
  Cc: Stephen Hemminger, David Miller, Haiyang Zhang, KY Srinivasan,
	Stephen Hemminger, wei.liu, linux-hyperv, netdev, linux-kernel

On 7/21/20 12:21 PM, Jakub Kicinski wrote:
> On Tue, 21 Jul 2020 04:58:59 +0000 Chi Song 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 <chisong@microsoft.com>
> 
> Sorry for waiting until v6 but sysfs feel like a very strange place to
> expose this. Especially under the netdev, not the bus device.
> 
> This looks like device specific state, perhaps ethtool -d is a more
> appropriate place?

Agreed, or a devlink resource maybe?
-- 
Florian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH v6 net-next] net: hyperv: Add attributes to show TX indirection table
  2020-07-21  4:58 [PATCH v6 net-next] net: hyperv: Add attributes to show TX indirection table Chi Song
  2020-07-21 19:21 ` Jakub Kicinski
@ 2020-07-21 21:54 ` Haiyang Zhang
  1 sibling, 0 replies; 5+ messages in thread
From: Haiyang Zhang @ 2020-07-21 21:54 UTC (permalink / raw)
  To: Chi Song, Stephen Hemminger, David Miller, KY Srinivasan,
	Stephen Hemminger, wei.liu, kuba, linux-hyperv
  Cc: netdev, linux-kernel



> -----Original Message-----
> From: Chi Song <Song.Chi@microsoft.com>
> Sent: Tuesday, July 21, 2020 12:59 AM
> To: Stephen Hemminger <stephen@networkplumber.org>; David Miller
> <davem@davemloft.net>; Haiyang Zhang <haiyangz@microsoft.com>; KY
> Srinivasan <kys@microsoft.com>; Stephen Hemminger
> <sthemmin@microsoft.com>; wei.liu@kernel.org; kuba@kernel.org; linux-
> hyperv@vger.kernel.org
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH v6 net-next] net: hyperv: Add attributes to show TX indirection
> table
> 
> 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 <chisong@microsoft.com>

Thanks you!
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v6 net-next] net: hyperv: Add attributes to show TX indirection table
  2020-07-21 19:24   ` Florian Fainelli
@ 2020-07-22 23:42     ` Chi Song
  0 siblings, 0 replies; 5+ messages in thread
From: Chi Song @ 2020-07-22 23:42 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Jakub Kicinski, Chi Song, Stephen Hemminger, David Miller,
	Haiyang Zhang, KY Srinivasan, Stephen Hemminger, wei.liu,
	linux-hyperv, netdev, linux-kernel



On Tue, 21 Jul 2020, Florian Fainelli wrote:

> On 7/21/20 12:21 PM, Jakub Kicinski wrote:
> > On Tue, 21 Jul 2020 04:58:59 +0000 Chi Song 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 <chisong@microsoft.com>
> >
> > Sorry for waiting until v6 but sysfs feel like a very strange place to
> > expose this. Especially under the netdev, not the bus device.
> >
> > This looks like device specific state, perhaps ethtool -d is a more
> > appropriate place?
>
> Agreed, or a devlink resource maybe?

Thank you for comments, I will move it to ethtool.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-22 23:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21  4:58 [PATCH v6 net-next] net: hyperv: Add attributes to show TX indirection table Chi Song
2020-07-21 19:21 ` Jakub Kicinski
2020-07-21 19:24   ` Florian Fainelli
2020-07-22 23:42     ` Chi Song
2020-07-21 21:54 ` Haiyang Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).