netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator
@ 2024-05-03 11:13 Breno Leitao
  2024-05-03 11:13 ` [PATCH net-next 2/2] IB/hfi1: Remove generic .ndo_get_stats64 Breno Leitao
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Breno Leitao @ 2024-05-03 11:13 UTC (permalink / raw)
  To: Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky
  Cc: netdev, open list:HFI1 DRIVER, open list

With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
convert veth & vrf"), stats allocation could be done on net core
instead of in this driver.

With this new approach, the driver doesn't have to bother with error
handling (allocation failure checking, making sure free happens in the
right spot, etc). This is core responsibility now.

Remove the allocation in the hfi1 driver and leverage the network
core allocation instead.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/infiniband/hw/hfi1/ipoib_main.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/ipoib_main.c b/drivers/infiniband/hw/hfi1/ipoib_main.c
index 5d814afdf7f3..59c6e55f4119 100644
--- a/drivers/infiniband/hw/hfi1/ipoib_main.c
+++ b/drivers/infiniband/hw/hfi1/ipoib_main.c
@@ -21,36 +21,25 @@ static int hfi1_ipoib_dev_init(struct net_device *dev)
 	struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev);
 	int ret;
 
-	dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
-	if (!dev->tstats)
-		return -ENOMEM;
-
 	ret = priv->netdev_ops->ndo_init(dev);
 	if (ret)
-		goto out_ret;
+		return ret;
 
 	ret = hfi1_netdev_add_data(priv->dd,
 				   qpn_from_mac(priv->netdev->dev_addr),
 				   dev);
 	if (ret < 0) {
 		priv->netdev_ops->ndo_uninit(dev);
-		goto out_ret;
+		return ret;
 	}
 
 	return 0;
-out_ret:
-	free_percpu(dev->tstats);
-	dev->tstats = NULL;
-	return ret;
 }
 
 static void hfi1_ipoib_dev_uninit(struct net_device *dev)
 {
 	struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev);
 
-	free_percpu(dev->tstats);
-	dev->tstats = NULL;
-
 	hfi1_netdev_remove_data(priv->dd, qpn_from_mac(priv->netdev->dev_addr));
 
 	priv->netdev_ops->ndo_uninit(dev);
@@ -173,9 +162,6 @@ static void hfi1_ipoib_netdev_dtor(struct net_device *dev)
 
 	hfi1_ipoib_txreq_deinit(priv);
 	hfi1_ipoib_rxq_deinit(priv->netdev);
-
-	free_percpu(dev->tstats);
-	dev->tstats = NULL;
 }
 
 static void hfi1_ipoib_set_id(struct net_device *dev, int id)
@@ -234,6 +220,7 @@ static int hfi1_ipoib_setup_rn(struct ib_device *device,
 
 	netdev->priv_destructor = hfi1_ipoib_netdev_dtor;
 	netdev->needs_free_netdev = true;
+	netdev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
 
 	return 0;
 }
-- 
2.43.0


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

* [PATCH net-next 2/2] IB/hfi1: Remove generic .ndo_get_stats64
  2024-05-03 11:13 [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator Breno Leitao
@ 2024-05-03 11:13 ` Breno Leitao
  2024-05-04 15:03   ` Simon Horman
  2024-05-05 14:16   ` Leon Romanovsky
  2024-05-04 15:03 ` [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator Simon Horman
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 8+ messages in thread
From: Breno Leitao @ 2024-05-03 11:13 UTC (permalink / raw)
  To: Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky
  Cc: netdev, open list:HFI1 DRIVER, open list

Commit 3e2f544dd8a33 ("net: get stats64 if device if driver is
configured") moved the callback to dev_get_tstats64() to net core, so,
unless the driver is doing some custom stats collection, it does not
need to set .ndo_get_stats64.

Since this driver is now relying in NETDEV_PCPU_STAT_TSTATS, then, it
doesn't need to set the dev_get_tstats64() generic .ndo_get_stats64
function pointer.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/infiniband/hw/hfi1/ipoib_main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/infiniband/hw/hfi1/ipoib_main.c b/drivers/infiniband/hw/hfi1/ipoib_main.c
index 59c6e55f4119..7c9d5203002b 100644
--- a/drivers/infiniband/hw/hfi1/ipoib_main.c
+++ b/drivers/infiniband/hw/hfi1/ipoib_main.c
@@ -96,7 +96,6 @@ static const struct net_device_ops hfi1_ipoib_netdev_ops = {
 	.ndo_uninit       = hfi1_ipoib_dev_uninit,
 	.ndo_open         = hfi1_ipoib_dev_open,
 	.ndo_stop         = hfi1_ipoib_dev_stop,
-	.ndo_get_stats64  = dev_get_tstats64,
 };
 
 static int hfi1_ipoib_mcast_attach(struct net_device *dev,
-- 
2.43.0


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

* Re: [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator
  2024-05-03 11:13 [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator Breno Leitao
  2024-05-03 11:13 ` [PATCH net-next 2/2] IB/hfi1: Remove generic .ndo_get_stats64 Breno Leitao
@ 2024-05-04 15:03 ` Simon Horman
  2024-05-05 14:10 ` Leon Romanovsky
  2024-05-05 14:10 ` Leon Romanovsky
  3 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2024-05-04 15:03 UTC (permalink / raw)
  To: Breno Leitao
  Cc: Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky, netdev,
	open list:HFI1 DRIVER, open list

On Fri, May 03, 2024 at 04:13:31AM -0700, Breno Leitao wrote:
> With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
> convert veth & vrf"), stats allocation could be done on net core
> instead of in this driver.
> 
> With this new approach, the driver doesn't have to bother with error
> handling (allocation failure checking, making sure free happens in the
> right spot, etc). This is core responsibility now.
> 
> Remove the allocation in the hfi1 driver and leverage the network
> core allocation instead.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next 2/2] IB/hfi1: Remove generic .ndo_get_stats64
  2024-05-03 11:13 ` [PATCH net-next 2/2] IB/hfi1: Remove generic .ndo_get_stats64 Breno Leitao
@ 2024-05-04 15:03   ` Simon Horman
  2024-05-05 14:16   ` Leon Romanovsky
  1 sibling, 0 replies; 8+ messages in thread
From: Simon Horman @ 2024-05-04 15:03 UTC (permalink / raw)
  To: Breno Leitao
  Cc: Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky, netdev,
	open list:HFI1 DRIVER, open list

On Fri, May 03, 2024 at 04:13:32AM -0700, Breno Leitao wrote:
> Commit 3e2f544dd8a33 ("net: get stats64 if device if driver is
> configured") moved the callback to dev_get_tstats64() to net core, so,
> unless the driver is doing some custom stats collection, it does not
> need to set .ndo_get_stats64.
> 
> Since this driver is now relying in NETDEV_PCPU_STAT_TSTATS, then, it
> doesn't need to set the dev_get_tstats64() generic .ndo_get_stats64
> function pointer.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator
  2024-05-03 11:13 [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator Breno Leitao
  2024-05-03 11:13 ` [PATCH net-next 2/2] IB/hfi1: Remove generic .ndo_get_stats64 Breno Leitao
  2024-05-04 15:03 ` [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator Simon Horman
@ 2024-05-05 14:10 ` Leon Romanovsky
  2024-05-07 10:07   ` Breno Leitao
  2024-05-05 14:10 ` Leon Romanovsky
  3 siblings, 1 reply; 8+ messages in thread
From: Leon Romanovsky @ 2024-05-05 14:10 UTC (permalink / raw)
  To: Breno Leitao
  Cc: Dennis Dalessandro, Jason Gunthorpe, netdev,
	open list:HFI1 DRIVER, open list

On Fri, May 03, 2024 at 04:13:31AM -0700, Breno Leitao wrote:
> With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
> convert veth & vrf"), stats allocation could be done on net core
> instead of in this driver.
> 
> With this new approach, the driver doesn't have to bother with error
> handling (allocation failure checking, making sure free happens in the
> right spot, etc). This is core responsibility now.
> 
> Remove the allocation in the hfi1 driver and leverage the network
> core allocation instead.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
>  drivers/infiniband/hw/hfi1/ipoib_main.c | 19 +++----------------
>  1 file changed, 3 insertions(+), 16 deletions(-)

Please use rdma-next in the PATCH subject line, when sending patches for RDMA.

Thanks

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

* Re: [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator
  2024-05-03 11:13 [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator Breno Leitao
                   ` (2 preceding siblings ...)
  2024-05-05 14:10 ` Leon Romanovsky
@ 2024-05-05 14:10 ` Leon Romanovsky
  3 siblings, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2024-05-05 14:10 UTC (permalink / raw)
  To: Dennis Dalessandro, Jason Gunthorpe, Breno Leitao
  Cc: netdev, linux-rdma, linux-kernel


On Fri, 03 May 2024 04:13:31 -0700, Breno Leitao wrote:
> With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
> convert veth & vrf"), stats allocation could be done on net core
> instead of in this driver.
> 
> With this new approach, the driver doesn't have to bother with error
> handling (allocation failure checking, making sure free happens in the
> right spot, etc). This is core responsibility now.
> 
> [...]

Applied, thanks!

[1/2] IB/hfi1: Do not use custom stat allocator
      https://git.kernel.org/rdma/rdma/c/5194947e6a3966
[2/2] IB/hfi1: Remove generic .ndo_get_stats64
      https://git.kernel.org/rdma/rdma/c/f483f6a29d4d70

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>


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

* Re: [PATCH net-next 2/2] IB/hfi1: Remove generic .ndo_get_stats64
  2024-05-03 11:13 ` [PATCH net-next 2/2] IB/hfi1: Remove generic .ndo_get_stats64 Breno Leitao
  2024-05-04 15:03   ` Simon Horman
@ 2024-05-05 14:16   ` Leon Romanovsky
  1 sibling, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2024-05-05 14:16 UTC (permalink / raw)
  To: Breno Leitao, Dennis Dalessandro
  Cc: Jason Gunthorpe, netdev, open list:HFI1 DRIVER, open list

On Fri, May 03, 2024 at 04:13:32AM -0700, Breno Leitao wrote:
> Commit 3e2f544dd8a33 ("net: get stats64 if device if driver is
> configured") moved the callback to dev_get_tstats64() to net core, so,
> unless the driver is doing some custom stats collection, it does not
> need to set .ndo_get_stats64.
> 
> Since this driver is now relying in NETDEV_PCPU_STAT_TSTATS, then, it
> doesn't need to set the dev_get_tstats64() generic .ndo_get_stats64
> function pointer.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
>  drivers/infiniband/hw/hfi1/ipoib_main.c | 1 -
>  1 file changed, 1 deletion(-)

Dennis,

Please pay attention that 3e2f544dd8a33 ("net: get stats64 if device if
driver is configured") is not in RDMA tree yet, but we are approaching
merge window and linux-next is already have it.

Thanks

> 
> diff --git a/drivers/infiniband/hw/hfi1/ipoib_main.c b/drivers/infiniband/hw/hfi1/ipoib_main.c
> index 59c6e55f4119..7c9d5203002b 100644
> --- a/drivers/infiniband/hw/hfi1/ipoib_main.c
> +++ b/drivers/infiniband/hw/hfi1/ipoib_main.c
> @@ -96,7 +96,6 @@ static const struct net_device_ops hfi1_ipoib_netdev_ops = {
>  	.ndo_uninit       = hfi1_ipoib_dev_uninit,
>  	.ndo_open         = hfi1_ipoib_dev_open,
>  	.ndo_stop         = hfi1_ipoib_dev_stop,
> -	.ndo_get_stats64  = dev_get_tstats64,
>  };
>  
>  static int hfi1_ipoib_mcast_attach(struct net_device *dev,
> -- 
> 2.43.0
> 

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

* Re: [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator
  2024-05-05 14:10 ` Leon Romanovsky
@ 2024-05-07 10:07   ` Breno Leitao
  0 siblings, 0 replies; 8+ messages in thread
From: Breno Leitao @ 2024-05-07 10:07 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Dennis Dalessandro, Jason Gunthorpe, netdev,
	open list:HFI1 DRIVER, open list

Hello Leon,

On Sun, May 05, 2024 at 05:10:32PM +0300, Leon Romanovsky wrote:
> On Fri, May 03, 2024 at 04:13:31AM -0700, Breno Leitao wrote:
> > With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
> > convert veth & vrf"), stats allocation could be done on net core
> > instead of in this driver.
> > 
> > With this new approach, the driver doesn't have to bother with error
> > handling (allocation failure checking, making sure free happens in the
> > right spot, etc). This is core responsibility now.
> > 
> > Remove the allocation in the hfi1 driver and leverage the network
> > core allocation instead.
> > 
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> > ---
> >  drivers/infiniband/hw/hfi1/ipoib_main.c | 19 +++----------------
> >  1 file changed, 3 insertions(+), 16 deletions(-)
> 
> Please use rdma-next in the PATCH subject line, when sending patches for RDMA.

Thanks for the heads-up. I will make sure I use rdma-next in the next RDMA patches.

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

end of thread, other threads:[~2024-05-07 10:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-03 11:13 [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator Breno Leitao
2024-05-03 11:13 ` [PATCH net-next 2/2] IB/hfi1: Remove generic .ndo_get_stats64 Breno Leitao
2024-05-04 15:03   ` Simon Horman
2024-05-05 14:16   ` Leon Romanovsky
2024-05-04 15:03 ` [PATCH net-next 1/2] IB/hfi1: Do not use custom stat allocator Simon Horman
2024-05-05 14:10 ` Leon Romanovsky
2024-05-07 10:07   ` Breno Leitao
2024-05-05 14:10 ` Leon Romanovsky

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).