All of lore.kernel.org
 help / color / mirror / Atom feed
* [net-next PATCH] ixgbe: add counter for times rx pages gets allocated, not recycled
@ 2017-09-01 10:54 Jesper Dangaard Brouer
  2017-09-01 15:24 ` Alexander Duyck
  2017-09-01 19:09 ` Jeff Kirsher
  0 siblings, 2 replies; 3+ messages in thread
From: Jesper Dangaard Brouer @ 2017-09-01 10:54 UTC (permalink / raw)
  To: netdev; +Cc: Jeff Kirsher, Alexander Duyck, Jesper Dangaard Brouer

The ixgbe driver have page recycle scheme based around the RX-ring
queue, where a RX page is shared between two packets. Based on the
refcnt, the driver can determine if the RX-page is currently only used
by a single packet, if so it can then directly refill/recycle the
RX-slot by with the opposite "side" of the page.

While this is a clever trick, it is hard to determine when this
recycling is successful and when it fails.  Adding a counter, which is
available via ethtool --statistics as 'alloc_rx_page'.  Which counts
the number of times the recycle fails and the real page allocator is
invoked.  When interpreting the stats, do remember that every alloc
will serve two packets.

The counter is collected per rx_ring, but is summed and ethtool
exported as 'alloc_rx_page'.  It would be relevant to know what
rx_ring that cannot keep up, but that can be exported later if
someone experience a need for this.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe.h         |    2 ++
 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c |    1 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c    |    4 ++++
 3 files changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index dd5578756ae0..008d0085e01f 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -275,6 +275,7 @@ struct ixgbe_rx_queue_stats {
 	u64 rsc_count;
 	u64 rsc_flush;
 	u64 non_eop_descs;
+	u64 alloc_rx_page;
 	u64 alloc_rx_page_failed;
 	u64 alloc_rx_buff_failed;
 	u64 csum_err;
@@ -655,6 +656,7 @@ struct ixgbe_adapter {
 	u64 rsc_total_count;
 	u64 rsc_total_flush;
 	u64 non_eop_descs;
+	u32 alloc_rx_page;
 	u32 alloc_rx_page_failed;
 	u32 alloc_rx_buff_failed;
 
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 72c565712a5f..d96d9d6c3492 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -104,6 +104,7 @@ static const struct ixgbe_stats ixgbe_gstrings_stats[] = {
 	{"tx_flow_control_xoff", IXGBE_STAT(stats.lxofftxc)},
 	{"rx_flow_control_xoff", IXGBE_STAT(stats.lxoffrxc)},
 	{"rx_csum_offload_errors", IXGBE_STAT(hw_csum_rx_error)},
+	{"alloc_rx_page", IXGBE_STAT(alloc_rx_page)},
 	{"alloc_rx_page_failed", IXGBE_STAT(alloc_rx_page_failed)},
 	{"alloc_rx_buff_failed", IXGBE_STAT(alloc_rx_buff_failed)},
 	{"rx_no_dma_resources", IXGBE_STAT(hw_rx_no_dma_resources)},
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index d962368d08d0..7d2e4b08cdf4 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -1598,6 +1598,7 @@ static bool ixgbe_alloc_mapped_page(struct ixgbe_ring *rx_ring,
 		rx_ring->rx_stats.alloc_rx_page_failed++;
 		return false;
 	}
+	rx_ring->rx_stats.alloc_rx_page++;
 
 	/* map page for use */
 	dma = dma_map_page_attrs(rx_ring->dev, page, 0,
@@ -6771,6 +6772,7 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
 	u32 i, missed_rx = 0, mpc, bprc, lxon, lxoff, xon_off_tot;
 	u64 non_eop_descs = 0, restart_queue = 0, tx_busy = 0;
 	u64 alloc_rx_page_failed = 0, alloc_rx_buff_failed = 0;
+	u64 alloc_rx_page = 0;
 	u64 bytes = 0, packets = 0, hw_csum_rx_error = 0;
 
 	if (test_bit(__IXGBE_DOWN, &adapter->state) ||
@@ -6791,6 +6793,7 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
 	for (i = 0; i < adapter->num_rx_queues; i++) {
 		struct ixgbe_ring *rx_ring = adapter->rx_ring[i];
 		non_eop_descs += rx_ring->rx_stats.non_eop_descs;
+		alloc_rx_page += rx_ring->rx_stats.alloc_rx_page;
 		alloc_rx_page_failed += rx_ring->rx_stats.alloc_rx_page_failed;
 		alloc_rx_buff_failed += rx_ring->rx_stats.alloc_rx_buff_failed;
 		hw_csum_rx_error += rx_ring->rx_stats.csum_err;
@@ -6798,6 +6801,7 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
 		packets += rx_ring->stats.packets;
 	}
 	adapter->non_eop_descs = non_eop_descs;
+	adapter->alloc_rx_page = alloc_rx_page;
 	adapter->alloc_rx_page_failed = alloc_rx_page_failed;
 	adapter->alloc_rx_buff_failed = alloc_rx_buff_failed;
 	adapter->hw_csum_rx_error = hw_csum_rx_error;

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

* Re: [net-next PATCH] ixgbe: add counter for times rx pages gets allocated, not recycled
  2017-09-01 10:54 [net-next PATCH] ixgbe: add counter for times rx pages gets allocated, not recycled Jesper Dangaard Brouer
@ 2017-09-01 15:24 ` Alexander Duyck
  2017-09-01 19:09 ` Jeff Kirsher
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Duyck @ 2017-09-01 15:24 UTC (permalink / raw)
  To: Jesper Dangaard Brouer; +Cc: Netdev, Jeff Kirsher

On Fri, Sep 1, 2017 at 3:54 AM, Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
> The ixgbe driver have page recycle scheme based around the RX-ring
> queue, where a RX page is shared between two packets. Based on the
> refcnt, the driver can determine if the RX-page is currently only used
> by a single packet, if so it can then directly refill/recycle the
> RX-slot by with the opposite "side" of the page.
>
> While this is a clever trick, it is hard to determine when this
> recycling is successful and when it fails.  Adding a counter, which is
> available via ethtool --statistics as 'alloc_rx_page'.  Which counts
> the number of times the recycle fails and the real page allocator is
> invoked.  When interpreting the stats, do remember that every alloc
> will serve two packets.
>
> The counter is collected per rx_ring, but is summed and ethtool
> exported as 'alloc_rx_page'.  It would be relevant to know what
> rx_ring that cannot keep up, but that can be exported later if
> someone experience a need for this.
>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> ---
>  drivers/net/ethernet/intel/ixgbe/ixgbe.h         |    2 ++
>  drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c |    1 +
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c    |    4 ++++
>  3 files changed, 7 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
> index dd5578756ae0..008d0085e01f 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
> @@ -275,6 +275,7 @@ struct ixgbe_rx_queue_stats {
>         u64 rsc_count;
>         u64 rsc_flush;
>         u64 non_eop_descs;
> +       u64 alloc_rx_page;
>         u64 alloc_rx_page_failed;
>         u64 alloc_rx_buff_failed;
>         u64 csum_err;
> @@ -655,6 +656,7 @@ struct ixgbe_adapter {
>         u64 rsc_total_count;
>         u64 rsc_total_flush;
>         u64 non_eop_descs;
> +       u32 alloc_rx_page;
>         u32 alloc_rx_page_failed;
>         u32 alloc_rx_buff_failed;
>
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> index 72c565712a5f..d96d9d6c3492 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> @@ -104,6 +104,7 @@ static const struct ixgbe_stats ixgbe_gstrings_stats[] = {
>         {"tx_flow_control_xoff", IXGBE_STAT(stats.lxofftxc)},
>         {"rx_flow_control_xoff", IXGBE_STAT(stats.lxoffrxc)},
>         {"rx_csum_offload_errors", IXGBE_STAT(hw_csum_rx_error)},
> +       {"alloc_rx_page", IXGBE_STAT(alloc_rx_page)},
>         {"alloc_rx_page_failed", IXGBE_STAT(alloc_rx_page_failed)},
>         {"alloc_rx_buff_failed", IXGBE_STAT(alloc_rx_buff_failed)},
>         {"rx_no_dma_resources", IXGBE_STAT(hw_rx_no_dma_resources)},
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> index d962368d08d0..7d2e4b08cdf4 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> @@ -1598,6 +1598,7 @@ static bool ixgbe_alloc_mapped_page(struct ixgbe_ring *rx_ring,
>                 rx_ring->rx_stats.alloc_rx_page_failed++;
>                 return false;
>         }
> +       rx_ring->rx_stats.alloc_rx_page++;

So this line should be moved down past the DMA page mapping as it can
fail on some architectures. My personal preference would be to have
this placed in the lines just after the "bi" members being updated,
and before the return.

>         /* map page for use */
>         dma = dma_map_page_attrs(rx_ring->dev, page, 0,
> @@ -6771,6 +6772,7 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
>         u32 i, missed_rx = 0, mpc, bprc, lxon, lxoff, xon_off_tot;
>         u64 non_eop_descs = 0, restart_queue = 0, tx_busy = 0;
>         u64 alloc_rx_page_failed = 0, alloc_rx_buff_failed = 0;
> +       u64 alloc_rx_page = 0;
>         u64 bytes = 0, packets = 0, hw_csum_rx_error = 0;
>
>         if (test_bit(__IXGBE_DOWN, &adapter->state) ||
> @@ -6791,6 +6793,7 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
>         for (i = 0; i < adapter->num_rx_queues; i++) {
>                 struct ixgbe_ring *rx_ring = adapter->rx_ring[i];
>                 non_eop_descs += rx_ring->rx_stats.non_eop_descs;
> +               alloc_rx_page += rx_ring->rx_stats.alloc_rx_page;
>                 alloc_rx_page_failed += rx_ring->rx_stats.alloc_rx_page_failed;
>                 alloc_rx_buff_failed += rx_ring->rx_stats.alloc_rx_buff_failed;
>                 hw_csum_rx_error += rx_ring->rx_stats.csum_err;
> @@ -6798,6 +6801,7 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
>                 packets += rx_ring->stats.packets;
>         }
>         adapter->non_eop_descs = non_eop_descs;
> +       adapter->alloc_rx_page = alloc_rx_page;
>         adapter->alloc_rx_page_failed = alloc_rx_page_failed;
>         adapter->alloc_rx_buff_failed = alloc_rx_buff_failed;
>         adapter->hw_csum_rx_error = hw_csum_rx_error;
>

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

* Re: [net-next PATCH] ixgbe: add counter for times rx pages gets allocated, not recycled
  2017-09-01 10:54 [net-next PATCH] ixgbe: add counter for times rx pages gets allocated, not recycled Jesper Dangaard Brouer
  2017-09-01 15:24 ` Alexander Duyck
@ 2017-09-01 19:09 ` Jeff Kirsher
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Kirsher @ 2017-09-01 19:09 UTC (permalink / raw)
  To: Jesper Dangaard Brouer, netdev; +Cc: Alexander Duyck

[-- Attachment #1: Type: text/plain, Size: 1309 bytes --]

On Fri, 2017-09-01 at 12:54 +0200, Jesper Dangaard Brouer wrote:
> The ixgbe driver have page recycle scheme based around the RX-ring
> queue, where a RX page is shared between two packets. Based on the
> refcnt, the driver can determine if the RX-page is currently only
> used
> by a single packet, if so it can then directly refill/recycle the
> RX-slot by with the opposite "side" of the page.
> 
> While this is a clever trick, it is hard to determine when this
> recycling is successful and when it fails.  Adding a counter, which
> is
> available via ethtool --statistics as 'alloc_rx_page'.  Which counts
> the number of times the recycle fails and the real page allocator is
> invoked.  When interpreting the stats, do remember that every alloc
> will serve two packets.
> 
> The counter is collected per rx_ring, but is summed and ethtool
> exported as 'alloc_rx_page'.  It would be relevant to know what
> rx_ring that cannot keep up, but that can be exported later if
> someone experience a need for this.
> 
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>

Since Alex has a suggested change for this patch, when you resubmit v2,
can you make sure you CC intel-wired-lan mailing list, so that my
patchwork project picks up this patch?  Thanks in advance Jesper.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2017-09-01 19:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01 10:54 [net-next PATCH] ixgbe: add counter for times rx pages gets allocated, not recycled Jesper Dangaard Brouer
2017-09-01 15:24 ` Alexander Duyck
2017-09-01 19:09 ` Jeff Kirsher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.