* [PATCH net] net: socionext: netsec: fix xdp stats accounting
@ 2019-10-11 13:45 Lorenzo Bianconi
2019-10-11 14:15 ` Ilias Apalodimas
0 siblings, 1 reply; 4+ messages in thread
From: Lorenzo Bianconi @ 2019-10-11 13:45 UTC (permalink / raw)
To: davem; +Cc: netdev, lorenzo.bianconi, ilias.apalodimas
Increment netdev rx counters even for XDP_DROP verdict. Moreover report
even tx bytes for xdp buffers (TYPE_NETSEC_XDP_TX or
TYPE_NETSEC_XDP_NDO)
Fixes: ba2b232108d3 ("net: netsec: add XDP support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
just compiled not tested on a real device
---
drivers/net/ethernet/socionext/netsec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index f9e6744d8fd6..b1c2a79899b3 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -252,7 +252,6 @@
#define NETSEC_XDP_CONSUMED BIT(0)
#define NETSEC_XDP_TX BIT(1)
#define NETSEC_XDP_REDIR BIT(2)
-#define NETSEC_XDP_RX_OK (NETSEC_XDP_PASS | NETSEC_XDP_TX | NETSEC_XDP_REDIR)
enum ring_id {
NETSEC_RING_TX = 0,
@@ -661,6 +660,7 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
bytes += desc->skb->len;
dev_kfree_skb(desc->skb);
} else {
+ bytes += desc->xdpf->len;
xdp_return_frame(desc->xdpf);
}
next:
@@ -1030,7 +1030,7 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
next:
if ((skb && napi_gro_receive(&priv->napi, skb) != GRO_DROP) ||
- xdp_result & NETSEC_XDP_RX_OK) {
+ xdp_result) {
ndev->stats.rx_packets++;
ndev->stats.rx_bytes += xdp.data_end - xdp.data;
}
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: socionext: netsec: fix xdp stats accounting
2019-10-11 13:45 [PATCH net] net: socionext: netsec: fix xdp stats accounting Lorenzo Bianconi
@ 2019-10-11 14:15 ` Ilias Apalodimas
2019-10-11 15:16 ` Ilias Apalodimas
0 siblings, 1 reply; 4+ messages in thread
From: Ilias Apalodimas @ 2019-10-11 14:15 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: davem, netdev, lorenzo.bianconi
Hi Lorenzo,
On Fri, Oct 11, 2019 at 03:45:38PM +0200, Lorenzo Bianconi wrote:
> Increment netdev rx counters even for XDP_DROP verdict. Moreover report
> even tx bytes for xdp buffers (TYPE_NETSEC_XDP_TX or
> TYPE_NETSEC_XDP_NDO)
The RX counters work fine. The TX change is causing a panic though and i am
looking into it since your patch seems harmless. In any case please don't merge
this yet
Thanks
/Ilias
> Fixes: ba2b232108d3 ("net: netsec: add XDP support")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> just compiled not tested on a real device
> ---
> drivers/net/ethernet/socionext/netsec.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
> index f9e6744d8fd6..b1c2a79899b3 100644
> --- a/drivers/net/ethernet/socionext/netsec.c
> +++ b/drivers/net/ethernet/socionext/netsec.c
> @@ -252,7 +252,6 @@
> #define NETSEC_XDP_CONSUMED BIT(0)
> #define NETSEC_XDP_TX BIT(1)
> #define NETSEC_XDP_REDIR BIT(2)
> -#define NETSEC_XDP_RX_OK (NETSEC_XDP_PASS | NETSEC_XDP_TX | NETSEC_XDP_REDIR)
>
> enum ring_id {
> NETSEC_RING_TX = 0,
> @@ -661,6 +660,7 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
> bytes += desc->skb->len;
> dev_kfree_skb(desc->skb);
> } else {
> + bytes += desc->xdpf->len;
> xdp_return_frame(desc->xdpf);
> }
> next:
> @@ -1030,7 +1030,7 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
>
> next:
> if ((skb && napi_gro_receive(&priv->napi, skb) != GRO_DROP) ||
> - xdp_result & NETSEC_XDP_RX_OK) {
> + xdp_result) {
> ndev->stats.rx_packets++;
> ndev->stats.rx_bytes += xdp.data_end - xdp.data;
> }
> --
> 2.21.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: socionext: netsec: fix xdp stats accounting
2019-10-11 14:15 ` Ilias Apalodimas
@ 2019-10-11 15:16 ` Ilias Apalodimas
2019-10-11 15:58 ` Lorenzo Bianconi
0 siblings, 1 reply; 4+ messages in thread
From: Ilias Apalodimas @ 2019-10-11 15:16 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: davem, netdev, lorenzo.bianconi
On Fri, Oct 11, 2019 at 05:15:03PM +0300, Ilias Apalodimas wrote:
> Hi Lorenzo,
>
> On Fri, Oct 11, 2019 at 03:45:38PM +0200, Lorenzo Bianconi wrote:
> > Increment netdev rx counters even for XDP_DROP verdict. Moreover report
> > even tx bytes for xdp buffers (TYPE_NETSEC_XDP_TX or
> > TYPE_NETSEC_XDP_NDO)
>
> The RX counters work fine. The TX change is causing a panic though and i am
> looking into it since your patch seems harmless. In any case please don't merge
> this yet
>
Ok i think i know what's going on.
Our clean TX routine has a netdev_completed_queue(). This is properly accounted
for on netsec_netdev_start_xmit() which calls netdev_sent_queue().
Since the XDP never had support for that you need to account for the extra bytes
in netsec_xdp_queue_one(). That's what triggering the BUG_ON
(lib/dynamic_queue_limits.c line 27)
Since netdev_completed_queue() enforces barrier() and in some cases smp_mb() i
think i'd prefer it per function, although it looks uglier.
Can you send a patch with this call in netsec_xdp_queue_one()? If we cant
measure any performance difference i am fine with adding it in that only.
Thanks
/Ilias
> Thanks
> /Ilias
>
> > Fixes: ba2b232108d3 ("net: netsec: add XDP support")
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > just compiled not tested on a real device
> > ---
> > drivers/net/ethernet/socionext/netsec.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
> > index f9e6744d8fd6..b1c2a79899b3 100644
> > --- a/drivers/net/ethernet/socionext/netsec.c
> > +++ b/drivers/net/ethernet/socionext/netsec.c
> > @@ -252,7 +252,6 @@
> > #define NETSEC_XDP_CONSUMED BIT(0)
> > #define NETSEC_XDP_TX BIT(1)
> > #define NETSEC_XDP_REDIR BIT(2)
> > -#define NETSEC_XDP_RX_OK (NETSEC_XDP_PASS | NETSEC_XDP_TX | NETSEC_XDP_REDIR)
> >
> > enum ring_id {
> > NETSEC_RING_TX = 0,
> > @@ -661,6 +660,7 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
> > bytes += desc->skb->len;
> > dev_kfree_skb(desc->skb);
> > } else {
> > + bytes += desc->xdpf->len;
> > xdp_return_frame(desc->xdpf);
> > }
> > next:
> > @@ -1030,7 +1030,7 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
> >
> > next:
> > if ((skb && napi_gro_receive(&priv->napi, skb) != GRO_DROP) ||
> > - xdp_result & NETSEC_XDP_RX_OK) {
> > + xdp_result) {
> > ndev->stats.rx_packets++;
> > ndev->stats.rx_bytes += xdp.data_end - xdp.data;
> > }
> > --
> > 2.21.0
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: socionext: netsec: fix xdp stats accounting
2019-10-11 15:16 ` Ilias Apalodimas
@ 2019-10-11 15:58 ` Lorenzo Bianconi
0 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2019-10-11 15:58 UTC (permalink / raw)
To: Ilias Apalodimas; +Cc: davem, netdev, lorenzo.bianconi
[-- Attachment #1: Type: text/plain, Size: 3067 bytes --]
> On Fri, Oct 11, 2019 at 05:15:03PM +0300, Ilias Apalodimas wrote:
> > Hi Lorenzo,
> >
> > On Fri, Oct 11, 2019 at 03:45:38PM +0200, Lorenzo Bianconi wrote:
> > > Increment netdev rx counters even for XDP_DROP verdict. Moreover report
> > > even tx bytes for xdp buffers (TYPE_NETSEC_XDP_TX or
> > > TYPE_NETSEC_XDP_NDO)
> >
> > The RX counters work fine. The TX change is causing a panic though and i am
> > looking into it since your patch seems harmless. In any case please don't merge
> > this yet
> >
>
> Ok i think i know what's going on.
> Our clean TX routine has a netdev_completed_queue(). This is properly accounted
> for on netsec_netdev_start_xmit() which calls netdev_sent_queue().
>
> Since the XDP never had support for that you need to account for the extra bytes
> in netsec_xdp_queue_one(). That's what triggering the BUG_ON
> (lib/dynamic_queue_limits.c line 27)
Hi Ilias,
yes, right. We need to account pending xdp buffer len on tx side.
>
> Since netdev_completed_queue() enforces barrier() and in some cases smp_mb() i
> think i'd prefer it per function, although it looks uglier.
> Can you send a patch with this call in netsec_xdp_queue_one()? If we cant
> measure any performance difference i am fine with adding it in that only.
If this introduce a performance penalty we can just account netdev tx_bytes
directly (maybe it is ugly)
Regards,
Lorenzo
>
> Thanks
> /Ilias
>
> > Thanks
> > /Ilias
> >
> > > Fixes: ba2b232108d3 ("net: netsec: add XDP support")
> > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > > ---
> > > just compiled not tested on a real device
> > > ---
> > > drivers/net/ethernet/socionext/netsec.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
> > > index f9e6744d8fd6..b1c2a79899b3 100644
> > > --- a/drivers/net/ethernet/socionext/netsec.c
> > > +++ b/drivers/net/ethernet/socionext/netsec.c
> > > @@ -252,7 +252,6 @@
> > > #define NETSEC_XDP_CONSUMED BIT(0)
> > > #define NETSEC_XDP_TX BIT(1)
> > > #define NETSEC_XDP_REDIR BIT(2)
> > > -#define NETSEC_XDP_RX_OK (NETSEC_XDP_PASS | NETSEC_XDP_TX | NETSEC_XDP_REDIR)
> > >
> > > enum ring_id {
> > > NETSEC_RING_TX = 0,
> > > @@ -661,6 +660,7 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
> > > bytes += desc->skb->len;
> > > dev_kfree_skb(desc->skb);
> > > } else {
> > > + bytes += desc->xdpf->len;
> > > xdp_return_frame(desc->xdpf);
> > > }
> > > next:
> > > @@ -1030,7 +1030,7 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
> > >
> > > next:
> > > if ((skb && napi_gro_receive(&priv->napi, skb) != GRO_DROP) ||
> > > - xdp_result & NETSEC_XDP_RX_OK) {
> > > + xdp_result) {
> > > ndev->stats.rx_packets++;
> > > ndev->stats.rx_bytes += xdp.data_end - xdp.data;
> > > }
> > > --
> > > 2.21.0
> > >
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-10-11 15:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-11 13:45 [PATCH net] net: socionext: netsec: fix xdp stats accounting Lorenzo Bianconi
2019-10-11 14:15 ` Ilias Apalodimas
2019-10-11 15:16 ` Ilias Apalodimas
2019-10-11 15:58 ` Lorenzo Bianconi
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).