Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantQuoted 104 lines
-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of Paul Durrant
Sent: 26 March 2014 18:16
To: Sander Eikelenboom
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 18:08
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 7 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Wednesday, March 26, 2014, 6:46:06 PM, you wrote:
Quoted 15 lines
Quoted 7 lines
Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 7 lines
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy"while
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" butshortly
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
after
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 7 lines
Quoted 7 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);Quoted 12 lines
Quoted 4 lines
Quoted 2 lines
in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Yes
Quoted 5 lines
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimatingthen
Quoted 20 lines
the
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.It's seem to be the last ..
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
net_rx_action()calculated we would need 4 slots .. and sco-Quoted 1 line
meta_slots_used== 4 when we return so it doesn't trigger youBUG_ON..
Quoted 5 lines
The 4 slots we calculated are:
1 slot for the data part: DIV_ROUND_UP(offset_in_page(skb->data) +skb_headlen(skb),PAGE_SIZE)
2 slots for the single frag in this SKB from: DIV_ROUND_UP(size,
Quoted 7 lines
PAGE_SIZE)Quoted 3 lines
1 slot since GSO
In the debug code i annotated all cons++, and the code uses 1 slot to
process
Quoted 1 line
the data from the SKB as expected but uses 3 slots in the frag chopping
loop.
So, we must have done something like fill an existing slot, fill the next, but then had some left over requiring a third. Could you try the following additional patch?
drivers/net/xen-netback/netback.c +1 -1
@@ -499,7 +499,7 @@ static void xenvif_rx_action(struct xenvif *vif)for (i =0 ; i <skb_shinfo (skb)->nr_frags; i++) {unsigned int size; size =skb_frag_size (&skb_shinfo (skb)->frags[i]); - max_slots_needed +=DIV_ROUND_UP (size,PAGE_SIZE ); + max_slots_needed += (size /PAGE_SIZE ) +2 ; } if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4 ||
Paul
Quoted 37 lines
Quoted 4 lines
And when it reaches the state were cons > prod it is always in "
get_next_rx_buffer".Quoted 1 line
Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
Quoted 9 lines
frags ..
Quoted 4 lines
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return (from
xenvif_gop_skb()) minus the value on entry ,Quoted 1 line
and if you look back up the code then you can see that
meta_prodisincremented every time
RING_GET_REQUEST()is evaluated.Quoted 1 line
So, we must be consuming a slot without evaluating
RING_GET_REQUEST()Quoted 5 lines
and I think that's exactly what's happening...
Quoted 1 line
Right at the bottom of
xenvif_gop_frag_copy()req_consis simplyincremented in the case of a GSO. So the
BUG_ON()is indeed off by one.That is probably only done on first iteration / frag ?
Yes, the extra slot is accounted for right after the head frag is processed.
Paul
Quoted 1 line
Because i don't see my warn there trigger .. but it could be that's because
at
Quoted 6 lines
that moment we still have cons <= prod.
Quoted 1 line
Paul
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantQuoted 104 lines
-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of Paul Durrant
Sent: 26 March 2014 18:16
To: Sander Eikelenboom
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 18:08
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 7 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Wednesday, March 26, 2014, 6:46:06 PM, you wrote:
Quoted 15 lines
Quoted 7 lines
Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 7 lines
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy"while
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" butshortly
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
after
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 7 lines
Quoted 7 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);Quoted 12 lines
Quoted 4 lines
Quoted 2 lines
in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Yes
Quoted 5 lines
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimatingthen
Quoted 20 lines
the
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.It's seem to be the last ..
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
net_rx_action()calculated we would need 4 slots .. and sco-Quoted 1 line
meta_slots_used== 4 when we return so it doesn't trigger youBUG_ON..
Quoted 5 lines
The 4 slots we calculated are:
1 slot for the data part: DIV_ROUND_UP(offset_in_page(skb->data) +skb_headlen(skb),PAGE_SIZE)
2 slots for the single frag in this SKB from: DIV_ROUND_UP(size,
Quoted 7 lines
PAGE_SIZE)Quoted 3 lines
1 slot since GSO
In the debug code i annotated all cons++, and the code uses 1 slot to
process
Quoted 1 line
the data from the SKB as expected but uses 3 slots in the frag chopping
loop.
So, we must have done something like fill an existing slot, fill the next, but then had some left over requiring a third. Could you try the following additional patch?
drivers/net/xen-netback/netback.c +1 -1
@@ -499,7 +499,7 @@ static void xenvif_rx_action(struct xenvif *vif)for (i =0 ; i <skb_shinfo (skb)->nr_frags; i++) {unsigned int size; size =skb_frag_size (&skb_shinfo (skb)->frags[i]); - max_slots_needed +=DIV_ROUND_UP (size,PAGE_SIZE ); + max_slots_needed += (size /PAGE_SIZE ) +2 ; } if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4 ||
Paul
Quoted 37 lines
Quoted 4 lines
And when it reaches the state were cons > prod it is always in "
get_next_rx_buffer".Quoted 1 line
Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
Quoted 9 lines
frags ..
Quoted 4 lines
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return (from
xenvif_gop_skb()) minus the value on entry ,Quoted 1 line
and if you look back up the code then you can see that
meta_prodisincremented every time
RING_GET_REQUEST()is evaluated.Quoted 1 line
So, we must be consuming a slot without evaluating
RING_GET_REQUEST()Quoted 5 lines
and I think that's exactly what's happening...
Quoted 1 line
Right at the bottom of
xenvif_gop_frag_copy()req_consis simplyincremented in the case of a GSO. So the
BUG_ON()is indeed off by one.That is probably only done on first iteration / frag ?
Yes, the extra slot is accounted for right after the head frag is processed.
Paul
Quoted 1 line
Because i don't see my warn there trigger .. but it could be that's because
at
Quoted 6 lines
that moment we still have cons <= prod.
Quoted 1 line
Paul
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantQuoted 105 lines · you
Quoted 105 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 18:08
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 7 lines · you
Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 7 lines
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy" whileQuoted 8 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" but shortlyafter
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 11 lines
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Yes
Quoted 5 lines
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimating thenthe
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.It's seem to be the last ..
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
net_rx_action()calculated we would need 4 slots .. and sco-Quoted 1 line
meta_slots_used== 4 when we return so it doesn't trigger youBUG_ON..The 4 slots we calculated are:
1 slot for the data part: DIV_ROUND_UP(offset_in_page(skb->data) +skb_headlen(skb),PAGE_SIZE)
2 slots for the single frag in this SKB from:DIV_ROUND_UP(size, PAGE_SIZE)1 slot since GSOIn the debug code i annotated all cons++, and the code uses 1 slot to process the data from the SKB as expected but uses 3 slots in the frag chopping loop. And when it reaches the state were cons > prod it is always in "
get_next_rx_buffer".Quoted 1 line
Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
frags ..
Quoted 4 lines
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return (from
xenvif_gop_skb()) minus the value on entry ,Quoted 1 line
and if you look back up the code then you can see that
meta_prodisincremented every time
RING_GET_REQUEST()is evaluated.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
So, we must be consuming a slot without evaluating
RING_GET_REQUEST()and I think that's exactly what's happening...
Quoted 1 line
Right at the bottom of
xenvif_gop_frag_copy()req_consis simplyincremented in the case of a GSO. So the
BUG_ON()is indeed off by one.That is probably only done on first iteration / frag ?
Yes, the extra slot is accounted for right after the head frag is processed
Ok so we are talking about:
if (*head && ((1 << gso_type) & vif->gso_mask)){
vif->rx.req_cons++;Well it had some debug code in place to detect if that path is taken as well:
[ 1157.095216] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here end npo->meta_prod:40 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 npo->copy_gref:4325379 npo->copy_off:560 MAX_BUFFER_OFFSET:4096 bytes:560 size:0 offset:560 head:1273462060 i:3 vif->rx.sring->req_event:2105868 gso_gaps:0 estimated_slots_needed:4 reserved_slots_left:-1
Well "gso_gaps:0" indicates that in this case that path in "xenvif_gop_frag_copy()" has not been taken in any iteration of that frag.
However i=3 .. so we have done 3 iterations of the loop while we expected to do only 2 ...
So that would mean that somehow the code in "xenvif_gop_frag_copy()" needs more slots
to brake this frag down than the loop with DIV_ROUND_UP(size, PAGE_SIZE) in net_rx_action() has accounted for.
RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
Quoted 153 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 20:18
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 18:08
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 14 lines
Quoted 14 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 7 lines · you
Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;Quoted 8 lines
Quoted 8 lines
linux-
Quoted 7 lines
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy"while
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" butshortly
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
after
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 11 lines
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Quoted 7 lines
Quoted 7 lines
Yes
Quoted 5 lines
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimatingthen
Quoted 20 lines
Quoted 20 lines
the
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.It's seem to be the last ..
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
net_rx_action()calculated we would need 4 slots .. and sco-Quoted 1 line
meta_slots_used== 4 when we return so it doesn't trigger youBUG_ON..
Quoted 5 lines
Quoted 5 lines
The 4 slots we calculated are:
1 slot for the data part: DIV_ROUND_UP(offset_in_page(skb->data) +skb_headlen(skb),PAGE_SIZE)
2 slots for the single frag in this SKB from: DIV_ROUND_UP(size,
PAGE_SIZE)Quoted 3 lines
Quoted 3 lines
1 slot since GSO
In the debug code i annotated all cons++, and the code uses 1 slot to
process
Quoted 1 line
Quoted 1 line
the data from the SKB as expected but uses 3 slots in the frag chopping
loop.
Quoted 9 lines
Quoted 9 lines
And when it reaches the state were cons > prod it is always in "
get_next_rx_buffer".Quoted 1 line
Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
frags ..
Quoted 4 lines
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return(from
Quoted 4 lines
Quoted 4 lines
xenvif_gop_skb()) minus the value on entry ,Quoted 1 line
and if you look back up the code then you can see that
meta_prodisincremented every time
RING_GET_REQUEST()is evaluated.Quoted 1 line
So, we must be consuming a slot without evaluating
RING_GET_REQUEST()Quoted 7 lines
Quoted 5 lines
and I think that's exactly what's happening...
Quoted 1 line
Right at the bottom of
xenvif_gop_frag_copy()req_consis simplyincremented in the case of a GSO. So the
BUG_ON()is indeed off by one.That is probably only done on first iteration / frag ?
Yes, the extra slot is accounted for right after the head frag is processed
Ok so we are talking about:
if (*head && ((1 << gso_type) & vif->gso_mask)){ vif->rx.req_cons++;Well it had some debug code in place to detect if that path is taken as well:
[ 1157.095216] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here end npo-Quoted 1 line
meta_prod:40 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868
npo->copy_gref:4325379 npo->copy_off:560 MAX_BUFFER_OFFSET:4096 bytes:560 size:0 offset:560 head:1273462060 i:3 vif->rx.sring-
Quoted 1 line
req_event:2105868 gso_gaps:0 estimated_slots_needed:4
reserved_slots_left:-1
Well "gso_gaps:0" indicates that in this case that path in "
xenvif_gop_frag_copy()" has not been taken in any iteration of that frag.
Quoted 8 lines
However i=3 .. so we have done 3 iterations of the loop while we expected to do only 2 ...
So that would mean that somehow the code in "
xenvif_gop_frag_copy()" needs more slots
to brake this frag down than the loop withDIV_ROUND_UP(size, PAGE_SIZE)innet_rx_action()has accounted for.
Yes. The code is not assuming worst-case page-spanning and it looks like it needs to.
I also notice a bogus clause in this if statement in start_new_rx_buffer():
if ((offset + size > MAX_BUFFER_OFFSET) &&
(size <= MAX_BUFFER_OFFSET) && offset && !head)
return true;MAX_BUFFER_OFFSET is defined to be PAGE_SIZE and xenvif_gop_frag_copy() never passes a value of size > PAGE_SIZE, so that 2nd clause is completely pointless. I'll come up with some patches shortly.
Paul
Quoted 5 lines
Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
Hrmm i don't know if it's your mailer or my mailer .. but i seem to get a lot of your mails truncated somehow :S though the xen-devel list archive seem to have them in complete form .. so it's probably my mailer tripping over something
Quoted 1 line
I'll come up with some patches shortly.
OK will test them ASAP.
Quoted 131 lines · you
Quoted 131 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 20:18
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 18:08
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 14 lines
Quoted 14 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 7 lines · you
Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;Quoted 8 lines
Quoted 8 lines
linux-
Quoted 7 lines
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy"while
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" butshortly
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
after
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 11 lines
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Quoted 7 lines
Quoted 7 lines
Yes
Quoted 5 lines
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimatingthen
Quoted 20 lines
Quoted 20 lines
the
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.It's seem to be the last ..
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
net_rx_action()calculated we would need 4 slots .. and sco-Quoted 1 line
meta_slots_used== 4 when we return so it doesn't trigger youBUG_ON..
Quoted 5 lines
Quoted 5 lines
The 4 slots we calculated are:
1 slot for the data part: DIV_ROUND_UP(offset_in_page(skb->data) +skb_headlen(skb),PAGE_SIZE)
2 slots for the single frag in this SKB from: DIV_ROUND_UP(size,
PAGE_SIZE)Quoted 3 lines
Quoted 3 lines
1 slot since GSO
In the debug code i annotated all cons++, and the code uses 1 slot to
process
Quoted 1 line
Quoted 1 line
the data from the SKB as expected but uses 3 slots in the frag chopping
loop.
Quoted 9 lines
Quoted 9 lines
And when it reaches the state were cons > prod it is always in "
get_next_rx_buffer".Quoted 1 line
Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
frags ..
Quoted 4 lines
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return(from
Quoted 4 lines
Quoted 4 lines
xenvif_gop_skb()) minus the value on entry ,Quoted 1 line
and if you look back up the code then you can see that
meta_prodisincremented every time
RING_GET_REQUEST()is evaluated.Quoted 1 line
So, we must be consuming a slot without evaluating
RING_GET_REQUEST()Quoted 3 lines
Quoted 3 lines
and I think that's exactly what's happening...
Quoted 1 line
Right at the bottom of
xenvif_gop_frag_copy()req_consis simplyincremented in the case of a GSO. So the
BUG_ON()is indeed off by one
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantHrmm i don't know if it's your mailer or my mailer .. but i seem to get a lot of your mails truncated somehow :S though the xen-devel list archive seem to have them in complete form .. so it's probably my mailer tripping over something
Quoted 1 line
I'll come up with some patches shortly.
OK will test them ASAP.
Quoted 131 lines · you
Quoted 131 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 20:18
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 18:08
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 14 lines
Quoted 14 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 7 lines · you
Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;Quoted 8 lines
Quoted 8 lines
linux-
Quoted 7 lines
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy"while
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" butshortly
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
after
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 11 lines
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Quoted 7 lines
Quoted 7 lines
Yes
Quoted 5 lines
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimatingthen
Quoted 20 lines
Quoted 20 lines
the
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.It's seem to be the last ..
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
net_rx_action()calculated we would need 4 slots .. and sco-Quoted 1 line
meta_slots_used== 4 when we return so it doesn't trigger youBUG_ON..
Quoted 5 lines
Quoted 5 lines
The 4 slots we calculated are:
1 slot for the data part: DIV_ROUND_UP(offset_in_page(skb->data) +skb_headlen(skb),PAGE_SIZE)
2 slots for the single frag in this SKB from: DIV_ROUND_UP(size,
PAGE_SIZE)Quoted 3 lines
Quoted 3 lines
1 slot since GSO
In the debug code i annotated all cons++, and the code uses 1 slot to
process
Quoted 1 line
Quoted 1 line
the data from the SKB as expected but uses 3 slots in the frag chopping
loop.
Quoted 9 lines
Quoted 9 lines
And when it reaches the state were cons > prod it is always in "
get_next_rx_buffer".Quoted 1 line
Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
frags ..
Quoted 4 lines
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return(from
Quoted 4 lines
Quoted 4 lines
xenvif_gop_skb()) minus the value on entry ,Quoted 1 line
and if you look back up the code then you can see that
meta_prodisincremented every time
RING_GET_REQUEST()is evaluated.Quoted 1 line
So, we must be consuming a slot without evaluating
RING_GET_REQUEST()Quoted 3 lines
Quoted 3 lines
and I think that's exactly what's happening...
Quoted 1 line
Right at the bottom of
xenvif_gop_frag_copy()req_consis simplyincremented in the case of a GSO. So the
BUG_ON()is indeed off by one
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Sander EikelenboomQuoted 153 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 20:18
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 18:08
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 14 lines
Quoted 14 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 7 lines · you
Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;Quoted 8 lines
Quoted 8 lines
linux-
Quoted 7 lines
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy"while
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" butshortly
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
after
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 11 lines
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Quoted 7 lines
Quoted 7 lines
Yes
Quoted 5 lines
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimatingthen
Quoted 20 lines
Quoted 20 lines
the
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.It's seem to be the last ..
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
net_rx_action()calculated we would need 4 slots .. and sco-Quoted 1 line
meta_slots_used== 4 when we return so it doesn't trigger youBUG_ON..
Quoted 5 lines
Quoted 5 lines
The 4 slots we calculated are:
1 slot for the data part: DIV_ROUND_UP(offset_in_page(skb->data) +skb_headlen(skb),PAGE_SIZE)
2 slots for the single frag in this SKB from: DIV_ROUND_UP(size,
PAGE_SIZE)Quoted 3 lines
Quoted 3 lines
1 slot since GSO
In the debug code i annotated all cons++, and the code uses 1 slot to
process
Quoted 1 line
Quoted 1 line
the data from the SKB as expected but uses 3 slots in the frag chopping
loop.
Quoted 9 lines
Quoted 9 lines
And when it reaches the state were cons > prod it is always in "
get_next_rx_buffer".Quoted 1 line
Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
frags ..
Quoted 4 lines
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return(from
Quoted 4 lines
Quoted 4 lines
xenvif_gop_skb()) minus the value on entry ,Quoted 1 line
and if you look back up the code then you can see that
meta_prodisincremented every time
RING_GET_REQUEST()is evaluated.Quoted 1 line
So, we must be consuming a slot without evaluating
RING_GET_REQUEST()Quoted 7 lines
Quoted 5 lines
and I think that's exactly what's happening...
Quoted 1 line
Right at the bottom of
xenvif_gop_frag_copy()req_consis simplyincremented in the case of a GSO. So the
BUG_ON()is indeed off by one.That is probably only done on first iteration / frag ?
Yes, the extra slot is accounted for right after the head frag is processed
Ok so we are talking about:
if (*head && ((1 << gso_type) & vif->gso_mask)){ vif->rx.req_cons++;Well it had some debug code in place to detect if that path is taken as well:
[ 1157.095216] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here end npo-Quoted 1 line
meta_prod:40 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868
npo->copy_gref:4325379 npo->copy_off:560 MAX_BUFFER_OFFSET:4096 bytes:560 size:0 offset:560 head:1273462060 i:3 vif->rx.sring-
Quoted 1 line
req_event:2105868 gso_gaps:0 estimated_slots_needed:4
reserved_slots_left:-1
Well "gso_gaps:0" indicates that in this case that path in "
xenvif_gop_frag_copy()" has not been taken in any iteration of that frag.
Quoted 8 lines
However i=3 .. so we have done 3 iterations of the loop while we expected to do only 2 ...
So that would mean that somehow the code in "
xenvif_gop_frag_copy()" needs more slots
to brake this frag down than the loop withDIV_ROUND_UP(size, PAGE_SIZE)innet_rx_action()has accounted for.
Yes. The code is not assuming worst-case page-spanning and it looks like it needs to.
I also notice a bogus clause in this if statement in start_new_rx_buffer():
if ((offset + size > MAX_BUFFER_OFFSET) &&
(size <= MAX_BUFFER_OFFSET) && offset && !head)
return true;MAX_BUFFER_OFFSET is defined to be PAGE_SIZE and xenvif_gop_frag_copy() never passes a value of size > PAGE_SIZE, so that 2nd clause is completely pointless. I'll come up with some patches shortly.
Paul
Quoted 5 lines
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantQuoted 105 lines · you
Quoted 105 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 18:08
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 7 lines · you
Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 7 lines
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy" whileQuoted 8 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" but shortlyafter
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 11 lines
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Yes
Quoted 5 lines
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimating thenthe
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.It's seem to be the last ..
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
net_rx_action()calculated we would need 4 slots .. and sco-Quoted 1 line
meta_slots_used== 4 when we return so it doesn't trigger youBUG_ON..The 4 slots we calculated are:
1 slot for the data part: DIV_ROUND_UP(offset_in_page(skb->data) +skb_headlen(skb),PAGE_SIZE)
2 slots for the single frag in this SKB from:DIV_ROUND_UP(size, PAGE_SIZE)1 slot since GSOIn the debug code i annotated all cons++, and the code uses 1 slot to process the data from the SKB as expected but uses 3 slots in the frag chopping loop. And when it reaches the state were cons > prod it is always in "
get_next_rx_buffer".Quoted 1 line
Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
frags ..
Quoted 4 lines
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return (from
xenvif_gop_skb()) minus the value on entry ,Quoted 1 line
and if you look back up the code then you can see that
meta_prodisincremented every time
RING_GET_REQUEST()is evaluated.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
So, we must be consuming a slot without evaluating
RING_GET_REQUEST()and I think that's exactly what's happening...
Quoted 1 line
Right at the bottom of
xenvif_gop_frag_copy()req_consis simplyincremented in the case of a GSO. So the
BUG_ON()is indeed off by one.That is probably only done on first iteration / frag ?
Yes, the extra slot is accounted for right after the head frag is processed
Ok so we are talking about:
if (*head && ((1 << gso_type) & vif->gso_mask)){
vif->rx.req_cons++;Well it had some debug code in place to detect if that path is taken as well:
[ 1157.095216] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here end npo->meta_prod:40 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 npo->copy_gref:4325379 npo->copy_off:560 MAX_BUFFER_OFFSET:4096 bytes:560 size:0 offset:560 head:1273462060 i:3 vif->rx.sring->req_event:2105868 gso_gaps:0 estimated_slots_needed:4 reserved_slots_left:-1
Well "gso_gaps:0" indicates that in this case that path in "xenvif_gop_frag_copy()" has not been taken in any iteration of that frag.
However i=3 .. so we have done 3 iterations of the loop while we expected to do only 2 ...
So that would mean that somehow the code in "xenvif_gop_frag_copy()" needs more slots
to brake this frag down than the loop with DIV_ROUND_UP(size, PAGE_SIZE) in net_rx_action() has accounted for.
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Sander EikelenboomQuoted 103 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 18:08
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 7 lines · you
Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 7 lines
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy" whileQuoted 8 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" but shortlyafter
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 11 lines
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Yes
Quoted 5 lines
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimating thenthe
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.It's seem to be the last ..
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
net_rx_action()calculated we would need 4 slots .. and sco-Quoted 1 line
meta_slots_used== 4 when we return so it doesn't trigger youBUG_ON..The 4 slots we calculated are:
1 slot for the data part: DIV_ROUND_UP(offset_in_page(skb->data) +skb_headlen(skb),PAGE_SIZE)
2 slots for the single frag in this SKB from:DIV_ROUND_UP(size, PAGE_SIZE)1 slot since GSOIn the debug code i annotated all cons++, and the code uses 1 slot to process the data from the SKB as expected but uses 3 slots in the frag chopping loop. And when it reaches the state were cons > prod it is always in "
get_next_rx_buffer".Quoted 1 line
Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
frags ..
Quoted 4 lines
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return (from
xenvif_gop_skb()) minus the value on entry ,
Quoted 8 lines
Quoted 1 line
and if you look back up the code then you can see that
meta_prodisincremented every time
RING_GET_REQUEST()is evaluated.Quoted 1 line
So, we must be consuming a slot without evaluating
RING_GET_REQUEST()and I think that's exactly what's happening...
Quoted 1 line
Right at the bottom of
xenvif_gop_frag_copy()req_consis simplyincremented in the case of a GSO. So the
BUG_ON()is indeed off by one.That is probably only done on first iteration / frag ?
Yes, the extra slot is accounted for right after the head frag is processed.
Paul
Quoted 7 lines
Because i don't see my warn there trigger .. but it could be that's because at that moment we still have cons <= prod.
Quoted 1 line
Paul
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantQuoted 37 lines · you
Re-send shortened version...
Quoted 9 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 25 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy" whileprod
Quoted 8 lines
Quoted 8 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have become free (you see cons become > prod in "
get_next_rx_buffer" but shortlyafter
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculation then why is thatBUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);
Quoted 4 lines
Quoted 2 lines
in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Yes
Quoted 5 lines
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimating then theBUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.
It's seem to be the last ..
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo->meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1 req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1 reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 .. used_fragloop:3 [ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco->meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1 max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
net_rx_action() calculated we would need 4 slots .. and sco->meta_slots_used == 4 when we return so it doesn't trigger you BUG_ON ..
The 4 slots we calculated are:
1 slot for the data part: DIV_ROUND_UP(offset_in_page(skb->data) + skb_headlen(skb), PAGE_SIZE) 2 slots for the single frag in this SKB from: DIV_ROUND_UP(size, PAGE_SIZE)
1 slot since GSO
In the debug code i annotated all cons++, and the code uses 1 slot to process the data from the SKB as expected but uses 3 slots in the frag chopping loop. And when it reaches the state were cons > prod it is always in "get_next_rx_buffer".
Quoted 8 lines
Quoted 3 lines
But probably because "npo->copy_prod++" seems to be used for the frags .. and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return (fromxenvif_gop_skb()) minus the value on entry , and if you look back up the code then you can see thatmeta_prodis incremented every timeRING_GET_REQUEST()is evaluated. So, we must be consuming a slot without evaluatingRING_GET_REQUEST()and I think that's exactly what's happening... Right at the bottom ofxenvif_gop_frag_copy()req_consis simply incremented in the case of a GSO. So theBUG_ON()is indeed off by one.
That is probably only done on first iteration / frag ?
Because i don't see my warn there trigger .. but it could be that's because at that moment we still have cons <= prod.
Quoted 1 line
Paul
RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Sander EikelenboomQuoted 68 lines
-----Original Message-----
From: Paul Durrant
Sent: 26 March 2014 17:47
To: 'Sander Eikelenboom'
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy" whileprod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 8 lines
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" but shortlyafter
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimating then theBUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the frags
..
Quoted 2 lines
and it isn't added to
npo->meta_prod?
Quoted 9 lines
meta_slots_usedis calculated as the value ofmeta_prodat return (fromxenvif_gop_skb()) minus the value on entry , and if you look back up the code then you can see thatmeta_prodis incremented every timeRING_GET_REQUEST()is evaluated. So, we must be consuming a slot without evaluatingRING_GET_REQUEST()and I think that's exactly what's happening... Right at the bottom ofxenvif_gop_frag_copy()req_consis simply incremented in the case of a GSO. So theBUG_ON()is indeed off by one.
Can you re-test with the following patch applied?
Paul
drivers/net/xen-netback/netback.c +7 -1
@@ -482,6 +482,8 @@ static void xenvif_rx_action(struct xenvif *vif)while ((skb =skb_dequeue (&vif->rx_queue)) !=NULL ) {RING_IDX max_slots_needed; +RING_IDX old_req_cons; +RING_IDX ring_slots_used;int i;/* We need a cheap worse case estimate for the number of
@@ -511,8 +513,12 @@ static void xenvif_rx_action(struct xenvif *vif) vif->rx_last_skb_slots =0 ; sco = (struct skb_cb_overlay *)skb->cb; + + old_req_cons = vif->rx.req_cons; sco->meta_slots_used =xenvif_gop_skb (skb, &npo); -BUG_ON (sco->meta_slots_used > max_slots_needed); + ring_slots_used = vif->rx.req_cons - old_req_cons; + +BUG_ON (ring_slots_used > max_slots_needed);__skb_queue_tail (&rxq, skb); }
Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
Quoted 99 lines · you
Quoted 68 lines
-----Original Message-----
From: Paul Durrant
Sent: 26 March 2014 17:47
To: 'Sander Eikelenboom'
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy" whileprod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 8 lines
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" but shortlyafter
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimating then theBUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the frags
..
Quoted 2 lines
and it isn't added to
npo->meta_prod?Quoted 9 lines
meta_slots_usedis calculated as the value ofmeta_prodat return (fromxenvif_gop_skb()) minus the value on entry , and if you look back up the code then you can see thatmeta_prodis incremented every timeRING_GET_REQUEST()is evaluated. So, we must be consuming a slot without evaluatingRING_GET_REQUEST()and I think that's exactly what's happening... Right at the bottom ofxenvif_gop_frag_copy()req_consis simply incremented in the case of a GSO. So theBUG_ON()is indeed off by one.Can you re-test with the following patch applied?
Paul
drivers/net/xen-netback/netback.c +2
-0@@ -482,6 +482,8 @@ static void xenvif_rx_action(struct xenvif *vif)while ((skb =skb_dequeue (&vif->rx_queue)) !=NULL ) {RING_IDX max_slots_needed; +RING_IDX old_req_cons; +RING_IDX ring_slots_used;int i;/* We need a cheap worse case estimate for the number of @@ -511,8 +513,12 @@ static void xenvif_rx_action(struct xenvif *vif) vif->rx_last_skb_slots =0 ; sco = (struct skb_cb_overlay *)skb->cb;
drivers/net/xen-netback/netback.c static void xenvif_rx_action(struct xenvif *vif) · line 524
Quoted 10 lines
drivers/net/xen-netback/netback.c +5
-1+ + old_req_cons = vif->rx.req_cons; sco->meta_slots_used =xenvif_gop_skb (skb, &npo); -BUG_ON (sco->meta_slots_used > max_slots_needed); + ring_slots_used = vif->rx.req_cons - old_req_cons; + +BUG_ON (ring_slots_used > max_slots_needed);__skb_queue_tail (&rxq, skb); }
That blew pretty fast .. on that BUG_ON
[ 290.218182] ------------[ cut here ]------------ [ 290.225425] kernel BUG at drivers/net/xen-netback/netback.c:664! [ 290.232717] invalid opcode: 0000 [#1] SMP [ 290.239875] Modules linked in: [ 290.246923] CPU: 0 PID: 10447 Comm: vif7.0 Not tainted 3.13.6-20140326-nbdebug35+ #1 [ 290.254040] Hardware name: MSI MS-7640/890FXA-GD70 (MS-7640) , BIOS V1.8B1 09/13/2010 [ 290.261313] task: ffff880055d16480 ti: ffff88004cb7e000 task.ti: ffff88004cb7e000 [ 290.268713] RIP: e030:[<ffffffff81780430>] [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.276193] RSP: e02b:ffff88004cb7fc28 EFLAGS: 00010202 [ 290.283555] RAX: 0000000000000006 RBX: ffff88004c630000 RCX: 3fffffffffffffff [ 290.290908] RDX: 00000000ffffffff RSI: ffff88004c630940 RDI: 0000000000048e7b [ 290.298325] RBP: ffff88004cb7fde8 R08: 0000000000007bc9 R09: 0000000000000005 [ 290.305809] R10: ffff88004cb7fd28 R11: ffffc90012690600 R12: 0000000000000004 [ 290.313217] R13: ffff8800536a84e0 R14: 0000000000000001 R15: ffff88004c637618 [ 290.320521] FS: 00007f1d3030c700(0000) GS:ffff88005f600000(0000) knlGS:0000000000000000 [ 290.327839] CS: e033 DS: 0000 ES: 0000 CR0: 000000008005003b [ 290.335216] CR2: ffffffffff600400 CR3: 0000000058537000 CR4: 0000000000000660 [ 290.342732] Stack: [ 290.350129] ffff88004cb7fd2c ffff880000000005 ffff88004cb7fd28 ffffffff810f7fc8 [ 290.357652] ffff880055d16b50 ffffffff00000407 ffff880000000000 ffffffff00000000 [ 290.365048] ffff880055d16b50 ffff880000000001 ffff880000000001 ffffffff00000000 [ 290.372461] Call Trace: [ 290.379806] [<ffffffff810f7fc8>] ? __lock_acquire+0x418/0x2220 [ 290.387211] [<ffffffff810df5f6>] ? finish_task_switch+0x46/0xf0 [ 290.394552] [<ffffffff81781400>] xenvif_kthread+0x40/0x190 [ 290.401808] [<ffffffff810f05e0>] ? __init_waitqueue_head+0x60/0x60 [ 290.408993] [<ffffffff817813c0>] ? xenvif_stop_queue+0x60/0x60 [ 290.416238] [<ffffffff810d4f24>] kthread+0xe4/0x100 [ 290.423428] [<ffffffff81b4cf30>] ? _raw_spin_unlock_irq+0x30/0x50 [ 290.430615] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.437793] [<ffffffff81b4e13c>] ret_from_fork+0x7c/0xb0 [ 290.444945] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.452091] Code: fd ff ff 48 8b b5 f0 fe ff ff 48 c7 c2 10 98 ce 81 31 c0 48 8b be c8 7c 00 00 48 c7 c6 f0 f1 fd 81 e8 35 be 24 00 e9 ba f8 ff ff <0f> 0b 0f 0b 41 bf 01 00 00 00 e9 55 f6 ff ff 0f 0b 66 66 66 66 [ 290.467121] RIP [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.474436] RSP <ffff88004cb7fc28> [ 290.482400] ---[ end trace 2fcf9e9ae26950b3 ]---
RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
Quoted 127 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 19:57
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Paul Durrant
Sent: 26 March 2014 17:47
To: 'Sander Eikelenboom'
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 11 lines
Quoted 11 lines
kernel; [email protected]
Subject: RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;Quoted 8 lines
Quoted 8 lines
linux-
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy"while
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 1 line
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" butshortly
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
after
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?Quoted 7 lines
Quoted 7 lines
That code excerpt is from net_rx_action(),isn't it?
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimatingthen
Quoted 5 lines
Quoted 5 lines
the
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
frags
Quoted 8 lines
Quoted 8 lines
..
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return (fromxenvif_gop_skb()) minus the value on entry , and if you look back up the code then you can see thatmeta_prodis incremented every timeRING_GET_REQUEST()is evaluated. So, we must be consuming a slotwithout
Quoted 3 lines
Quoted 3 lines
evaluating
RING_GET_REQUEST()and I think that's exactly what's happening... Right at the bottom ofxenvif_gop_frag_copy()req_consis simply incremented in the case of a GSO. So theBUG_ON()is indeed offby
drivers/net/xen-
Quoted 8 lines
Quoted 2 lines
one.
Can you re-test with the following patch applied?
Paul
drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0
-0netback/netback
Quoted 23 lines
index 438d0c0..4f24220 100644
drivers/net/xen-netback/netback.c +7
-1@@ -482,6 +482,8 @@ static void xenvif_rx_action(struct xenvif *vif)while ((skb =skb_dequeue (&vif->rx_queue)) !=NULL ) {RING_IDX max_slots_needed; +RING_IDX old_req_cons; +RING_IDX ring_slots_used;int i;/* We need a cheap worse case estimate for the number of @@ -511,8 +513,12 @@ static void xenvif_rx_action(struct xenvif *vif) vif->rx_last_skb_slots =0 ; sco = (struct skb_cb_overlay *)skb->cb; + + old_req_cons = vif->rx.req_cons; sco->meta_slots_used =xenvif_gop_skb (skb, &npo); -BUG_ON (sco->meta_slots_used > max_slots_needed); + ring_slots_used = vif->rx.req_cons - old_req_cons; + +BUG_ON (ring_slots_used > max_slots_needed);
Quoted 5 lines
drivers/net/xen-netback/netback.c static void xenvif_rx_action(struct xenvif *vif) · line 524
Quoted 2 lines
drivers/net/xen-netback/netback.c +0
-0__skb_queue_tail (&rxq, skb); }That blew pretty fast .. on that
BUG_ON
Good. That's what should have happened :-)
Paul
Quoted 52 lines
[ 290.218182] ------------[ cut here ]------------ [ 290.225425] kernel BUG at drivers/net/xen-netback/netback.c:664! [ 290.232717] invalid opcode: 0000 [#1] SMP [ 290.239875] Modules linked in: [ 290.246923] CPU: 0 PID: 10447 Comm: vif7.0 Not tainted 3.13.6-20140326- nbdebug35+ #1 [ 290.254040] Hardware name: MSI MS-7640/890FXA-GD70 (MS-7640) , BIOS V1.8B1 09/13/2010 [ 290.261313] task: ffff880055d16480 ti: ffff88004cb7e000 task.ti: ffff88004cb7e000 [ 290.268713] RIP: e030:[<ffffffff81780430>] [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.276193] RSP: e02b:ffff88004cb7fc28 EFLAGS: 00010202 [ 290.283555] RAX: 0000000000000006 RBX: ffff88004c630000 RCX: 3fffffffffffffff [ 290.290908] RDX: 00000000ffffffff RSI: ffff88004c630940 RDI: 0000000000048e7b [ 290.298325] RBP: ffff88004cb7fde8 R08: 0000000000007bc9 R09: 0000000000000005 [ 290.305809] R10: ffff88004cb7fd28 R11: ffffc90012690600 R12: 0000000000000004 [ 290.313217] R13: ffff8800536a84e0 R14: 0000000000000001 R15: ffff88004c637618 [ 290.320521] FS: 00007f1d3030c700(0000) GS:ffff88005f600000(0000) knlGS:0000000000000000 [ 290.327839] CS: e033 DS: 0000 ES: 0000 CR0: 000000008005003b [ 290.335216] CR2: ffffffffff600400 CR3: 0000000058537000 CR4: 0000000000000660 [ 290.342732] Stack: [ 290.350129] ffff88004cb7fd2c ffff880000000005 ffff88004cb7fd28 ffffffff810f7fc8 [ 290.357652] ffff880055d16b50 ffffffff00000407 ffff880000000000 ffffffff00000000 [ 290.365048] ffff880055d16b50 ffff880000000001 ffff880000000001 ffffffff00000000 [ 290.372461] Call Trace: [ 290.379806] [<ffffffff810f7fc8>] ? __lock_acquire+0x418/0x2220 [ 290.387211] [<ffffffff810df5f6>] ? finish_task_switch+0x46/0xf0 [ 290.394552] [<ffffffff81781400>] xenvif_kthread+0x40/0x190 [ 290.401808] [<ffffffff810f05e0>] ? __init_waitqueue_head+0x60/0x60 [ 290.408993] [<ffffffff817813c0>] ? xenvif_stop_queue+0x60/0x60 [ 290.416238] [<ffffffff810d4f24>] kthread+0xe4/0x100 [ 290.423428] [<ffffffff81b4cf30>] ? _raw_spin_unlock_irq+0x30/0x50 [ 290.430615] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.437793] [<ffffffff81b4e13c>] ret_from_fork+0x7c/0xb0 [ 290.444945] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.452091] Code: fd ff ff 48 8b b5 f0 fe ff ff 48 c7 c2 10 98 ce 81 31 c0 48 8b be c8 7c 00 00 48 c7 c6 f0 f1 fd 81 e8 35 be 24 00 e9 ba f8 ff ff <0f> 0b 0f 0b 41 bf 01 00 00 00 e9 55 f6 ff ff 0f 0b 66 66 66 66 [ 290.467121] RIP [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.474436] RSP <ffff88004cb7fc28> [ 290.482400] ---[ end trace 2fcf9e9ae26950b3 ]---
Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
Quoted 127 lines · you
Quoted 127 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 19:57
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Paul Durrant
Sent: 26 March 2014 17:47
To: 'Sander Eikelenboom'
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 11 lines
Quoted 11 lines
kernel; [email protected]
Subject: RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;Quoted 8 lines
Quoted 8 lines
linux-
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy"while
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 1 line
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" butshortly
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
after
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?Quoted 7 lines
Quoted 7 lines
That code excerpt is from net_rx_action(),isn't it?
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimatingthen
Quoted 5 lines
Quoted 5 lines
the
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
frags
Quoted 8 lines
Quoted 8 lines
..
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return (fromxenvif_gop_skb()) minus the value on entry , and if you look back up the code then you can see thatmeta_prodis incremented every timeRING_GET_REQUEST()is evaluated. So, we must be consuming a slotwithout
Quoted 3 lines
Quoted 3 lines
evaluating
RING_GET_REQUEST()and I think that's exactly what's happening... Right at the bottom ofxenvif_gop_frag_copy()req_consis simply incremented in the case of a GSO. So theBUG_ON()is indeed offby
drivers/net/xen-
Quoted 8 lines
Quoted 2 lines
one.
Can you re-test with the following patch applied?
Paul
drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0
-0netback/netback
Quoted 23 lines
index 438d0c0..4f24220 100644
drivers/net/xen-netback/netback.c +7
-1@@ -482,6 +482,8 @@ static void xenvif_rx_action(struct xenvif *vif)while ((skb =skb_dequeue (&vif->rx_queue)) !=NULL ) {RING_IDX max_slots_needed; +RING_IDX old_req_cons; +RING_IDX ring_slots_used;int i;/* We need a cheap worse case estimate for the number of @@ -511,8 +513,12 @@ static void xenvif_rx_action(struct xenvif *vif) vif->rx_last_skb_slots =0 ; sco = (struct skb_cb_overlay *)skb->cb; + + old_req_cons = vif->rx.req_cons; sco->meta_slots_used =xenvif_gop_skb (skb, &npo); -BUG_ON (sco->meta_slots_used > max_slots_needed); + ring_slots_used = vif->rx.req_cons - old_req_cons; + +BUG_ON (ring_slots_used > max_slots_needed);
Quoted 7 lines
Quoted 5 lines
drivers/net/xen-netback/netback.c static void xenvif_rx_action(struct xenvif *vif) · line 524
Quoted 2 lines
drivers/net/xen-netback/netback.c +0
-0__skb_queue_tail (&rxq, skb); }That blew pretty fast .. on that
BUG_ONGood. That's what should have happened :-)
Yes .. and No ..
We shouldn't be there in the first place :-)
Since now every miscalculation in the needed slots leads to a nice remote DOS attack .. (since we now crash the vif kthread)
it would be nice to have a worst case slot calculation .. with some theoretical guarantees
--
Sander
Quoted 54 lines
Paul
Quoted 52 lines
[ 290.218182] ------------[ cut here ]------------ [ 290.225425] kernel BUG at drivers/net/xen-netback/netback.c:664! [ 290.232717] invalid opcode: 0000 [#1] SMP [ 290.239875] Modules linked in: [ 290.246923] CPU: 0 PID: 10447 Comm: vif7.0 Not tainted 3.13.6-20140326- nbdebug35+ #1 [ 290.254040] Hardware name: MSI MS-7640/890FXA-GD70 (MS-7640) , BIOS V1.8B1 09/13/2010 [ 290.261313] task: ffff880055d16480 ti: ffff88004cb7e000 task.ti: ffff88004cb7e000 [ 290.268713] RIP: e030:[<ffffffff81780430>] [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.276193] RSP: e02b:ffff88004cb7fc28 EFLAGS: 00010202 [ 290.283555] RAX: 0000000000000006 RBX: ffff88004c630000 RCX: 3fffffffffffffff [ 290.290908] RDX: 00000000ffffffff RSI: ffff88004c630940 RDI: 0000000000048e7b [ 290.298325] RBP: ffff88004cb7fde8 R08: 0000000000007bc9 R09: 0000000000000005 [ 290.305809] R10: ffff88004cb7fd28 R11: ffffc90012690600 R12: 0000000000000004 [ 290.313217] R13: ffff8800536a84e0 R14: 0000000000000001 R15: ffff88004c637618 [ 290.320521] FS: 00007f1d3030c700(0000) GS:ffff88005f600000(0000) knlGS:0000000000000000 [ 290.327839] CS: e033 DS: 0000 ES: 0000 CR0: 000000008005003b [ 290.335216] CR2: ffffffffff600400 CR3: 0000000058537000 CR4: 0000000000000660 [ 290.342732] Stack: [ 290.350129] ffff88004cb7fd2c ffff880000000005 ffff88004cb7fd28 ffffffff810f7fc8 [ 290.357652] ffff880055d16b50 ffffffff00000407 ffff880000000000 ffffffff00000000 [ 290.365048] ffff880055d16b50 ffff880000000001 ffff880000000001 ffffffff00000000 [ 290.372461] Call Trace: [ 290.379806] [<ffffffff810f7fc8>] ? __lock_acquire+0x418/0x2220 [ 290.387211] [<ffffffff810df5f6>] ? finish_task_switch+0x46/0xf0 [ 290.394552] [<ffffffff81781400>] xenvif_kthread+0x40/0x190 [ 290.401808] [<ffffffff810f05e0>] ? __init_waitqueue_head+0x60/0x60 [ 290.408993] [<ffffffff817813c0>] ? xenvif_stop_queue+0x60/0x60 [ 290.416238] [<ffffffff810d4f24>] kthread+0xe4/0x100 [ 290.423428] [<ffffffff81b4cf30>] ? _raw_spin_unlock_irq+0x30/0x50 [ 290.430615] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.437793] [<ffffffff81b4e13c>] ret_from_fork+0x7c/0xb0 [ 290.444945] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.452091] Code: fd ff ff 48 8b b5 f0 fe ff ff 48 c7 c2 10 98 ce 81 31 c0 48 8b be c8 7c 00 00 48 c7 c6 f0 f1 fd 81 e8 35 be 24 00 e9 ba f8 ff ff <0f> 0b 0f 0b 41 bf 01 00 00 00 e9 55 f6 ff ff 0f 0b 66 66 66 66 [ 290.467121] RIP [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.474436] RSP <ffff88004cb7fc28> [ 290.482400] ---[ end trace 2fcf9e9ae26950b3 ]---
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantQuoted 127 lines · you
Quoted 127 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 19:57
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Paul Durrant
Sent: 26 March 2014 17:47
To: 'Sander Eikelenboom'
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 11 lines
Quoted 11 lines
kernel; [email protected]
Subject: RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;Quoted 8 lines
Quoted 8 lines
linux-
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy"while
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 1 line
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" butshortly
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
after
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?Quoted 7 lines
Quoted 7 lines
That code excerpt is from net_rx_action(),isn't it?
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimatingthen
Quoted 5 lines
Quoted 5 lines
the
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
frags
Quoted 8 lines
Quoted 8 lines
..
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return (fromxenvif_gop_skb()) minus the value on entry , and if you look back up the code then you can see thatmeta_prodis incremented every timeRING_GET_REQUEST()is evaluated. So, we must be consuming a slotwithout
Quoted 3 lines
Quoted 3 lines
evaluating
RING_GET_REQUEST()and I think that's exactly what's happening... Right at the bottom ofxenvif_gop_frag_copy()req_consis simply incremented in the case of a GSO. So theBUG_ON()is indeed offby
drivers/net/xen-
Quoted 8 lines
Quoted 2 lines
one.
Can you re-test with the following patch applied?
Paul
drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0
-0netback/netback
Quoted 23 lines
index 438d0c0..4f24220 100644
drivers/net/xen-netback/netback.c +7
-1@@ -482,6 +482,8 @@ static void xenvif_rx_action(struct xenvif *vif)while ((skb =skb_dequeue (&vif->rx_queue)) !=NULL ) {RING_IDX max_slots_needed; +RING_IDX old_req_cons; +RING_IDX ring_slots_used;int i;/* We need a cheap worse case estimate for the number of @@ -511,8 +513,12 @@ static void xenvif_rx_action(struct xenvif *vif) vif->rx_last_skb_slots =0 ; sco = (struct skb_cb_overlay *)skb->cb; + + old_req_cons = vif->rx.req_cons; sco->meta_slots_used =xenvif_gop_skb (skb, &npo); -BUG_ON (sco->meta_slots_used > max_slots_needed); + ring_slots_used = vif->rx.req_cons - old_req_cons; + +BUG_ON (ring_slots_used > max_slots_needed);
Quoted 7 lines
Quoted 5 lines
drivers/net/xen-netback/netback.c static void xenvif_rx_action(struct xenvif *vif) · line 524
Quoted 2 lines
drivers/net/xen-netback/netback.c +0
-0__skb_queue_tail (&rxq, skb); }That blew pretty fast .. on that
BUG_ONGood. That's what should have happened :-)
Yes .. and No ..
We shouldn't be there in the first place :-)
Since now every miscalculation in the needed slots leads to a nice remote DOS attack .. (since we now crash the vif kthread)
it would be nice to have a worst case slot calculation .. with some theoretical guarantees
--
Sander
Quoted 54 lines
Paul
Quoted 52 lines
[ 290.218182] ------------[ cut here ]------------ [ 290.225425] kernel BUG at drivers/net/xen-netback/netback.c:664! [ 290.232717] invalid opcode: 0000 [#1] SMP [ 290.239875] Modules linked in: [ 290.246923] CPU: 0 PID: 10447 Comm: vif7.0 Not tainted 3.13.6-20140326- nbdebug35+ #1 [ 290.254040] Hardware name: MSI MS-7640/890FXA-GD70 (MS-7640) , BIOS V1.8B1 09/13/2010 [ 290.261313] task: ffff880055d16480 ti: ffff88004cb7e000 task.ti: ffff88004cb7e000 [ 290.268713] RIP: e030:[<ffffffff81780430>] [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.276193] RSP: e02b:ffff88004cb7fc28 EFLAGS: 00010202 [ 290.283555] RAX: 0000000000000006 RBX: ffff88004c630000 RCX: 3fffffffffffffff [ 290.290908] RDX: 00000000ffffffff RSI: ffff88004c630940 RDI: 0000000000048e7b [ 290.298325] RBP: ffff88004cb7fde8 R08: 0000000000007bc9 R09: 0000000000000005 [ 290.305809] R10: ffff88004cb7fd28 R11: ffffc90012690600 R12: 0000000000000004 [ 290.313217] R13: ffff8800536a84e0 R14: 0000000000000001 R15: ffff88004c637618 [ 290.320521] FS: 00007f1d3030c700(0000) GS:ffff88005f600000(0000) knlGS:0000000000000000 [ 290.327839] CS: e033 DS: 0000 ES: 0000 CR0: 000000008005003b [ 290.335216] CR2: ffffffffff600400 CR3: 0000000058537000 CR4: 0000000000000660 [ 290.342732] Stack: [ 290.350129] ffff88004cb7fd2c ffff880000000005 ffff88004cb7fd28 ffffffff810f7fc8 [ 290.357652] ffff880055d16b50 ffffffff00000407 ffff880000000000 ffffffff00000000 [ 290.365048] ffff880055d16b50 ffff880000000001 ffff880000000001 ffffffff00000000 [ 290.372461] Call Trace: [ 290.379806] [<ffffffff810f7fc8>] ? __lock_acquire+0x418/0x2220 [ 290.387211] [<ffffffff810df5f6>] ? finish_task_switch+0x46/0xf0 [ 290.394552] [<ffffffff81781400>] xenvif_kthread+0x40/0x190 [ 290.401808] [<ffffffff810f05e0>] ? __init_waitqueue_head+0x60/0x60 [ 290.408993] [<ffffffff817813c0>] ? xenvif_stop_queue+0x60/0x60 [ 290.416238] [<ffffffff810d4f24>] kthread+0xe4/0x100 [ 290.423428] [<ffffffff81b4cf30>] ? _raw_spin_unlock_irq+0x30/0x50 [ 290.430615] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.437793] [<ffffffff81b4e13c>] ret_from_fork+0x7c/0xb0 [ 290.444945] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.452091] Code: fd ff ff 48 8b b5 f0 fe ff ff 48 c7 c2 10 98 ce 81 31 c0 48 8b be c8 7c 00 00 48 c7 c6 f0 f1 fd 81 e8 35 be 24 00 e9 ba f8 ff ff <0f> 0b 0f 0b 41 bf 01 00 00 00 e9 55 f6 ff ff 0f 0b 66 66 66 66 [ 290.467121] RIP [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.474436] RSP <ffff88004cb7fc28> [ 290.482400] ---[ end trace 2fcf9e9ae26950b3 ]---
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Sander EikelenboomQuoted 127 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 19:57
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Paul Durrant
Sent: 26 March 2014 17:47
To: 'Sander Eikelenboom'
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 11 lines
Quoted 11 lines
kernel; [email protected]
Subject: RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;Quoted 8 lines
Quoted 8 lines
linux-
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy"while
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
prod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 1 line
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" butshortly
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
after
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?Quoted 7 lines
Quoted 7 lines
That code excerpt is from net_rx_action(),isn't it?
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimatingthen
Quoted 5 lines
Quoted 5 lines
the
BUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the
frags
Quoted 8 lines
Quoted 8 lines
..
Quoted 2 lines
and it isn't added to
npo->meta_prod?
meta_slots_usedis calculated as the value ofmeta_prodat return (fromxenvif_gop_skb()) minus the value on entry , and if you look back up the code then you can see thatmeta_prodis incremented every timeRING_GET_REQUEST()is evaluated. So, we must be consuming a slotwithout
Quoted 3 lines
Quoted 3 lines
evaluating
RING_GET_REQUEST()and I think that's exactly what's happening... Right at the bottom ofxenvif_gop_frag_copy()req_consis simply incremented in the case of a GSO. So theBUG_ON()is indeed offby
drivers/net/xen-
Quoted 8 lines
Quoted 2 lines
one.
Can you re-test with the following patch applied?
Paul
drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0
-0netback/netback
Quoted 23 lines
index 438d0c0..4f24220 100644
drivers/net/xen-netback/netback.c +7
-1@@ -482,6 +482,8 @@ static void xenvif_rx_action(struct xenvif *vif)while ((skb =skb_dequeue (&vif->rx_queue)) !=NULL ) {RING_IDX max_slots_needed; +RING_IDX old_req_cons; +RING_IDX ring_slots_used;int i;/* We need a cheap worse case estimate for the number of @@ -511,8 +513,12 @@ static void xenvif_rx_action(struct xenvif *vif) vif->rx_last_skb_slots =0 ; sco = (struct skb_cb_overlay *)skb->cb; + + old_req_cons = vif->rx.req_cons; sco->meta_slots_used =xenvif_gop_skb (skb, &npo); -BUG_ON (sco->meta_slots_used > max_slots_needed); + ring_slots_used = vif->rx.req_cons - old_req_cons; + +BUG_ON (ring_slots_used > max_slots_needed);
Quoted 5 lines
drivers/net/xen-netback/netback.c static void xenvif_rx_action(struct xenvif *vif) · line 524
Quoted 2 lines
drivers/net/xen-netback/netback.c +0
-0__skb_queue_tail (&rxq, skb); }That blew pretty fast .. on that
BUG_ON
Good. That's what should have happened :-)
Paul
Quoted 52 lines
[ 290.218182] ------------[ cut here ]------------ [ 290.225425] kernel BUG at drivers/net/xen-netback/netback.c:664! [ 290.232717] invalid opcode: 0000 [#1] SMP [ 290.239875] Modules linked in: [ 290.246923] CPU: 0 PID: 10447 Comm: vif7.0 Not tainted 3.13.6-20140326- nbdebug35+ #1 [ 290.254040] Hardware name: MSI MS-7640/890FXA-GD70 (MS-7640) , BIOS V1.8B1 09/13/2010 [ 290.261313] task: ffff880055d16480 ti: ffff88004cb7e000 task.ti: ffff88004cb7e000 [ 290.268713] RIP: e030:[<ffffffff81780430>] [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.276193] RSP: e02b:ffff88004cb7fc28 EFLAGS: 00010202 [ 290.283555] RAX: 0000000000000006 RBX: ffff88004c630000 RCX: 3fffffffffffffff [ 290.290908] RDX: 00000000ffffffff RSI: ffff88004c630940 RDI: 0000000000048e7b [ 290.298325] RBP: ffff88004cb7fde8 R08: 0000000000007bc9 R09: 0000000000000005 [ 290.305809] R10: ffff88004cb7fd28 R11: ffffc90012690600 R12: 0000000000000004 [ 290.313217] R13: ffff8800536a84e0 R14: 0000000000000001 R15: ffff88004c637618 [ 290.320521] FS: 00007f1d3030c700(0000) GS:ffff88005f600000(0000) knlGS:0000000000000000 [ 290.327839] CS: e033 DS: 0000 ES: 0000 CR0: 000000008005003b [ 290.335216] CR2: ffffffffff600400 CR3: 0000000058537000 CR4: 0000000000000660 [ 290.342732] Stack: [ 290.350129] ffff88004cb7fd2c ffff880000000005 ffff88004cb7fd28 ffffffff810f7fc8 [ 290.357652] ffff880055d16b50 ffffffff00000407 ffff880000000000 ffffffff00000000 [ 290.365048] ffff880055d16b50 ffff880000000001 ffff880000000001 ffffffff00000000 [ 290.372461] Call Trace: [ 290.379806] [<ffffffff810f7fc8>] ? __lock_acquire+0x418/0x2220 [ 290.387211] [<ffffffff810df5f6>] ? finish_task_switch+0x46/0xf0 [ 290.394552] [<ffffffff81781400>] xenvif_kthread+0x40/0x190 [ 290.401808] [<ffffffff810f05e0>] ? __init_waitqueue_head+0x60/0x60 [ 290.408993] [<ffffffff817813c0>] ? xenvif_stop_queue+0x60/0x60 [ 290.416238] [<ffffffff810d4f24>] kthread+0xe4/0x100 [ 290.423428] [<ffffffff81b4cf30>] ? _raw_spin_unlock_irq+0x30/0x50 [ 290.430615] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.437793] [<ffffffff81b4e13c>] ret_from_fork+0x7c/0xb0 [ 290.444945] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.452091] Code: fd ff ff 48 8b b5 f0 fe ff ff 48 c7 c2 10 98 ce 81 31 c0 48 8b be c8 7c 00 00 48 c7 c6 f0 f1 fd 81 e8 35 be 24 00 e9 ba f8 ff ff <0f> 0b 0f 0b 41 bf 01 00 00 00 e9 55 f6 ff ff 0f 0b 66 66 66 66 [ 290.467121] RIP [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.474436] RSP <ffff88004cb7fc28> [ 290.482400] ---[ end trace 2fcf9e9ae26950b3 ]---
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantQuoted 99 lines · you
Quoted 68 lines
-----Original Message-----
From: Paul Durrant
Sent: 26 March 2014 17:47
To: 'Sander Eikelenboom'
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy" whileprod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 8 lines
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" but shortlyafter
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimating then theBUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the frags
..
Quoted 2 lines
and it isn't added to
npo->meta_prod?Quoted 9 lines
meta_slots_usedis calculated as the value ofmeta_prodat return (fromxenvif_gop_skb()) minus the value on entry , and if you look back up the code then you can see thatmeta_prodis incremented every timeRING_GET_REQUEST()is evaluated. So, we must be consuming a slot without evaluatingRING_GET_REQUEST()and I think that's exactly what's happening... Right at the bottom ofxenvif_gop_frag_copy()req_consis simply incremented in the case of a GSO. So theBUG_ON()is indeed off by one.Can you re-test with the following patch applied?
Paul
drivers/net/xen-netback/netback.c +2
-0@@ -482,6 +482,8 @@ static void xenvif_rx_action(struct xenvif *vif)while ((skb =skb_dequeue (&vif->rx_queue)) !=NULL ) {RING_IDX max_slots_needed; +RING_IDX old_req_cons; +RING_IDX ring_slots_used;int i;/* We need a cheap worse case estimate for the number of @@ -511,8 +513,12 @@ static void xenvif_rx_action(struct xenvif *vif) vif->rx_last_skb_slots =0 ; sco = (struct skb_cb_overlay *)skb->cb;
drivers/net/xen-netback/netback.c static void xenvif_rx_action(struct xenvif *vif) · line 524
Quoted 10 lines
drivers/net/xen-netback/netback.c +5
-1+ + old_req_cons = vif->rx.req_cons; sco->meta_slots_used =xenvif_gop_skb (skb, &npo); -BUG_ON (sco->meta_slots_used > max_slots_needed); + ring_slots_used = vif->rx.req_cons - old_req_cons; + +BUG_ON (ring_slots_used > max_slots_needed);__skb_queue_tail (&rxq, skb); }
That blew pretty fast .. on that BUG_ON
[ 290.218182] ------------[ cut here ]------------ [ 290.225425] kernel BUG at drivers/net/xen-netback/netback.c:664! [ 290.232717] invalid opcode: 0000 [#1] SMP [ 290.239875] Modules linked in: [ 290.246923] CPU: 0 PID: 10447 Comm: vif7.0 Not tainted 3.13.6-20140326-nbdebug35+ #1 [ 290.254040] Hardware name: MSI MS-7640/890FXA-GD70 (MS-7640) , BIOS V1.8B1 09/13/2010 [ 290.261313] task: ffff880055d16480 ti: ffff88004cb7e000 task.ti: ffff88004cb7e000 [ 290.268713] RIP: e030:[<ffffffff81780430>] [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.276193] RSP: e02b:ffff88004cb7fc28 EFLAGS: 00010202 [ 290.283555] RAX: 0000000000000006 RBX: ffff88004c630000 RCX: 3fffffffffffffff [ 290.290908] RDX: 00000000ffffffff RSI: ffff88004c630940 RDI: 0000000000048e7b [ 290.298325] RBP: ffff88004cb7fde8 R08: 0000000000007bc9 R09: 0000000000000005 [ 290.305809] R10: ffff88004cb7fd28 R11: ffffc90012690600 R12: 0000000000000004 [ 290.313217] R13: ffff8800536a84e0 R14: 0000000000000001 R15: ffff88004c637618 [ 290.320521] FS: 00007f1d3030c700(0000) GS:ffff88005f600000(0000) knlGS:0000000000000000 [ 290.327839] CS: e033 DS: 0000 ES: 0000 CR0: 000000008005003b [ 290.335216] CR2: ffffffffff600400 CR3: 0000000058537000 CR4: 0000000000000660 [ 290.342732] Stack: [ 290.350129] ffff88004cb7fd2c ffff880000000005 ffff88004cb7fd28 ffffffff810f7fc8 [ 290.357652] ffff880055d16b50 ffffffff00000407 ffff880000000000 ffffffff00000000 [ 290.365048] ffff880055d16b50 ffff880000000001 ffff880000000001 ffffffff00000000 [ 290.372461] Call Trace: [ 290.379806] [<ffffffff810f7fc8>] ? __lock_acquire+0x418/0x2220 [ 290.387211] [<ffffffff810df5f6>] ? finish_task_switch+0x46/0xf0 [ 290.394552] [<ffffffff81781400>] xenvif_kthread+0x40/0x190 [ 290.401808] [<ffffffff810f05e0>] ? __init_waitqueue_head+0x60/0x60 [ 290.408993] [<ffffffff817813c0>] ? xenvif_stop_queue+0x60/0x60 [ 290.416238] [<ffffffff810d4f24>] kthread+0xe4/0x100 [ 290.423428] [<ffffffff81b4cf30>] ? _raw_spin_unlock_irq+0x30/0x50 [ 290.430615] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.437793] [<ffffffff81b4e13c>] ret_from_fork+0x7c/0xb0 [ 290.444945] [<ffffffff810d4e40>] ? __init_kthread_worker+0x70/0x70 [ 290.452091] Code: fd ff ff 48 8b b5 f0 fe ff ff 48 c7 c2 10 98 ce 81 31 c0 48 8b be c8 7c 00 00 48 c7 c6 f0 f1 fd 81 e8 35 be 24 00 e9 ba f8 ff ff <0f> 0b 0f 0b 41 bf 01 00 00 00 e9 55 f6 ff ff 0f 0b 66 66 66 66 [ 290.467121] RIP [<ffffffff81780430>] xenvif_rx_action+0x1650/0x1670 [ 290.474436] RSP <ffff88004cb7fc28> [ 290.482400] ---[ end trace 2fcf9e9ae26950b3 ]---
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Sander EikelenboomQuoted 68 lines
-----Original Message-----
From: Paul Durrant
Sent: 26 March 2014 17:47
To: 'Sander Eikelenboom'
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: RE: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Re-send shortened version...
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"[snip]
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
- When processing an SKB we end up in "
xenvif_gop_frag_copy" whileprod
Quoted 7 lines
Quoted 7 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have
become
Quoted 8 lines
Quoted 1 line
Quoted 1 line
free (you see cons become > prod in "
get_next_rx_buffer" but shortlyafter
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculationthen
Quoted 9 lines
why is that
BUG_ONnot firing?You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?That code excerpt is from net_rx_action(),isn't it?
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating
max_slots_neededwere underestimating then theBUG_ON()should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or thatmeta_slots_usedis not equal to the number of ring slots consumed.Quoted 1 line
But probably because "npo->copy_prod++" seems to be used for the frags
..
Quoted 2 lines
and it isn't added to
npo->meta_prod?
Quoted 9 lines
meta_slots_usedis calculated as the value ofmeta_prodat return (fromxenvif_gop_skb()) minus the value on entry , and if you look back up the code then you can see thatmeta_prodis incremented every timeRING_GET_REQUEST()is evaluated. So, we must be consuming a slot without evaluatingRING_GET_REQUEST()and I think that's exactly what's happening... Right at the bottom ofxenvif_gop_frag_copy()req_consis simply incremented in the case of a GSO. So theBUG_ON()is indeed off by one.
Can you re-test with the following patch applied?
Paul
drivers/net/xen-netback/netback.c +7 -1
@@ -482,6 +482,8 @@ static void xenvif_rx_action(struct xenvif *vif)while ((skb =skb_dequeue (&vif->rx_queue)) !=NULL ) {RING_IDX max_slots_needed; +RING_IDX old_req_cons; +RING_IDX ring_slots_used;int i;/* We need a cheap worse case estimate for the number of
@@ -511,8 +513,12 @@ static void xenvif_rx_action(struct xenvif *vif) vif->rx_last_skb_slots =0 ; sco = (struct skb_cb_overlay *)skb->cb; + + old_req_cons = vif->rx.req_cons; sco->meta_slots_used =xenvif_gop_skb (skb, &npo); -BUG_ON (sco->meta_slots_used > max_slots_needed); + ring_slots_used = vif->rx.req_cons - old_req_cons; + +BUG_ON (ring_slots_used > max_slots_needed);__skb_queue_tail (&rxq, skb); }
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantHi Paul,
Seems your last mail arrived in pretty bad shape (truncated) in my mailbox ..
--
Sander
Quoted 82 lines · you
Quoted 82 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:07
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 18 lines
Quoted 18 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 15:23
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 5 lines
Quoted 5 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 11:11
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; IanCampbell;
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
linux-
Quoted 2 lines
Quoted 2 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13Network
Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
troubles "bisected"
Paul,
You have been awfully silent for this whole thread while this is a
regression
Quoted 2 lines
Quoted 2 lines
caused by a patch of you (
ca2f09f2b2c6c25047cfc545d057c4edfcfe561cas clearly stated muchearlier
Quoted 4 lines
Quoted 4 lines
in
Quoted 2 lines
Quoted 2 lines
this thread).
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Sorry, I've been distracted...
Quoted 4 lines
The commit messages states:
"net_rx_action()is the place where we could do with an accurate
predicition but,
since that has proven tricky to calculate, a cheap worse-case (butnot
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
too
Quoted 2 lines
Quoted 2 lines
bad)
estimate is all we really need since the only thing we *must*prevent
Quoted 5 lines
Quoted 5 lines
is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
xenvif_gop_skb()
consuming more slots than are available."Your "worst-case" calculation stated in the commit message is
clearly
Quoted 4 lines
Quoted 4 lines
not
Quoted 3 lines
Quoted 3 lines
the
Quoted 2 lines
Quoted 2 lines
worst case,
since it doesn't take calls to "get_next_rx_buffer" into account
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Sander EikelenboomQuoted 200 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:54
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:07
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 18 lines
Quoted 18 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 15:23
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 5 lines
Quoted 5 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 11:11
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; IanCampbell;
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
linux-
Quoted 2 lines
Quoted 2 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13Network
Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
troubles "bisected"
Paul,
You have been awfully silent for this whole thread while this is a
regression
Quoted 2 lines
Quoted 2 lines
caused by a patch of you (
ca2f09f2b2c6c25047cfc545d057c4edfcfe561cas clearly stated muchearlier
Quoted 4 lines
Quoted 4 lines
in
Quoted 2 lines
Quoted 2 lines
this thread).
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Sorry, I've been distracted...
Quoted 4 lines
The commit messages states:
"net_rx_action()is the place where we could do with an accurate
predicition but,
since that has proven tricky to calculate, a cheap worse-case (butnot
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
too
Quoted 2 lines
Quoted 2 lines
bad)
estimate is all we really need since the only thing we *must*prevent
Quoted 5 lines
Quoted 5 lines
is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
xenvif_gop_skb()
consuming more slots than are available."Your "worst-case" calculation stated in the commit message is
clearly
Quoted 9 lines
Quoted 9 lines
not
Quoted 6 lines
Quoted 6 lines
the
Quoted 5 lines
Quoted 3 lines
worst case,
since it doesn't take calls to "get_next_rx_buffer" into account.It should be taking into account the behaviour of
start_new_rx_buffer(),Quoted 1 line
Quoted 1 line
which should be true if a slot is full or a frag will overflow the current
slot
Quoted 31 lines
Quoted 31 lines
and
Quoted 29 lines
Quoted 29 lines
doesn't require splitting.
Quoted 1 line
The code in
net_rx_action()makes the assumption that each frag willrequire as many slots as its size requires, i.e. it assumes no packing of multiple frags into a single slot, so it should be a worst case.
Quoted 1 line
Did I miss something in that logic?
Yes.
In "xenvif_gop_skb()" this loop:for (i = 0; i < nr_frags; i++) { xenvif_gop_frag_copy(vif, skb, npo, skb_frag_page(&skb_shinfo(skb)->frags[i]), skb_frag_size(&skb_shinfo(skb)->frags[i]), skb_shinfo(skb)->frags[i].page_offset, &head); }Is capable of using up (at least) 1 slot more than is anticipated for in "
net_rx_action()" by this code:for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size, PAGE_SIZE); }And this happens when it calls "
get_next_rx_buffer()" from "xenvif_gop_frag_copy()" where it's breaking down the frag.Quoted 5 lines
Quoted 5 lines
Quoted 1 line
The function that determines whether to consume another slot is
start_new_rx_buffer()and for each frag I don't see why this would return true more thanDIV_ROUND_UP(size, PAGE_SIZE)times.Quoted 1 line
It may be called more times than that since the code in
xenvif_gop_frag_copy()must also allow for the offset of the frag butshould
Quoted 21 lines
Quoted 8 lines
not return true in all cases.
Quoted 1 line
So, I still cannot see why a frag would ever consume more than
DIV_ROUND_UP(size, PAGE_SIZE)slots.Well here a case were a frag is broken down in 2 pieces:
[ 1156.870372] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here 1 npo-Quoted 1 line
meta_prod:39 vif->rx.sring->req_prod:2105867 vif-
rx.req_cons:2105867
Quoted 9 lines
npo->copy_gref:760 npo->copy_off:4096 MAX_BUFFER_OFFSET:4096 bytes:560 size:560 offset:0 head:1273462060 i:2 vif->rx.sring-
Quoted 1 line
req_event:2104275 estimated_slots_needed:4 reserved_slots_left:0
[ 1156.871971] vif vif-7-0 vif7.0: ?!? xenvif_start_xmit stopping queue !min_slots_needed:1 min_slots_needed_2:0 min_slots_needed_3:0 vif-
Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105867 vif->rx.sring- req_event:2105868 skb->len:66 skb->data_len:0
[ 1156.964316] vif vif-7-0 vif7.0: ?!? get_next_rx_buffer before req npo-Quoted 1 line
meta_prod:39 vif->rx.sring->req_prod:2105867 vif-
rx.req_cons:2105867
Quoted 2 lines
vif->rx.sring->req_event:2105868, reserved_slots_left:0
[ 1157.001635] vif vif-7-0 vif7.0: ?!? get_next_rx_buffer after req npo-Quoted 11 lines
Quoted 1 line
Quoted 1 line
meta_prod:39 vif->rx.sring->req_prod:2105867 vif-
rx.req_cons:2105868
Quoted 4 lines
req->gref:4325379 req->id:11 vif->rx.sring->req_event:2105868 reserved_slots_left:-1
[ 1157.039095] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here 2 npo-Quoted 1 line
meta_prod:40 vif->rx.sring->req_prod:2105867 vif-
rx.req_cons:2105868
Quoted 4 lines
npo->copy_gref:4325379 npo->copy_off:0 MAX_BUFFER_OFFSET:4096 bytes:560 size:560 offset:0 head:1273462060 i:2 vif->rx.sring-
Quoted 1 line
req_event:2105868 estimated_slots_needed:4 reserved_slots_left:-1
[ 1157.095216] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here endnpo-
Quoted 24 lines
Quoted 1 line
Quoted 1 line
meta_prod:40 vif->rx.sring->req_prod:2105867 vif-
rx.req_cons:2105868
Quoted 22 lines
npo->copy_gref:4325379 npo->copy_off:560 MAX_BUFFER_OFFSET:4096 bytes:560 size:0 offset:560 head:1273462060 i:3 vif->rx.sring-
Quoted 1 line
req_event:2105868 gso_gaps:0 estimated_slots_needed:4
reserved_slots_left:-1
[ 1157.151338] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 4 after npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 i(frag):0 j(data):1 reserved_slots_left:-1
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
- When processing an SKB we end up in "
xenvif_gop_frag_copy" whileprod
Quoted 8 lines
Quoted 8 lines
== cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.Sometimes we are saved by the bell .. since additional slots have become free (you see cons become > prod in "
get_next_rx_buffer" but shortlyafter
Quoted 5 lines
Quoted 3 lines
that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>
max_slots_needed, so if we are overflowing the worst-case calculation then why is thatBUG_ONnot firing?
Quoted 7 lines
You mean:
sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); BUG_ON(sco->meta_slots_used > max_slots_needed);in "
get_next_rx_buffer" ?
That code excerpt is from net_rx_action(),isn't it?
Quoted 3 lines
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
Well, if the code calculating max_slots_needed were underestimating then the BUG_ON() should fire. If it is not firing in your case then this suggests your problem lies elsewhere, or that meta_slots_used is not equal to the number of ring slots consumed.
Quoted 3 lines
But probably because "npo->copy_prod++" seems to be used for the frags .. and it isn't added to
npo->meta_prod?
meta_slots_used is calculated as the value of meta_prod at return (from xenvif_gop_skb()) minus the value on entry , and if you look back up the code then you can see that meta_prod is incremented every time RING_GET_REQUEST() is evaluated. So, we must be consuming a slot without evaluating RING_GET_REQUEST() and I think that's exactly what's happening... Right at the bottom of xenvif_gop_frag_copy() req_cons is simply incremented in the case of a GSO. So the BUG_ON() is indeed off by one.
Paul
Quoted 264 lines
--
SanderQuoted 3 lines
Paul
Quoted 1 line
If you need additional / other info, please cook up a debug patch with
what
Quoted 10 lines
Quoted 10 lines
you need.
--
SanderQuoted 7 lines
Quoted 7 lines
Quoted 3 lines
Paul
Quoted 1 line
Ultimately this results in bad grant reference warnings (and packets
marked
Quoted 3 lines
Quoted 3 lines
as "errors" in the interface statistics).
In my case it always seems to be a skb with 1 frag which is broken
down in
Quoted 7 lines
Quoted 7 lines
5
Quoted 3 lines
Quoted 3 lines
or 6 pieces ..
So "
get_next_rx_buffer()" is called once .. and i'm overrunning the ringwith
Quoted 2 lines
Quoted 2 lines
1 slot, but i'm not sure if that's not coincedence
since in the code there seem to be no explicit limitation on how oftenthis
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
code path is taken. So perhaps it's implicitly limited
since packets and frags can't be arbitrarily large in comparison with thepage_sizebut that's not something i'm capable of figuring out :-)Quoted 3 lines
Paul
Quoted 1 line
Problem is that a worst case calculation would probably be reverting
to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the
Quoted 2 lines
Quoted 2 lines
old calculation,
and the problems this patch was trying to solve would reappear,but
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
introducing new regressions
isn't very useful either. And since it seems such a tricky and fragilething to
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
determine, it would
probably be best to be split into a distinct function with a commentto
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
explain
Quoted 3 lines
Quoted 3 lines
the rationale used.
Since this doesn't seem to progress very fast .. CC'ed some more
folks
Quoted 11 lines
Quoted 11 lines
..
Quoted 10 lines
Quoted 10 lines
you
Quoted 9 lines
Quoted 9 lines
never know ..
--
SanderTuesday, March 25, 2014, 4:29:42 PM, you wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line · you
On Sat, Mar 22, 2014 at 07:28:34PM +0100, Sander Eikelenboom
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[...]
Quoted 1 line
Quoted 1 line
Yes there is only one frag .. but it seems to be much larger
than
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
PAGE_SIZE.. andxenvif_gop_frag_copybrakes that frag down intosmaller
Quoted 1 line
Quoted 1 line
bits .. hence the calculation in
xenvif_rx_actiondetermining theslots
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
needed
Quoted 6 lines
Quoted 6 lines
by doing:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
for (i = 0; i < nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size,Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
PAGE_SIZE);Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
}But the code in
xenvif_gop_frag_copy.. seems to be needingone
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
more slot (from the emperical test) .. and calling
"
get_next_rx_buffer"Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
seems involved in that ..
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Hmm looked again .. and it seems this is it .. when your frags
are
Quoted 8 lines
Quoted 8 lines
large
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
enough you have the chance of running into this.
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
get_next_rx_bufferis guarded bystart_new_rx_buffer. Do yousee
Quoted 2 lines
Quoted 2 lines
any
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
problem with that implementation?
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
In general no, but "
get_next_rx_buffer" up's cons .. and thecalculations
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
done in "
xenvif_rx_action" formax_slots_neededto prevent theoverrun
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
don't count in this possibility. So it's not the guarding of
"
start_new_rx_buffer" that is at fault. It's the ones early in "xenvif_rx_action".Quoted 1 line
The ones that were changed by Paul's patch from
MAX_SKB_FRAGSQuoted 9 lines
Quoted 9 lines
to a
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
calculated value that should be a "slim fit".
Quoted 1 line
The problem is in determining upfront in "
xenvif_rx_action" whenand
Quoted 3 lines
Quoted 3 lines
how
Quoted 2 lines
Quoted 2 lines
often the "
get_next_rx_buffer" path will be taken.Quoted 1 line
Unless there are other non direct restrictions (from a size point of
view)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
it
Quoted 3 lines
Quoted 3 lines
can be called multiple times per frag per skb.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Problem is .. i don't see an easy fix, the "one more slot" of the
empirical
Quoted 3 lines
Quoted 3 lines
test doesn't seem to be the worst case either (i think):
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- In my case the packets that hit this only have 1 frag, but i
could
Quoted 4 lines
Quoted 4 lines
have
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
had more frags.
Quoted 1 line
Quoted 1 line
Quoted 1 line
I also think you can't rule out the possibility of doing the
"
get_next_rx_buffer" for multiple subsequent frags from onepacket,
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
so in the worst (and perhaps even from a single frag since it's
looped
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
over a split of it in what seems
PAGE_SIZEpieces.)Quoted 1 line
Quoted 1 line
Quoted 1 line
- So an exact calculation of how much slots we are going to
need
Quoted 2 lines
Quoted 2 lines
for
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
hitting this "
get_next_rx_buffer" upfront in "xenvif_rx_action"seems
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
unfeasible.
Quoted 1 line
Quoted 1 line
Quoted 1 line
- A worst case gamble seems impossible either .. if you take
multiple
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
frags * multiple times the "
get_next_rx_buffer" ... you wouldprobably
Quoted 8 lines
Quoted 8 lines
be
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
back at just
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
setting the
needed_slotstoMAX_SKB_FRAGS.- Other thing would be checking for the available slots before
doing
Quoted 2 lines
Quoted 2 lines
the
Quoted 1 line
Quoted 1 line
"
get_next_rx_buffer" .. how ever .. we don't account for howmany
Quoted 7 lines
Quoted 7 lines
slots
Quoted 6 lines
Quoted 6 lines
we
Quoted 5 lines
Quoted 5 lines
still need to
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
just process the remaining frags.
We've done a worst case estimation for whole SKB (linear area +
all
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
frags) already, at the very first beginning. That's what
max_slots_neededis for.Quoted 1 line
- Just remove the whole "
get_next_rx_buffer".. just tested itbut
Quoted 5 lines
Quoted 5 lines
it
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
seems the "
get_next_rx_buffer" is necessary .. when i makestart_new_rx_bufferalways return falseQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
i hit the bug below :S
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
So the questions are ... is the "
get_next_rx_buffer" part reallynecessary
Quoted 2 lines
Quoted 2 lines
?
Quoted 1 line
Quoted 1 line
Quoted 1 line
- if not, what is the benefit of the "
get_next_rx_buffer" anddoes
Quoted 3 lines
Quoted 3 lines
that
Quoted 2 lines
Quoted 2 lines
outweigh the additional cost of accounting
Quoted 1 line
Quoted 1 line
Quoted 1 line
of
needed_slotsfor the frags that have yet to be processed?
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
- if yes, erhmmm what would be the best acceptable solution
..
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
returning to using
MAX_SKB_FRAGS?Quoted 4 lines
Quoted 4 lines
Quoted 1 line
I think you need to answer several questions first:
1. ismax_slots_neededactually large enough to cover wholeSKB?
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
No it's not if, you end up calling "
get_next_rx_buffer" one ormultiple
Quoted 2 lines
Quoted 2 lines
times when processing the SKB
Quoted 1 line
you have the chance of overrunning (or be saved because
prod
Quoted 8 lines
Quoted 8 lines
gets
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
upped before you overrun).
Quoted 4 lines
Quoted 1 line
2. is the test of ring slot availability acurate?
Seems to be.
Quoted 1 line
3. is the number of ring slots consumed larger than
max_slots_needed? (IQuoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
guess the answer is yes)
Yes that was the whole point.
Quoted 1 line
4. which step in the break-down procedure causes backend to
overrun
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the
Quoted 2 lines
Quoted 1 line
ring?
The "
get_next_rx_buffer" call .. that is not accounted for(which
Quoted 7 lines
Quoted 7 lines
can
Quoted 6 lines
Quoted 6 lines
be
Quoted 5 lines
Quoted 5 lines
called
Quoted 1 line
multiple times per frag (unless some other none obvious size
restriction limits this
Quoted 2 lines
to one time per frag or one time per SKB).
In my errorneous case it is called one time, but it would benice if
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
there
Quoted 5 lines
Quoted 5 lines
would be some theoretical proof
Quoted 4 lines
instead of just some emperical test.
Quoted 1 line
It doesn't matter how many frags your SKB has and how big a
frag
Quoted 3 lines
Quoted 3 lines
is. If
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
every step is correct then you're fine. The code you're looking at (
start_new_rx_buffer/get_next_rx_bufferand friend) needsto
Quoted 4 lines
Quoted 4 lines
be
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
carefully examined.
Well it seems it only calls "
get_next_rx_buffer" in some specialcases
Quoted 8 lines
Quoted 8 lines
..
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(and that also what i'm seeing because it doesn't happen
Quoted 3 lines
continously.
Question is shouldn't this
max_needed_slotscalc be reverted towhat it
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
was before 3.14 and take the time in 3.15 to figure out a
Quoted 1 line
the theoretical max (if it can be calculated upfront) .. or another
way
Quoted 12 lines
Quoted 12 lines
to
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
guarantee the code is able to process the whole SKB ?
Quoted 1 line
Quoted 1 line
Wei.
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantQuoted 162 lines · you
Quoted 162 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:07
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 15:23
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 17 lines
Quoted 17 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 11:11
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 4 lines
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Paul,
You have been awfully silent for this whole thread while this is a
regression
Quoted 2 lines
Quoted 2 lines
caused by a patch of you (
ca2f09f2b2c6c25047cfc545d057c4edfcfe561cas clearly stated muchearlier
Quoted 6 lines
Quoted 6 lines
in
Quoted 4 lines
Quoted 2 lines
this thread).
Sorry, I've been distracted...
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
The commit messages states:
"net_rx_action()is the place where we could do with an accurate
predicition but,
since that has proven tricky to calculate, a cheap worse-case (but nottoo
Quoted 2 lines
Quoted 2 lines
bad)
estimate is all we really need since the only thing we *must* preventis
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
xenvif_gop_skb()
consuming more slots than are available."Your "worst-case" calculation stated in the commit message is clearly
not
Quoted 6 lines
Quoted 6 lines
the
Quoted 5 lines
Quoted 3 lines
worst case,
since it doesn't take calls to "get_next_rx_buffer" into account.It should be taking into account the behaviour of
start_new_rx_buffer(),Quoted 1 line
Quoted 1 line
which should be true if a slot is full or a frag will overflow the current slot
and
Quoted 26 lines
Quoted 26 lines
doesn't require splitting.
Quoted 1 line
The code in
net_rx_action()makes the assumption that each frag willrequire as many slots as its size requires, i.e. it assumes no packing of multiple frags into a single slot, so it should be a worst case.
Quoted 1 line
Did I miss something in that logic?
Yes.
In "xenvif_gop_skb()" this loop:for (i = 0; i < nr_frags; i++) { xenvif_gop_frag_copy(vif, skb, npo, skb_frag_page(&skb_shinfo(skb)->frags[i]), skb_frag_size(&skb_shinfo(skb)->frags[i]), skb_shinfo(skb)->frags[i].page_offset, &head); }Is capable of using up (at least) 1 slot more than is anticipated for in "
net_rx_action()" by this code:for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size, PAGE_SIZE); }Quoted 5 lines
Quoted 3 lines
And this happens when it calls "
get_next_rx_buffer()" from "xenvif_gop_frag_copy()" where it's breaking down the frag.The function that determines whether to consume another slot is
start_new_rx_buffer()and for each frag I don't see why this would return true more thanDIV_ROUND_UP(size, PAGE_SIZE)times.Quoted 1 line
It may be called more times than that since the code in
xenvif_gop_frag_copy()must also allow for the offset of the frag but should not return true in all cases.Quoted 1 line
So, I still cannot see why a frag would ever consume more than
DIV_ROUND_UP(size, PAGE_SIZE)slots.Well here a case were a frag is broken down in 2 pieces:
[ 1156.870372] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here 1 npo-Quoted 1 line
meta_prod:39 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105867
npo->copy_gref:760 npo->copy_off:4096 MAX_BUFFER_OFFSET:4096 bytes:560 size:560 offset:0 head:1273462060 i:2 vif->rx.sring-
Quoted 1 line
req_event:2104275 estimated_slots_needed:4 reserved_slots_left:0
[ 1156.871971] vif vif-7-0 vif7.0: ?!? xenvif_start_xmit stopping queue !min_slots_needed:1 min_slots_needed_2:0 min_slots_needed_3:0 vif-
Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105867 vif->rx.sring- req_event:2105868 skb->len:66 skb->data_len:0
[ 1156.964316] vif vif-7-0 vif7.0: ?!? get_next_rx_buffer before req npo-Quoted 1 line
meta_prod:39 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105867
vif->rx.sring->req_event:2105868, reserved_slots_left:0
[ 1157.001635] vif vif-7-0 vif7.0: ?!? get_next_rx_buffer after req npo-Quoted 1 line
meta_prod:39 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868
req->gref:4325379 req->id:11 vif->rx.sring->req_event:2105868 reserved_slots_left:-1
[ 1157.039095] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here 2 npo-Quoted 1 line
meta_prod:40 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868
npo->copy_gref:4325379 npo->copy_off:0 MAX_BUFFER_OFFSET:4096 bytes:560 size:560 offset:0 head:1273462060 i:2 vif->rx.sring-
Quoted 1 line
req_event:2105868 estimated_slots_needed:4 reserved_slots_left:-1
[ 1157.095216] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here end npo-Quoted 1 line
meta_prod:40 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868
npo->copy_gref:4325379 npo->copy_off:560 MAX_BUFFER_OFFSET:4096 bytes:560 size:0 offset:560 head:1273462060 i:3 vif->rx.sring-
Quoted 1 line
req_event:2105868 gso_gaps:0 estimated_slots_needed:4
reserved_slots_left:-1
[ 1157.151338] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 4 after npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 i(frag):0 j(data):1 reserved_slots_left:-1
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
- When processing an SKB we end up in "
xenvif_gop_frag_copy" while prod == cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.
Quoted 7 lines
Quoted 5 lines
Sometimes we are saved by the bell .. since additional slots have become free (you see cons become > prod in "
get_next_rx_buffer" but shortly after that prod is increased ..
just in time to not cause a overrun).Ah, but hang on... There's a
BUG_ONmeta_slots_used>max_slots_needed, so if we are overflowing the worst-case calculation then why is thatBUG_ONnot firing?
You mean:
sco = (struct skb_cb_overlay *)skb->cb;
sco->meta_slots_used = xenvif_gop_skb(skb, &npo);
BUG_ON(sco->meta_slots_used > max_slots_needed);in "get_next_rx_buffer" ?
I don't know .. at least now it doesn't crash dom0 and therefore not my complete machine and since tcp is recovering from a failed packet :-)
But probably because "npo->copy_prod++" seems to be used for the frags .. and it isn't added to npo->meta_prod ?
--
Sander
Quoted 229 lines
Paul
Quoted 227 lines
If you need additional / other info, please cook up a debug patch with what you need.
--
SanderQuoted 3 lines
Paul
Quoted 1 line
Ultimately this results in bad grant reference warnings (and packets
marked
Quoted 3 lines
Quoted 3 lines
as "errors" in the interface statistics).
In my case it always seems to be a skb with 1 frag which is broken down in
5
Quoted 3 lines
Quoted 3 lines
or 6 pieces ..
So "
get_next_rx_buffer()" is called once .. and i'm overrunning the ringwith
Quoted 8 lines
Quoted 8 lines
1 slot, but i'm not sure if that's not coincedence
since in the code there seem to be no explicit limitation on how often this code path is taken. So perhaps it's implicitly limited
since packets and frags can't be arbitrarily large in comparison with thepage_sizebut that's not something i'm capable of figuring out :-)Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Paul
Quoted 1 line
Problem is that a worst case calculation would probably be reverting to
the
Quoted 4 lines
Quoted 4 lines
old calculation,
and the problems this patch was trying to solve would reappear, but introducing new regressions
isn't very useful either. And since it seems such a tricky and fragilething to
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
determine, it would
probably be best to be split into a distinct function with a comment toexplain
Quoted 3 lines
Quoted 3 lines
the rationale used.
Since this doesn't seem to progress very fast .. CC'ed some more folks
..
Quoted 13 lines
Quoted 13 lines
you
Quoted 12 lines
Quoted 12 lines
never know ..
--
SanderQuoted 3 lines · you
Quoted 1 line · you
On Sat, Mar 22, 2014 at 07:28:34PM +0100, Sander Eikelenboom
Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
[...]
Quoted 1 line
Quoted 1 line
Yes there is only one frag .. but it seems to be much larger than
PAGE_SIZE.. andxenvif_gop_frag_copybrakes that frag down intosmaller
Quoted 1 line
Quoted 1 line
bits .. hence the calculation in
xenvif_rx_actiondetermining the slotsneeded
Quoted 2 lines
Quoted 2 lines
by doing:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
for (i = 0; i < nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size,
PAGE_SIZE);Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
}But the code in
xenvif_gop_frag_copy.. seems to be needingone
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
more slot (from the emperical test) .. and calling "
get_next_rx_buffer" seems involved in that ..Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Hmm looked again .. and it seems this is it .. when your frags are
large
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
enough you have the chance of running into this.
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
get_next_rx_bufferis guarded bystart_new_rx_buffer. Do yousee
Quoted 3 lines
Quoted 3 lines
any
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
problem with that implementation?
In general no, but "
get_next_rx_buffer" up's cons .. and thecalculations
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
done in "
xenvif_rx_action" formax_slots_neededto prevent theoverrun
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
don't count in this possibility. So it's not the guarding of
"
start_new_rx_buffer" that is at fault. It's the ones early in "xenvif_rx_action".Quoted 1 line
The ones that were changed by Paul's patch from
MAX_SKB_FRAGSto a
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
calculated value that should be a "slim fit".
Quoted 1 line
The problem is in determining upfront in "
xenvif_rx_action" whenand
Quoted 3 lines
Quoted 3 lines
how
Quoted 2 lines
Quoted 2 lines
often the "
get_next_rx_buffer" path will be taken.Quoted 1 line
Unless there are other non direct restrictions (from a size point of
view)
Quoted 8 lines
Quoted 8 lines
it
Quoted 3 lines
Quoted 3 lines
can be called multiple times per frag per skb.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Problem is .. i don't see an easy fix, the "one more slot" of the
empirical
Quoted 3 lines
Quoted 3 lines
test doesn't seem to be the worst case either (i think):
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- In my case the packets that hit this only have 1 frag, but i could
have
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
had more frags.
Quoted 1 line
Quoted 1 line
Quoted 1 line
I also think you can't rule out the possibility of doing the
"
get_next_rx_buffer" for multiple subsequent frags from one packet,Quoted 1 line
Quoted 1 line
Quoted 1 line
so in the worst (and perhaps even from a single frag since it's
looped
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
over a split of it in what seems
PAGE_SIZEpieces.)Quoted 1 line
Quoted 1 line
Quoted 1 line
- So an exact calculation of how much slots we are going to need
for
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
hitting this "
get_next_rx_buffer" upfront in "xenvif_rx_action" seems unfeasible.Quoted 1 line
Quoted 1 line
Quoted 1 line
- A worst case gamble seems impossible either .. if you take
multiple
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
frags * multiple times the "
get_next_rx_buffer" ... you would probablybe
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
back at just
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
setting the
needed_slotstoMAX_SKB_FRAGS.- Other thing would be checking for the available slots before
doing
Quoted 2 lines
Quoted 2 lines
the
Quoted 1 line
Quoted 1 line
"
get_next_rx_buffer" .. how ever .. we don't account for how manyslots
Quoted 10 lines
Quoted 10 lines
we
Quoted 9 lines
Quoted 9 lines
still need to
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
just process the remaining frags.
We've done a worst case estimation for whole SKB (linear area + all frags) already, at the very first beginning. That's what
max_slots_neededis for.Quoted 1 line
- Just remove the whole "
get_next_rx_buffer".. just tested it butit
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
seems the "
get_next_rx_buffer" is necessary .. when i makestart_new_rx_bufferalways return falseQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
i hit the bug below :S
So the questions are ... is the "
get_next_rx_buffer" part reallynecessary
Quoted 2 lines
Quoted 2 lines
?
Quoted 1 line
Quoted 1 line
Quoted 1 line
- if not, what is the benefit of the "
get_next_rx_buffer" anddoes
Quoted 7 lines
Quoted 7 lines
that
Quoted 6 lines
Quoted 6 lines
outweigh the additional cost of accounting
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
of
needed_slotsfor the frags that have yet to be processed ?
- if yes, erhmmm what would be the best acceptable solution ..returning to using
MAX_SKB_FRAGS?Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
I think you need to answer several questions first:
1. ismax_slots_neededactually large enough to cover whole SKB?No it's not if, you end up calling "
get_next_rx_buffer" one ormultiple
Quoted 2 lines
Quoted 2 lines
times when processing the SKB
Quoted 1 line
you have the chance of overrunning (or be saved because prod
gets
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
Quoted 6 lines
upped before you overrun).
Quoted 4 lines
Quoted 1 line
2. is the test of ring slot availability acurate?
Seems to be.
Quoted 1 line
3. is the number of ring slots consumed larger than
max_slots_needed? (IQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
guess the answer is yes)
Yes that was the whole point.
Quoted 1 line
4. which step in the break-down procedure causes backend to
overrun
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the
Quoted 2 lines
Quoted 1 line
ring?
The "
get_next_rx_buffer" call .. that is not accounted for (whichcan
Quoted 4 lines
Quoted 4 lines
be
Quoted 3 lines
Quoted 3 lines
called
Quoted 1 line
multiple times per frag (unless some other none obvious size
restriction limits this
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
to one time per frag or one time per SKB).
In my errorneous case it is called one time, but it would be nice ifthere
Quoted 5 lines
Quoted 5 lines
would be some theoretical proof
Quoted 4 lines
instead of just some emperical test.
Quoted 1 line
It doesn't matter how many frags your SKB has and how big a frag
is. If
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
every step is correct then you're fine. The code you're looking at (
start_new_rx_buffer/get_next_rx_bufferand friend) needs tobe
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
carefully examined.
Well it seems it only calls "
get_next_rx_buffer" in some special cases..
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(and that also what i'm seeing because it doesn't happen
Quoted 3 lines
continously.
Question is shouldn't this
max_needed_slotscalc be reverted towhat it
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
was before 3.14 and take the time in 3.15 to figure out a
Quoted 1 line
the theoretical max (if it can be calculated upfront) .. or another way
to
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
guarantee the code is able to process the whole SKB ?
Quoted 1 line
Quoted 1 line
Wei.
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Sander EikelenboomQuoted 162 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 16:07
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 15:23
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 17 lines
Quoted 17 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 11:11
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 4 lines
Quoted 4 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Paul,
You have been awfully silent for this whole thread while this is a
regression
Quoted 2 lines
Quoted 2 lines
caused by a patch of you (
ca2f09f2b2c6c25047cfc545d057c4edfcfe561cas clearly stated muchearlier
Quoted 6 lines
Quoted 6 lines
in
Quoted 4 lines
Quoted 2 lines
this thread).
Sorry, I've been distracted...
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
The commit messages states:
"net_rx_action()is the place where we could do with an accurate
predicition but,
since that has proven tricky to calculate, a cheap worse-case (but nottoo
Quoted 2 lines
Quoted 2 lines
bad)
estimate is all we really need since the only thing we *must* preventis
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
xenvif_gop_skb()
consuming more slots than are available."Your "worst-case" calculation stated in the commit message is clearly
not
Quoted 6 lines
Quoted 6 lines
the
Quoted 5 lines
Quoted 3 lines
worst case,
since it doesn't take calls to "get_next_rx_buffer" into account.It should be taking into account the behaviour of
start_new_rx_buffer(),Quoted 1 line
Quoted 1 line
which should be true if a slot is full or a frag will overflow the current slot
and
Quoted 26 lines
Quoted 26 lines
doesn't require splitting.
Quoted 1 line
The code in
net_rx_action()makes the assumption that each frag willrequire as many slots as its size requires, i.e. it assumes no packing of multiple frags into a single slot, so it should be a worst case.
Quoted 1 line
Did I miss something in that logic?
Yes.
In "xenvif_gop_skb()" this loop:for (i = 0; i < nr_frags; i++) { xenvif_gop_frag_copy(vif, skb, npo, skb_frag_page(&skb_shinfo(skb)->frags[i]), skb_frag_size(&skb_shinfo(skb)->frags[i]), skb_shinfo(skb)->frags[i].page_offset, &head); }Is capable of using up (at least) 1 slot more than is anticipated for in "
net_rx_action()" by this code:for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size, PAGE_SIZE); }Quoted 5 lines
Quoted 3 lines
And this happens when it calls "
get_next_rx_buffer()" from "xenvif_gop_frag_copy()" where it's breaking down the frag.The function that determines whether to consume another slot is
start_new_rx_buffer()and for each frag I don't see why this would return true more thanDIV_ROUND_UP(size, PAGE_SIZE)times.Quoted 1 line
It may be called more times than that since the code in
xenvif_gop_frag_copy()must also allow for the offset of the frag but should not return true in all cases.Quoted 1 line
So, I still cannot see why a frag would ever consume more than
DIV_ROUND_UP(size, PAGE_SIZE)slots.Well here a case were a frag is broken down in 2 pieces:
[ 1156.870372] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here 1 npo-Quoted 1 line
meta_prod:39 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105867
npo->copy_gref:760 npo->copy_off:4096 MAX_BUFFER_OFFSET:4096 bytes:560 size:560 offset:0 head:1273462060 i:2 vif->rx.sring-
Quoted 1 line
req_event:2104275 estimated_slots_needed:4 reserved_slots_left:0
[ 1156.871971] vif vif-7-0 vif7.0: ?!? xenvif_start_xmit stopping queue !min_slots_needed:1 min_slots_needed_2:0 min_slots_needed_3:0 vif-
Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105867 vif->rx.sring- req_event:2105868 skb->len:66 skb->data_len:0
[ 1156.964316] vif vif-7-0 vif7.0: ?!? get_next_rx_buffer before req npo-Quoted 1 line
meta_prod:39 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105867
vif->rx.sring->req_event:2105868, reserved_slots_left:0
[ 1157.001635] vif vif-7-0 vif7.0: ?!? get_next_rx_buffer after req npo-Quoted 1 line
meta_prod:39 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868
req->gref:4325379 req->id:11 vif->rx.sring->req_event:2105868 reserved_slots_left:-1
[ 1157.039095] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here 2 npo-Quoted 1 line
meta_prod:40 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868
npo->copy_gref:4325379 npo->copy_off:0 MAX_BUFFER_OFFSET:4096 bytes:560 size:560 offset:0 head:1273462060 i:2 vif->rx.sring-
Quoted 1 line
req_event:2105868 estimated_slots_needed:4 reserved_slots_left:-1
[ 1157.095216] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here end npo-Quoted 1 line
meta_prod:40 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868
npo->copy_gref:4325379 npo->copy_off:560 MAX_BUFFER_OFFSET:4096 bytes:560 size:0 offset:560 head:1273462060 i:3 vif->rx.sring-
Quoted 1 line
req_event:2105868 gso_gaps:0 estimated_slots_needed:4
reserved_slots_left:-1
[ 1157.151338] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 4 after npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 i(frag):0 j(data):1 reserved_slots_left:-1
[ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo-Quoted 2 lines
meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif- rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1
req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1
reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 ..
used_fragloop:3[ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif-Quoted 2 lines
rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco- meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1
max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
- When processing an SKB we end up in "
xenvif_gop_frag_copy" while prod == cons ... but we still have bytes and size left ..
-start_new_rx_buffer()has returned true ..
- so we end up inget_next_rx_buffer
- this does aRING_GET_REQUESTand ups cons ..
- and we end up with a bad grant reference.
Quoted 5 lines
Sometimes we are saved by the bell .. since additional slots have become free (you see cons become > prod in "
get_next_rx_buffer" but shortly after that prod is increased ..
just in time to not cause a overrun).
Ah, but hang on... There's a BUG_ON meta_slots_used > max_slots_needed, so if we are overflowing the worst-case calculation then why is that BUG_ON not firing?
Paul
Quoted 227 lines
If you need additional / other info, please cook up a debug patch with what you need.
--
SanderQuoted 3 lines
Paul
Quoted 1 line
Ultimately this results in bad grant reference warnings (and packets
marked
Quoted 3 lines
Quoted 3 lines
as "errors" in the interface statistics).
In my case it always seems to be a skb with 1 frag which is broken down in
5
Quoted 3 lines
Quoted 3 lines
or 6 pieces ..
So "
get_next_rx_buffer()" is called once .. and i'm overrunning the ringwith
Quoted 8 lines
Quoted 8 lines
1 slot, but i'm not sure if that's not coincedence
since in the code there seem to be no explicit limitation on how often this code path is taken. So perhaps it's implicitly limited
since packets and frags can't be arbitrarily large in comparison with thepage_sizebut that's not something i'm capable of figuring out :-)Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Paul
Quoted 1 line
Problem is that a worst case calculation would probably be reverting to
the
Quoted 4 lines
Quoted 4 lines
old calculation,
and the problems this patch was trying to solve would reappear, but introducing new regressions
isn't very useful either. And since it seems such a tricky and fragilething to
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
determine, it would
probably be best to be split into a distinct function with a comment toexplain
Quoted 3 lines
Quoted 3 lines
the rationale used.
Since this doesn't seem to progress very fast .. CC'ed some more folks
..
Quoted 13 lines
Quoted 13 lines
you
Quoted 12 lines
Quoted 12 lines
never know ..
--
SanderQuoted 3 lines · you
Quoted 1 line · you
On Sat, Mar 22, 2014 at 07:28:34PM +0100, Sander Eikelenboom
Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
[...]
Quoted 1 line
Quoted 1 line
Yes there is only one frag .. but it seems to be much larger than
PAGE_SIZE.. andxenvif_gop_frag_copybrakes that frag down intosmaller
Quoted 1 line
Quoted 1 line
bits .. hence the calculation in
xenvif_rx_actiondetermining the slotsneeded
Quoted 2 lines
Quoted 2 lines
by doing:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
for (i = 0; i < nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size,
PAGE_SIZE);Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
}But the code in
xenvif_gop_frag_copy.. seems to be needingone
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
more slot (from the emperical test) .. and calling "
get_next_rx_buffer" seems involved in that ..Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Hmm looked again .. and it seems this is it .. when your frags are
large
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
enough you have the chance of running into this.
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
get_next_rx_bufferis guarded bystart_new_rx_buffer. Do yousee
Quoted 3 lines
Quoted 3 lines
any
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
problem with that implementation?
In general no, but "
get_next_rx_buffer" up's cons .. and thecalculations
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
done in "
xenvif_rx_action" formax_slots_neededto prevent theoverrun
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
don't count in this possibility. So it's not the guarding of
"
start_new_rx_buffer" that is at fault. It's the ones early in "xenvif_rx_action".Quoted 1 line
The ones that were changed by Paul's patch from
MAX_SKB_FRAGSto a
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
calculated value that should be a "slim fit".
Quoted 1 line
The problem is in determining upfront in "
xenvif_rx_action" whenand
Quoted 3 lines
Quoted 3 lines
how
Quoted 2 lines
Quoted 2 lines
often the "
get_next_rx_buffer" path will be taken.Quoted 1 line
Unless there are other non direct restrictions (from a size point of
view)
Quoted 8 lines
Quoted 8 lines
it
Quoted 3 lines
Quoted 3 lines
can be called multiple times per frag per skb.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Problem is .. i don't see an easy fix, the "one more slot" of the
empirical
Quoted 3 lines
Quoted 3 lines
test doesn't seem to be the worst case either (i think):
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- In my case the packets that hit this only have 1 frag, but i could
have
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
had more frags.
Quoted 1 line
Quoted 1 line
Quoted 1 line
I also think you can't rule out the possibility of doing the
"
get_next_rx_buffer" for multiple subsequent frags from one packet,Quoted 1 line
Quoted 1 line
Quoted 1 line
so in the worst (and perhaps even from a single frag since it's
looped
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
over a split of it in what seems
PAGE_SIZEpieces.)Quoted 1 line
Quoted 1 line
Quoted 1 line
- So an exact calculation of how much slots we are going to need
for
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
hitting this "
get_next_rx_buffer" upfront in "xenvif_rx_action" seems unfeasible.Quoted 1 line
Quoted 1 line
Quoted 1 line
- A worst case gamble seems impossible either .. if you take
multiple
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
frags * multiple times the "
get_next_rx_buffer" ... you would probablybe
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
back at just
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
setting the
needed_slotstoMAX_SKB_FRAGS.- Other thing would be checking for the available slots before
doing
Quoted 2 lines
Quoted 2 lines
the
Quoted 1 line
Quoted 1 line
"
get_next_rx_buffer" .. how ever .. we don't account for how manyslots
Quoted 10 lines
Quoted 10 lines
we
Quoted 9 lines
Quoted 9 lines
still need to
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
just process the remaining frags.
We've done a worst case estimation for whole SKB (linear area + all frags) already, at the very first beginning. That's what
max_slots_neededis for.Quoted 1 line
- Just remove the whole "
get_next_rx_buffer".. just tested it butit
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
seems the "
get_next_rx_buffer" is necessary .. when i makestart_new_rx_bufferalways return falseQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
i hit the bug below :S
So the questions are ... is the "
get_next_rx_buffer" part reallynecessary
Quoted 2 lines
Quoted 2 lines
?
Quoted 1 line
Quoted 1 line
Quoted 1 line
- if not, what is the benefit of the "
get_next_rx_buffer" anddoes
Quoted 7 lines
Quoted 7 lines
that
Quoted 6 lines
Quoted 6 lines
outweigh the additional cost of accounting
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
of
needed_slotsfor the frags that have yet to be processed ?
- if yes, erhmmm what would be the best acceptable solution ..returning to using
MAX_SKB_FRAGS?Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
I think you need to answer several questions first:
1. ismax_slots_neededactually large enough to cover whole SKB?No it's not if, you end up calling "
get_next_rx_buffer" one ormultiple
Quoted 2 lines
Quoted 2 lines
times when processing the SKB
Quoted 1 line
you have the chance of overrunning (or be saved because prod
gets
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
Quoted 6 lines
upped before you overrun).
Quoted 4 lines
Quoted 1 line
2. is the test of ring slot availability acurate?
Seems to be.
Quoted 1 line
3. is the number of ring slots consumed larger than
max_slots_needed? (IQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
guess the answer is yes)
Yes that was the whole point.
Quoted 1 line
4. which step in the break-down procedure causes backend to
overrun
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the
Quoted 2 lines
Quoted 1 line
ring?
The "
get_next_rx_buffer" call .. that is not accounted for (whichcan
Quoted 4 lines
Quoted 4 lines
be
Quoted 3 lines
Quoted 3 lines
called
Quoted 1 line
multiple times per frag (unless some other none obvious size
restriction limits this
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
to one time per frag or one time per SKB).
In my errorneous case it is called one time, but it would be nice ifthere
Quoted 5 lines
Quoted 5 lines
would be some theoretical proof
Quoted 4 lines
instead of just some emperical test.
Quoted 1 line
It doesn't matter how many frags your SKB has and how big a frag
is. If
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
every step is correct then you're fine. The code you're looking at (
start_new_rx_buffer/get_next_rx_bufferand friend) needs tobe
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
carefully examined.
Well it seems it only calls "
get_next_rx_buffer" in some special cases..
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(and that also what i'm seeing because it doesn't happen
Quoted 3 lines
continously.
Question is shouldn't this
max_needed_slotscalc be reverted towhat it
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
was before 3.14 and take the time in 3.15 to figure out a
Quoted 1 line
the theoretical max (if it can be calculated upfront) .. or another way
to
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
guarantee the code is able to process the whole SKB ?
Quoted 1 line
Quoted 1 line
Wei.
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantQuoted 78 lines · you
Quoted 78 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 15:23
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 11:11
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 7 lines
Quoted 7 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Paul,
You have been awfully silent for this whole thread while this is a
regression
Quoted 2 lines
Quoted 2 lines
caused by a patch of you (
ca2f09f2b2c6c25047cfc545d057c4edfcfe561cas clearly stated much earlierin
Quoted 9 lines
Quoted 2 lines
this thread).
Sorry, I've been distracted...
Quoted 4 lines
The commit messages states:
"net_rx_action()is the place where we could do with an accurate
predicition but,
since that has proven tricky to calculate, a cheap worse-case (but nottoo
Quoted 6 lines
Quoted 6 lines
bad)
estimate is all we really need since the only thing we *must* prevent isxenvif_gop_skb()
consuming more slots than are available."Your "worst-case" calculation stated in the commit message is clearly not
the
Quoted 5 lines
Quoted 3 lines
worst case,
since it doesn't take calls to "get_next_rx_buffer" into account.It should be taking into account the behaviour of
start_new_rx_buffer(),which should be true if a slot is full or a frag will overflow the current slot and doesn't require splitting.
Quoted 1 line
The code in
net_rx_action()makes the assumption that each frag willrequire as many slots as its size requires, i.e. it assumes no packing of multiple frags into a single slot, so it should be a worst case.
Quoted 1 line
Did I miss something in that logic?
Yes.
In "xenvif_gop_skb()" this loop:for (i = 0; i < nr_frags; i++) { xenvif_gop_frag_copy(vif, skb, npo, skb_frag_page(&skb_shinfo(skb)->frags[i]), skb_frag_size(&skb_shinfo(skb)->frags[i]), skb_shinfo(skb)->frags[i].page_offset, &head); }Is capable of using up (at least) 1 slot more than is anticipated for in "
net_rx_action()" by this code:for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size, PAGE_SIZE); }
Quoted 7 lines
Quoted 3 lines
And this happens when it calls "
get_next_rx_buffer()" from "xenvif_gop_frag_copy()" where it's breaking down the frag.The function that determines whether to consume another slot is
start_new_rx_buffer()and for each frag I don't see why this would return true more thanDIV_ROUND_UP(size, PAGE_SIZE)times. It may be called more times than that since the code inxenvif_gop_frag_copy()must also allow for the offset of the frag but should not return true in all cases. So, I still cannot see why a frag would ever consume more thanDIV_ROUND_UP(size, PAGE_SIZE)slots.
Well here a case were a frag is broken down in 2 pieces:
[ 1156.870372] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here 1 npo->meta_prod:39 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105867 npo->copy_gref:760 npo->copy_off:4096 MAX_BUFFER_OFFSET:4096 bytes:560 size:560 offset:0 head:1273462060 i:2 vif->rx.sring->req_event:2104275 estimated_slots_needed:4 reserved_slots_left:0 [ 1156.871971] vif vif-7-0 vif7.0: ?!? xenvif_start_xmit stopping queue ! min_slots_needed:1 min_slots_needed_2:0 min_slots_needed_3:0 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105867 vif->rx.sring->req_event:2105868 skb->len:66 skb->data_len:0 [ 1156.964316] vif vif-7-0 vif7.0: ?!? get_next_rx_buffer before req npo->meta_prod:39 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105867 vif->rx.sring->req_event:2105868, reserved_slots_left:0 [ 1157.001635] vif vif-7-0 vif7.0: ?!? get_next_rx_buffer after req npo->meta_prod:39 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 req->gref:4325379 req->id:11 vif->rx.sring->req_event:2105868 reserved_slots_left:-1 [ 1157.039095] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here 2 npo->meta_prod:40 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 npo->copy_gref:4325379 npo->copy_off:0 MAX_BUFFER_OFFSET:4096 bytes:560 size:560 offset:0 head:1273462060 i:2 vif->rx.sring->req_event:2105868 estimated_slots_needed:4 reserved_slots_left:-1 [ 1157.095216] vif vif-7-0 vif7.0: ?!? xenvif_gop_frag_copy Me here end npo->meta_prod:40 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 npo->copy_gref:4325379 npo->copy_off:560 MAX_BUFFER_OFFSET:4096 bytes:560 size:0 offset:560 head:1273462060 i:3 vif->rx.sring->req_event:2105868 gso_gaps:0 estimated_slots_needed:4 reserved_slots_left:-1 [ 1157.151338] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 4 after npo->meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1 req->gref:657 req->id:7 estimated_slots_needed:4 i(frag):0 j(data):1 reserved_slots_left:-1 [ 1157.188908] vif vif-7-0 vif7.0: ?!? xenvif_gop_skb Me here 5 npo->meta_prod:40 old_meta_prod:36 vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 meta->gso_type:1 meta->gso_size:1448 nr_frags:1 req->gref:657 req->id:7 estimated_slots_needed:4 j(data):1 reserved_slots_left:-1 used in funcstart: 0 + 1 .. used_dataloop:1 .. used_fragloop:3 [ 1157.244975] vif vif-7-0 vif7.0: ?!? xenvif_rx_action me here 2 .. vif->rx.sring->req_prod:2105867 vif->rx.req_cons:2105868 sco->meta_slots_used:4 max_upped_gso:1 skb_is_gso(skb):1 max_slots_needed:4 j:6 is_gso:1 nr_frags:1 firstpart:1 secondpart:2 reserved_slots_left:-1
- When processing an SKB we end up in "xenvif_gop_frag_copy" while prod == cons ... but we still have bytes and size left ..
- start_new_rx_buffer() has returned true ..
- so we end up in get_next_rx_buffer
- this does a RING_GET_REQUEST and ups cons ..
- and we end up with a bad grant reference.
Sometimes we are saved by the bell .. since additional slots have become free (you see cons become > prod in "get_next_rx_buffer" but shortly after that prod is increased .. just in time to not cause a overrun).
If you need additional / other info, please cook up a debug patch with what you need.
--
Sander
Quoted 183 lines
Paul
Quoted 181 lines
Ultimately this results in bad grant reference warnings (and packets marked as "errors" in the interface statistics).
In my case it always seems to be a skb with 1 frag which is broken down in 5 or 6 pieces ..
So "
get_next_rx_buffer()" is called once .. and i'm overrunning the ring with 1 slot, but i'm not sure if that's not coincedence
since in the code there seem to be no explicit limitation on how often this code path is taken. So perhaps it's implicitly limited
since packets and frags can't be arbitrarily large in comparison with thepage_sizebut that's not something i'm capable of figuring out :-)Quoted 3 lines
Paul
Quoted 1 line
Problem is that a worst case calculation would probably be reverting to
the
Quoted 6 lines
Quoted 6 lines
old calculation,
and the problems this patch was trying to solve would reappear, but introducing new regressions
isn't very useful either. And since it seems such a tricky and fragile thing to determine, it would
probably be best to be split into a distinct function with a comment toexplain
Quoted 3 lines
Quoted 3 lines
the rationale used.
Since this doesn't seem to progress very fast .. CC'ed some more folks ..
you
Quoted 9 lines
Quoted 9 lines
never know ..
--
SanderTuesday, March 25, 2014, 4:29:42 PM, you wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines · you
On Sat, Mar 22, 2014 at 07:28:34PM +0100, Sander Eikelenboom wrote:
[...]Quoted 1 line
Quoted 1 line
Yes there is only one frag .. but it seems to be much larger than
PAGE_SIZE.. andxenvif_gop_frag_copybrakes that frag down intosmaller
Quoted 1 line
Quoted 1 line
bits .. hence the calculation in
xenvif_rx_actiondetermining the slotsneeded
Quoted 6 lines
Quoted 6 lines
by doing:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
for (i = 0; i < nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size,
PAGE_SIZE);Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
}But the code in
xenvif_gop_frag_copy.. seems to be needing onemore slot (from the emperical test) .. and calling "
get_next_rx_buffer" seems involved in that ..Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Hmm looked again .. and it seems this is it .. when your frags are large
enough you have the chance of running into this.
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
get_next_rx_bufferis guarded bystart_new_rx_buffer. Do you seeany
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Quoted 1 line
problem with that implementation?
In general no, but "
get_next_rx_buffer" up's cons .. and the calculationsdone in "
xenvif_rx_action" formax_slots_neededto prevent the overrunQuoted 1 line
don't count in this possibility. So it's not the guarding of
"
start_new_rx_buffer" that is at fault. It's the ones early in "xenvif_rx_action".Quoted 1 line
The ones that were changed by Paul's patch from
MAX_SKB_FRAGSto acalculated value that should be a "slim fit".
Quoted 1 line
The problem is in determining upfront in "
xenvif_rx_action" when andhow
Quoted 2 lines
Quoted 2 lines
often the "
get_next_rx_buffer" path will be taken.Quoted 1 line
Unless there are other non direct restrictions (from a size point of view)
it
Quoted 3 lines
Quoted 3 lines
can be called multiple times per frag per skb.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Problem is .. i don't see an easy fix, the "one more slot" of the
empirical
Quoted 9 lines
Quoted 9 lines
test doesn't seem to be the worst case either (i think):
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- In my case the packets that hit this only have 1 frag, but i could have
had more frags.
Quoted 1 line
Quoted 1 line
Quoted 1 line
I also think you can't rule out the possibility of doing the
"
get_next_rx_buffer" for multiple subsequent frags from one packet,Quoted 1 line
Quoted 1 line
Quoted 1 line
so in the worst (and perhaps even from a single frag since it's looped
over a split of it in what seems
PAGE_SIZEpieces.)Quoted 1 line
Quoted 1 line
Quoted 1 line
- So an exact calculation of how much slots we are going to need for
Quoted 8 lines
Quoted 8 lines
hitting this "
get_next_rx_buffer" upfront in "xenvif_rx_action" seems unfeasible.Quoted 1 line
Quoted 1 line
Quoted 1 line
- A worst case gamble seems impossible either .. if you take multiple
frags * multiple times the "
get_next_rx_buffer" ... you would probably be back at justQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
setting the
needed_slotstoMAX_SKB_FRAGS.- Other thing would be checking for the available slots before doing
the
Quoted 1 line
Quoted 1 line
"
get_next_rx_buffer" .. how ever .. we don't account for how many slotswe
Quoted 8 lines
Quoted 8 lines
still need to
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
just process the remaining frags.
We've done a worst case estimation for whole SKB (linear area + all frags) already, at the very first beginning. That's what
max_slots_neededis for.Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
- Just remove the whole "
get_next_rx_buffer".. just tested it but itseems the "
get_next_rx_buffer" is necessary .. when i makestart_new_rx_bufferalways return falseQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
i hit the bug below :S
So the questions are ... is the "
get_next_rx_buffer" part reallynecessary
Quoted 2 lines
Quoted 2 lines
?
Quoted 1 line
Quoted 1 line
Quoted 1 line
- if not, what is the benefit of the "
get_next_rx_buffer" and doesthat
Quoted 9 lines
Quoted 9 lines
outweigh the additional cost of accounting
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
of
needed_slotsfor the frags that have yet to be processed ?
- if yes, erhmmm what would be the best acceptable solution ..returning to using
MAX_SKB_FRAGS?Quoted 5 lines
Quoted 4 lines
Quoted 1 line
I think you need to answer several questions first:
1. ismax_slots_neededactually large enough to cover whole SKB?No it's not if, you end up calling "
get_next_rx_buffer" one ormultiple
Quoted 8 lines
Quoted 8 lines
times when processing the SKB
Quoted 1 line
you have the chance of overrunning (or be saved because prod gets
upped before you overrun).
Quoted 4 lines
Quoted 1 line
2. is the test of ring slot availability acurate?
Seems to be.
Quoted 1 line
3. is the number of ring slots consumed larger than
max_slots_needed? (IQuoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
guess the answer is yes)
Yes that was the whole point.
Quoted 1 line
4. which step in the break-down procedure causes backend to overrun
the
Quoted 2 lines
Quoted 1 line
ring?
The "
get_next_rx_buffer" call .. that is not accounted for (which canbe
Quoted 5 lines
Quoted 5 lines
called
Quoted 1 line
multiple times per frag (unless some other none obvious size
restriction limits this
Quoted 2 lines
to one time per frag or one time per SKB).
In my errorneous case it is called one time, but it would be nice ifthere
Quoted 23 lines
Quoted 23 lines
would be some theoretical proof
Quoted 9 lines
instead of just some emperical test.
Quoted 4 lines
It doesn't matter how many frags your SKB has and how big a frag is. If every step is correct then you're fine. The code you're looking at (
start_new_rx_buffer/get_next_rx_bufferand friend) needs to be carefully examined.Well it seems it only calls "
get_next_rx_buffer" in some special cases ..(and that also what i'm seeing because it doesn't happen
Quoted 3 lines
continously.
Question is shouldn't this
max_needed_slotscalc be reverted to what itwas before 3.14 and take the time in 3.15 to figure out a
Quoted 1 line
the theoretical max (if it can be calculated upfront) .. or another way to
guarantee the code is able to process the whole SKB ?
Quoted 1 line
Quoted 1 line
Wei.
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Sander EikelenboomQuoted 72 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 15:23
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 5 lines · you
Quoted 5 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 11:11
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell;linux-
Quoted 7 lines
Quoted 7 lines
kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Paul,
You have been awfully silent for this whole thread while this is a
regression
Quoted 2 lines
Quoted 2 lines
caused by a patch of you (
ca2f09f2b2c6c25047cfc545d057c4edfcfe561cas clearly stated much earlierin
Quoted 9 lines
Quoted 2 lines
this thread).
Sorry, I've been distracted...
Quoted 4 lines
The commit messages states:
"net_rx_action()is the place where we could do with an accurate
predicition but,
since that has proven tricky to calculate, a cheap worse-case (but nottoo
Quoted 6 lines
Quoted 6 lines
bad)
estimate is all we really need since the only thing we *must* prevent isxenvif_gop_skb()
consuming more slots than are available."Your "worst-case" calculation stated in the commit message is clearly not
the
Quoted 5 lines
Quoted 3 lines
worst case,
since it doesn't take calls to "get_next_rx_buffer" into account.It should be taking into account the behaviour of
start_new_rx_buffer(),which should be true if a slot is full or a frag will overflow the current slot and doesn't require splitting.
Quoted 1 line
The code in
net_rx_action()makes the assumption that each frag willrequire as many slots as its size requires, i.e. it assumes no packing of multiple frags into a single slot, so it should be a worst case.
Quoted 1 line
Did I miss something in that logic?
Yes.
In "xenvif_gop_skb()" this loop:for (i = 0; i < nr_frags; i++) { xenvif_gop_frag_copy(vif, skb, npo, skb_frag_page(&skb_shinfo(skb)->frags[i]), skb_frag_size(&skb_shinfo(skb)->frags[i]), skb_shinfo(skb)->frags[i].page_offset, &head); }Is capable of using up (at least) 1 slot more than is anticipated for in "
net_rx_action()" by this code:
Quoted 9 lines
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size, PAGE_SIZE); }And this happens when it calls "
get_next_rx_buffer()" from "xenvif_gop_frag_copy()" where it's breaking down the frag.
The function that determines whether to consume another slot is start_new_rx_buffer() and for each frag I don't see why this would return true more than DIV_ROUND_UP(size, PAGE_SIZE) times. It may be called more times than that since the code in xenvif_gop_frag_copy() must also allow for the offset of the frag but should not return true in all cases. So, I still cannot see why a frag would ever consume more than DIV_ROUND_UP(size, PAGE_SIZE) slots.
Paul
Quoted 181 lines
Ultimately this results in bad grant reference warnings (and packets marked as "errors" in the interface statistics).
In my case it always seems to be a skb with 1 frag which is broken down in 5 or 6 pieces ..
So "
get_next_rx_buffer()" is called once .. and i'm overrunning the ring with 1 slot, but i'm not sure if that's not coincedence
since in the code there seem to be no explicit limitation on how often this code path is taken. So perhaps it's implicitly limited
since packets and frags can't be arbitrarily large in comparison with thepage_sizebut that's not something i'm capable of figuring out :-)Quoted 3 lines
Paul
Quoted 1 line
Problem is that a worst case calculation would probably be reverting to
the
Quoted 6 lines
Quoted 6 lines
old calculation,
and the problems this patch was trying to solve would reappear, but introducing new regressions
isn't very useful either. And since it seems such a tricky and fragile thing to determine, it would
probably be best to be split into a distinct function with a comment toexplain
Quoted 3 lines
Quoted 3 lines
the rationale used.
Since this doesn't seem to progress very fast .. CC'ed some more folks ..
you
Quoted 9 lines
Quoted 9 lines
never know ..
--
SanderTuesday, March 25, 2014, 4:29:42 PM, you wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines · you
On Sat, Mar 22, 2014 at 07:28:34PM +0100, Sander Eikelenboom wrote:
[...]Quoted 1 line
Quoted 1 line
Yes there is only one frag .. but it seems to be much larger than
PAGE_SIZE.. andxenvif_gop_frag_copybrakes that frag down intosmaller
Quoted 1 line
Quoted 1 line
bits .. hence the calculation in
xenvif_rx_actiondetermining the slotsneeded
Quoted 6 lines
Quoted 6 lines
by doing:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
for (i = 0; i < nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size,
PAGE_SIZE);Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
}But the code in
xenvif_gop_frag_copy.. seems to be needing onemore slot (from the emperical test) .. and calling "
get_next_rx_buffer" seems involved in that ..Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Hmm looked again .. and it seems this is it .. when your frags are large
enough you have the chance of running into this.
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
get_next_rx_bufferis guarded bystart_new_rx_buffer. Do you seeany
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Quoted 1 line
problem with that implementation?
In general no, but "
get_next_rx_buffer" up's cons .. and the calculationsdone in "
xenvif_rx_action" formax_slots_neededto prevent the overrunQuoted 1 line
don't count in this possibility. So it's not the guarding of
"
start_new_rx_buffer" that is at fault. It's the ones early in "xenvif_rx_action".Quoted 1 line
The ones that were changed by Paul's patch from
MAX_SKB_FRAGSto acalculated value that should be a "slim fit".
Quoted 1 line
The problem is in determining upfront in "
xenvif_rx_action" when andhow
Quoted 2 lines
Quoted 2 lines
often the "
get_next_rx_buffer" path will be taken.Quoted 1 line
Unless there are other non direct restrictions (from a size point of view)
it
Quoted 3 lines
Quoted 3 lines
can be called multiple times per frag per skb.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Problem is .. i don't see an easy fix, the "one more slot" of the
empirical
Quoted 9 lines
Quoted 9 lines
test doesn't seem to be the worst case either (i think):
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- In my case the packets that hit this only have 1 frag, but i could have
had more frags.
Quoted 1 line
Quoted 1 line
Quoted 1 line
I also think you can't rule out the possibility of doing the
"
get_next_rx_buffer" for multiple subsequent frags from one packet,Quoted 1 line
Quoted 1 line
Quoted 1 line
so in the worst (and perhaps even from a single frag since it's looped
over a split of it in what seems
PAGE_SIZEpieces.)Quoted 1 line
Quoted 1 line
Quoted 1 line
- So an exact calculation of how much slots we are going to need for
Quoted 8 lines
Quoted 8 lines
hitting this "
get_next_rx_buffer" upfront in "xenvif_rx_action" seems unfeasible.Quoted 1 line
Quoted 1 line
Quoted 1 line
- A worst case gamble seems impossible either .. if you take multiple
frags * multiple times the "
get_next_rx_buffer" ... you would probably be back at justQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
setting the
needed_slotstoMAX_SKB_FRAGS.- Other thing would be checking for the available slots before doing
the
Quoted 1 line
Quoted 1 line
"
get_next_rx_buffer" .. how ever .. we don't account for how many slotswe
Quoted 8 lines
Quoted 8 lines
still need to
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
just process the remaining frags.
We've done a worst case estimation for whole SKB (linear area + all frags) already, at the very first beginning. That's what
max_slots_neededis for.Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
- Just remove the whole "
get_next_rx_buffer".. just tested it but itseems the "
get_next_rx_buffer" is necessary .. when i makestart_new_rx_bufferalways return falseQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
i hit the bug below :S
So the questions are ... is the "
get_next_rx_buffer" part reallynecessary
Quoted 2 lines
Quoted 2 lines
?
Quoted 1 line
Quoted 1 line
Quoted 1 line
- if not, what is the benefit of the "
get_next_rx_buffer" and doesthat
Quoted 9 lines
Quoted 9 lines
outweigh the additional cost of accounting
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
of
needed_slotsfor the frags that have yet to be processed ?
- if yes, erhmmm what would be the best acceptable solution ..returning to using
MAX_SKB_FRAGS?Quoted 5 lines
Quoted 4 lines
Quoted 1 line
I think you need to answer several questions first:
1. ismax_slots_neededactually large enough to cover whole SKB?No it's not if, you end up calling "
get_next_rx_buffer" one ormultiple
Quoted 8 lines
Quoted 8 lines
times when processing the SKB
Quoted 1 line
you have the chance of overrunning (or be saved because prod gets
upped before you overrun).
Quoted 4 lines
Quoted 1 line
2. is the test of ring slot availability acurate?
Seems to be.
Quoted 1 line
3. is the number of ring slots consumed larger than
max_slots_needed? (IQuoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
guess the answer is yes)
Yes that was the whole point.
Quoted 1 line
4. which step in the break-down procedure causes backend to overrun
the
Quoted 2 lines
Quoted 1 line
ring?
The "
get_next_rx_buffer" call .. that is not accounted for (which canbe
Quoted 5 lines
Quoted 5 lines
called
Quoted 1 line
multiple times per frag (unless some other none obvious size
restriction limits this
Quoted 2 lines
to one time per frag or one time per SKB).
In my errorneous case it is called one time, but it would be nice ifthere
Quoted 23 lines
Quoted 23 lines
would be some theoretical proof
Quoted 9 lines
instead of just some emperical test.
Quoted 4 lines
It doesn't matter how many frags your SKB has and how big a frag is. If every step is correct then you're fine. The code you're looking at (
start_new_rx_buffer/get_next_rx_bufferand friend) needs to be carefully examined.Well it seems it only calls "
get_next_rx_buffer" in some special cases ..(and that also what i'm seeing because it doesn't happen
Quoted 3 lines
continously.
Question is shouldn't this
max_needed_slotscalc be reverted to what itwas before 3.14 and take the time in 3.15 to figure out a
Quoted 1 line
the theoretical max (if it can be calculated upfront) .. or another way to
guarantee the code is able to process the whole SKB ?
Quoted 1 line
Quoted 1 line
Wei.
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Paul DurrantQuoted 28 lines · you
Quoted 9 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 11:11
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 7 lines
Paul,
You have been awfully silent for this whole thread while this is a regression caused by a patch of you (
ca2f09f2b2c6c25047cfc545d057c4edfcfe561cas clearly stated much earlier in this thread).Sorry, I've been distracted...
Quoted 9 lines
The commit messages states:
"net_rx_action()is the place where we could do with an accurate
predicition but,
since that has proven tricky to calculate, a cheap worse-case (but not too
bad)
estimate is all we really need since the only thing we *must* prevent isxenvif_gop_skb()
consuming more slots than are available."
Quoted 8 lines
Quoted 4 lines
Your "worst-case" calculation stated in the commit message is clearly not the worst case,
since it doesn't take calls to "get_next_rx_buffer" into account.It should be taking into account the behaviour of
start_new_rx_buffer(), which should be true if a slot is full or a frag will overflow the current slot and doesn't require splitting. The code innet_rx_action()makes the assumption that each frag will require as many slots as its size requires, i.e. it assumes no packing of multiple frags into a single slot, so it should be a worst case. Did I miss something in that logic?
Yes.
In "xenvif_gop_skb()" this loop:
for (i = 0; i < nr_frags; i++) {
xenvif_gop_frag_copy(vif, skb, npo,
skb_frag_page(&skb_shinfo(skb)->frags[i]),
skb_frag_size(&skb_shinfo(skb)->frags[i]),
skb_shinfo(skb)->frags[i].page_offset,
&head);
}Is capable of using up (at least) 1 slot more than is anticipated for in "net_rx_action()" by this code:
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
unsigned int size;
size = skb_frag_size(&skb_shinfo(skb)->frags[i]);
max_slots_needed += DIV_ROUND_UP(size, PAGE_SIZE);
}And this happens when it calls "get_next_rx_buffer()" from "xenvif_gop_frag_copy()" where it's breaking down the frag.
Ultimately this results in bad grant reference warnings (and packets marked as "errors" in the interface statistics).
In my case it always seems to be a skb with 1 frag which is broken down in 5 or 6 pieces ..
So "get_next_rx_buffer()" is called once .. and i'm overrunning the ring with 1 slot, but i'm not sure if that's not coincedence since in the code there seem to be no explicit limitation on how often this code path is taken. So perhaps it's implicitly limited since packets and frags can't be arbitrarily large in comparison with the page_size but that's not something i'm capable of figuring out :-)
Quoted 146 lines
Paul
Quoted 144 lines
Problem is that a worst case calculation would probably be reverting to the old calculation,
and the problems this patch was trying to solve would reappear, but introducing new regressions
isn't very useful either. And since it seems such a tricky and fragile thing to determine, it would
probably be best to be split into a distinct function with a comment to explain the rationale used.Since this doesn't seem to progress very fast .. CC'ed some more folks .. you never know ..
--
SanderQuoted 5 lines · you
Quoted 3 lines · you
On Sat, Mar 22, 2014 at 07:28:34PM +0100, Sander Eikelenboom wrote:
[...]Quoted 1 line
Quoted 1 line
Yes there is only one frag .. but it seems to be much larger than
PAGE_SIZE.. andxenvif_gop_frag_copybrakes that frag down into smaller bits .. hence the calculation inxenvif_rx_actiondetermining the slots needed by doing:Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
for (i = 0; i < nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size, PAGE_SIZE); }But the code in
xenvif_gop_frag_copy.. seems to be needing onemore slot (from the emperical test) .. and calling "
get_next_rx_buffer" seems involved in that ..Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Hmm looked again .. and it seems this is it .. when your frags are large
enough you have the chance of running into this.
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
get_next_rx_bufferis guarded bystart_new_rx_buffer. Do you see any problem with that implementation?In general no, but "
get_next_rx_buffer" up's cons .. and the calculationsdone in "
xenvif_rx_action" formax_slots_neededto prevent the overrunQuoted 1 line
don't count in this possibility. So it's not the guarding of
"
start_new_rx_buffer" that is at fault. It's the ones early in "xenvif_rx_action".Quoted 1 line
The ones that were changed by Paul's patch from
MAX_SKB_FRAGSto acalculated value that should be a "slim fit".
Quoted 1 line
The problem is in determining upfront in "
xenvif_rx_action" when and howoften the "
get_next_rx_buffer" path will be taken.Quoted 1 line
Unless there are other non direct restrictions (from a size point of view) it
can be called multiple times per frag per skb.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Problem is .. i don't see an easy fix, the "one more slot" of the empirical
test doesn't seem to be the worst case either (i think):
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- In my case the packets that hit this only have 1 frag, but i could have
had more frags.
Quoted 1 line
Quoted 1 line
Quoted 1 line
I also think you can't rule out the possibility of doing the
"
get_next_rx_buffer" for multiple subsequent frags from one packet,Quoted 1 line
Quoted 1 line
Quoted 1 line
so in the worst (and perhaps even from a single frag since it's looped
over a split of it in what seems
PAGE_SIZEpieces.)Quoted 1 line
Quoted 1 line
Quoted 1 line
- So an exact calculation of how much slots we are going to need for
hitting this "
get_next_rx_buffer" upfront in "xenvif_rx_action" seems unfeasible.Quoted 1 line
Quoted 1 line
Quoted 1 line
- A worst case gamble seems impossible either .. if you take multiple
frags * multiple times the "
get_next_rx_buffer" ... you would probably be back at justQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
setting the
needed_slotstoMAX_SKB_FRAGS.- Other thing would be checking for the available slots before doing the
"
get_next_rx_buffer" .. how ever .. we don't account for how many slots we still need toQuoted 8 lines
Quoted 8 lines
Quoted 2 lines
just process the remaining frags.
We've done a worst case estimation for whole SKB (linear area + all frags) already, at the very first beginning. That's what
max_slots_neededis for.Quoted 1 line
- Just remove the whole "
get_next_rx_buffer".. just tested it but itseems the "
get_next_rx_buffer" is necessary .. when i makestart_new_rx_bufferalways return falseQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
i hit the bug below :S
So the questions are ... is the "
get_next_rx_buffer" part really necessary?
Quoted 1 line
Quoted 1 line
Quoted 1 line
- if not, what is the benefit of the "
get_next_rx_buffer" and does thatoutweigh the additional cost of accounting
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
of
needed_slotsfor the frags that have yet to be processed ?
- if yes, erhmmm what would be the best acceptable solution ..returning to using
MAX_SKB_FRAGS?Quoted 5 lines
Quoted 4 lines
Quoted 1 line
I think you need to answer several questions first:
1. ismax_slots_neededactually large enough to cover whole SKB?No it's not if, you end up calling "
get_next_rx_buffer" one or multipletimes when processing the SKB
Quoted 1 line
you have the chance of overrunning (or be saved because prod gets
upped before you overrun).
Quoted 8 lines
Quoted 1 line
2. is the test of ring slot availability acurate?
Seems to be.
Quoted 2 lines
3. is the number of ring slots consumed larger than
max_slots_needed? (I guess the answer is yes)Yes that was the whole point.
Quoted 1 line
4. which step in the break-down procedure causes backend to overrun
the
Quoted 2 lines
Quoted 1 line
ring?
The "
get_next_rx_buffer" call .. that is not accounted for (which can becalled
Quoted 1 line
multiple times per frag (unless some other none obvious size
restriction limits this
Quoted 2 lines
to one time per frag or one time per SKB).
In my errorneous case it is called one time, but it would be nice if therewould be some theoretical proof
Quoted 9 lines
instead of just some emperical test.
Quoted 4 lines
It doesn't matter how many frags your SKB has and how big a frag is. If every step is correct then you're fine. The code you're looking at (
start_new_rx_buffer/get_next_rx_bufferand friend) needs to be carefully examined.Well it seems it only calls "
get_next_rx_buffer" in some special cases ..(and that also what i'm seeing because it doesn't happen
Quoted 3 lines
continously.
Question is shouldn't this
max_needed_slotscalc be reverted to what itwas before 3.14 and take the time in 3.15 to figure out a
Quoted 1 line
the theoretical max (if it can be calculated upfront) .. or another way to
guarantee the code is able to process the whole SKB ?
Quoted 1 line
Quoted 1 line
Wei.
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Sander EikelenboomQuoted 9 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 26 March 2014 11:11
To: Paul Durrant
Cc: Wei Liu; annie li; Zoltan Kiss; [email protected]; Ian Campbell; linux- kernel; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
Quoted 7 lines
Paul,
You have been awfully silent for this whole thread while this is a regression caused by a patch of you (
ca2f09f2b2c6c25047cfc545d057c4edfcfe561cas clearly stated much earlier in this thread).
Sorry, I've been distracted...
Quoted 9 lines
The commit messages states:
"net_rx_action()is the place where we could do with an accurate
predicition but,
since that has proven tricky to calculate, a cheap worse-case (but not too
bad)
estimate is all we really need since the only thing we *must* prevent isxenvif_gop_skb()
consuming more slots than are available."
Quoted 4 lines
Your "worst-case" calculation stated in the commit message is clearly not the worst case,
since it doesn't take calls to "get_next_rx_buffer" into account.
It should be taking into account the behaviour of start_new_rx_buffer(), which should be true if a slot is full or a frag will overflow the current slot and doesn't require splitting. The code in net_rx_action() makes the assumption that each frag will require as many slots as its size requires, i.e. it assumes no packing of multiple frags into a single slot, so it should be a worst case. Did I miss something in that logic?
Paul
Quoted 144 lines
Problem is that a worst case calculation would probably be reverting to the old calculation,
and the problems this patch was trying to solve would reappear, but introducing new regressions
isn't very useful either. And since it seems such a tricky and fragile thing to determine, it would
probably be best to be split into a distinct function with a comment to explain the rationale used.Since this doesn't seem to progress very fast .. CC'ed some more folks .. you never know ..
--
SanderQuoted 5 lines · you
Quoted 3 lines · you
On Sat, Mar 22, 2014 at 07:28:34PM +0100, Sander Eikelenboom wrote:
[...]Quoted 1 line
Quoted 1 line
Yes there is only one frag .. but it seems to be much larger than
PAGE_SIZE.. andxenvif_gop_frag_copybrakes that frag down into smaller bits .. hence the calculation inxenvif_rx_actiondetermining the slots needed by doing:Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
for (i = 0; i < nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size, PAGE_SIZE); }But the code in
xenvif_gop_frag_copy.. seems to be needing onemore slot (from the emperical test) .. and calling "
get_next_rx_buffer" seems involved in that ..Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Hmm looked again .. and it seems this is it .. when your frags are large
enough you have the chance of running into this.
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
get_next_rx_bufferis guarded bystart_new_rx_buffer. Do you see any problem with that implementation?In general no, but "
get_next_rx_buffer" up's cons .. and the calculationsdone in "
xenvif_rx_action" formax_slots_neededto prevent the overrunQuoted 1 line
don't count in this possibility. So it's not the guarding of
"
start_new_rx_buffer" that is at fault. It's the ones early in "xenvif_rx_action".Quoted 1 line
The ones that were changed by Paul's patch from
MAX_SKB_FRAGSto acalculated value that should be a "slim fit".
Quoted 1 line
The problem is in determining upfront in "
xenvif_rx_action" when and howoften the "
get_next_rx_buffer" path will be taken.Quoted 1 line
Unless there are other non direct restrictions (from a size point of view) it
can be called multiple times per frag per skb.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Problem is .. i don't see an easy fix, the "one more slot" of the empirical
test doesn't seem to be the worst case either (i think):
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
- In my case the packets that hit this only have 1 frag, but i could have
had more frags.
Quoted 1 line
Quoted 1 line
Quoted 1 line
I also think you can't rule out the possibility of doing the
"
get_next_rx_buffer" for multiple subsequent frags from one packet,Quoted 1 line
Quoted 1 line
Quoted 1 line
so in the worst (and perhaps even from a single frag since it's looped
over a split of it in what seems
PAGE_SIZEpieces.)Quoted 1 line
Quoted 1 line
Quoted 1 line
- So an exact calculation of how much slots we are going to need for
hitting this "
get_next_rx_buffer" upfront in "xenvif_rx_action" seems unfeasible.Quoted 1 line
Quoted 1 line
Quoted 1 line
- A worst case gamble seems impossible either .. if you take multiple
frags * multiple times the "
get_next_rx_buffer" ... you would probably be back at justQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
setting the
needed_slotstoMAX_SKB_FRAGS.- Other thing would be checking for the available slots before doing the
"
get_next_rx_buffer" .. how ever .. we don't account for how many slots we still need toQuoted 8 lines
Quoted 8 lines
Quoted 2 lines
just process the remaining frags.
We've done a worst case estimation for whole SKB (linear area + all frags) already, at the very first beginning. That's what
max_slots_neededis for.Quoted 1 line
- Just remove the whole "
get_next_rx_buffer".. just tested it but itseems the "
get_next_rx_buffer" is necessary .. when i makestart_new_rx_bufferalways return falseQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
i hit the bug below :S
So the questions are ... is the "
get_next_rx_buffer" part really necessary?
Quoted 1 line
Quoted 1 line
Quoted 1 line
- if not, what is the benefit of the "
get_next_rx_buffer" and does thatoutweigh the additional cost of accounting
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
of
needed_slotsfor the frags that have yet to be processed ?
- if yes, erhmmm what would be the best acceptable solution ..returning to using
MAX_SKB_FRAGS?Quoted 5 lines
Quoted 4 lines
Quoted 1 line
I think you need to answer several questions first:
1. ismax_slots_neededactually large enough to cover whole SKB?No it's not if, you end up calling "
get_next_rx_buffer" one or multipletimes when processing the SKB
Quoted 1 line
you have the chance of overrunning (or be saved because prod gets
upped before you overrun).
Quoted 8 lines
Quoted 1 line
2. is the test of ring slot availability acurate?
Seems to be.
Quoted 2 lines
3. is the number of ring slots consumed larger than
max_slots_needed? (I guess the answer is yes)Yes that was the whole point.
Quoted 1 line
4. which step in the break-down procedure causes backend to overrun
the
Quoted 2 lines
Quoted 1 line
ring?
The "
get_next_rx_buffer" call .. that is not accounted for (which can becalled
Quoted 1 line
multiple times per frag (unless some other none obvious size
restriction limits this
Quoted 2 lines
to one time per frag or one time per SKB).
In my errorneous case it is called one time, but it would be nice if therewould be some theoretical proof
Quoted 9 lines
instead of just some emperical test.
Quoted 4 lines
It doesn't matter how many frags your SKB has and how big a frag is. If every step is correct then you're fine. The code you're looking at (
start_new_rx_buffer/get_next_rx_bufferand friend) needs to be carefully examined.Well it seems it only calls "
get_next_rx_buffer" in some special cases ..(and that also what i'm seeing because it doesn't happen
Quoted 3 lines
continously.
Question is shouldn't this
max_needed_slotscalc be reverted to what itwas before 3.14 and take the time in 3.15 to figure out a
Quoted 1 line
the theoretical max (if it can be calculated upfront) .. or another way to
guarantee the code is able to process the whole SKB ?
Quoted 1 line
Quoted 1 line
Wei.
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Sander EikelenboomPaul,
You have been awfully silent for this whole thread while this is a regression caused by a patch of you (ca2f09f2b2c6c25047cfc545d057c4edfcfe561c as clearly stated much earlier in this thread).
The commit messages states:
"net_rx_action() is the place where we could do with an accurate predicition but, since that has proven tricky to calculate, a cheap worse-case (but not too bad) estimate is all we really need since the only thing we *must* prevent is xenvif_gop_skb() consuming more slots than are available."
Your "worst-case" calculation stated in the commit message is clearly not the worst case, since it doesn't take calls to "get_next_rx_buffer" into account.
Problem is that a worst case calculation would probably be reverting to the old calculation, and the problems this patch was trying to solve would reappear, but introducing new regressions isn't very useful either. And since it seems such a tricky and fragile thing to determine, it would probably be best to be split into a distinct function with a comment to explain the rationale used.
Since this doesn't seem to progress very fast .. CC'ed some more folks .. you never know ..
--
Sander
Quoted 85 lines · you
Quoted 10 lines · you
On Sat, Mar 22, 2014 at 07:28:34PM +0100, Sander Eikelenboom wrote:
[...]Quoted 8 lines
Quoted 7 lines
Yes there is only one frag .. but it seems to be much larger than
PAGE_SIZE.. andxenvif_gop_frag_copybrakes that frag down into smaller bits .. hence the calculation inxenvif_rx_actiondetermining the slots needed by doing:for (i = 0; i < nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size, PAGE_SIZE); }Quoted 7 lines
Quoted 4 lines
Quoted 1 line
But the code in
xenvif_gop_frag_copy.. seems to be needing one more slot (from the emperical test) .. and calling "get_next_rx_buffer" seems involved in that ..Hmm looked again .. and it seems this is it .. when your frags are large enough you have the chance of running into this.
get_next_rx_bufferis guarded bystart_new_rx_buffer. Do you see any problem with that implementation?In general no, but "
get_next_rx_buffer" up's cons .. and the calculations done in "xenvif_rx_action" formax_slots_neededto prevent the overrun don't count in this possibility. So it's not the guarding of "start_new_rx_buffer" that is at fault. It's the ones early in "xenvif_rx_action". The ones that were changed by Paul's patch fromMAX_SKB_FRAGSto a calculated value that should be a "slim fit".The problem is in determining upfront in "
xenvif_rx_action" when and how often the "get_next_rx_buffer" path will be taken. Unless there are other non direct restrictions (from a size point of view) it can be called multiple times per frag per skb.Quoted 20 lines
Quoted 9 lines
Problem is .. i don't see an easy fix, the "one more slot" of the empirical test doesn't seem to be the worst case either (i think):
- In my case the packets that hit this only have 1 frag, but i could have had more frags.
I also think you can't rule out the possibility of doing the "get_next_rx_buffer" for multiple subsequent frags from one packet, so in the worst (and perhaps even from a single frag since it's looped over a split of it in what seemsPAGE_SIZEpieces.)
- So an exact calculation of how much slots we are going to need for hitting this "get_next_rx_buffer" upfront in "xenvif_rx_action" seems unfeasible.
- A worst case gamble seems impossible either .. if you take multiple frags * multiple times the "get_next_rx_buffer" ... you would probably be back at just setting theneeded_slotstoMAX_SKB_FRAGS.Quoted 3 lines
- Other thing would be checking for the available slots before doing the "
get_next_rx_buffer" .. how ever .. we don't account for how many slots we still need to just process the remaining frags.We've done a worst case estimation for whole SKB (linear area + all frags) already, at the very first beginning. That's what
max_slots_neededis for.Quoted 3 lines
- Just remove the whole "
get_next_rx_buffer".. just tested it but it seems the "get_next_rx_buffer" is necessary .. when i makestart_new_rx_bufferalways return false i hit the bug below :SQuoted 8 lines
Quoted 5 lines
So the questions are ... is the "
get_next_rx_buffer" part really necessary ?
- if not, what is the benefit of the "get_next_rx_buffer" and does that outweigh the additional cost of accounting ofneeded_slotsfor the frags that have yet to be processed ?
- if yes, erhmmm what would be the best acceptable solution .. returning to usingMAX_SKB_FRAGS?I think you need to answer several questions first:
1. ismax_slots_neededactually large enough to cover whole SKB?No it's not if, you end up calling "
get_next_rx_buffer" one or multiple times when processing the SKB you have the chance of overrunning (or be saved because prod gets upped before you overrun).Quoted 1 line
2. is the test of ring slot availability acurate?
Seems to be.
Quoted 2 lines
3. is the number of ring slots consumed larger than
max_slots_needed? (I guess the answer is yes)Yes that was the whole point.
Quoted 2 lines
4. which step in the break-down procedure causes backend to overrun the ring?
The "
get_next_rx_buffer" call .. that is not accounted for (which can be called multiple times per frag (unless some other none obvious size restriction limits this
to one time per frag or one time per SKB).
In my errorneous case it is called one time, but it would be nice if there would be some theoretical proof instead of just some emperical test.Quoted 4 lines
It doesn't matter how many frags your SKB has and how big a frag is. If every step is correct then you're fine. The code you're looking at (
start_new_rx_buffer/get_next_rx_bufferand friend) needs to be carefully examined.Well it seems it only calls "
get_next_rx_buffer" in some special cases .. (and that also what i'm seeing because it doesn't happen continously.Question is shouldn't this
max_needed_slotscalc be reverted to what it was before 3.14 and take the time in 3.15 to figure out a the theoretical max (if it can be calculated upfront) .. or another way to guarantee the code is able to process the whole SKB ?Quoted 1 line
Wei.
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Sander EikelenboomQuoted 119 lines
-----Original Message-----
From: Sander Eikelenboom [mailto:[email protected]]
Sent: 25 March 2014 15:30
To: Wei Liu
Cc: annie li; Paul Durrant; Zoltan Kiss; [email protected]
Subject: Re: [Xen-devel] Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"Quoted 3 lines · you
On Sat, Mar 22, 2014 at 07:28:34PM +0100, Sander Eikelenboom wrote:
[...]Quoted 1 line
Quoted 1 line
Yes there is only one frag .. but it seems to be much larger than
PAGE_SIZE.. andxenvif_gop_frag_copybrakes that frag down into smaller bits .. hence the calculation inxenvif_rx_actiondetermining the slots needed by doing:Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
for (i = 0; i < nr_frags; i++) { unsigned int size; size = skb_frag_size(&skb_shinfo(skb)->frags[i]); max_slots_needed += DIV_ROUND_UP(size, PAGE_SIZE); }But the code in
xenvif_gop_frag_copy.. seems to be needing one moreslot (from the emperical test) .. and calling "
get_next_rx_buffer" seems involved in that ..Quoted 2 lines
Quoted 2 lines
Hmm looked again .. and it seems this is it .. when your frags are large
enough you have the chance of running into this.
Quoted 4 lines
Quoted 1 line
get_next_rx_bufferis guarded bystart_new_rx_buffer. Do you see any problem with that implementation?In general no, but "
get_next_rx_buffer" up's cons .. and the calculations done in "xenvif_rx_action" formax_slots_neededto prevent the overrun don't count in this possibility. So it's not the guarding of "start_new_rx_buffer" that is at fault. It's the ones early in "xenvif_rx_action".
The ones that were changed by Paul's patch fromMAX_SKB_FRAGSto a calculated value that should be a "slim fit".The problem is in determining upfront in "
xenvif_rx_action" when and how often the "get_next_rx_buffer" path will be taken.
Unless there are other non direct restrictions (from a size point of view) it can be called multiple times per frag per skb.Quoted 1 line
Quoted 1 line
Problem is .. i don't see an easy fix, the "one more slot" of the empirical
test doesn't seem to be the worst case either (i think):
Quoted 2 lines
Quoted 2 lines
- In my case the packets that hit this only have 1 frag, but i could have had
more frags.
Quoted 1 line
Quoted 1 line
I also think you can't rule out the possibility of doing the
"
get_next_rx_buffer" for multiple subsequent frags from one packet,Quoted 1 line
Quoted 1 line
so in the worst (and perhaps even from a single frag since it's looped
over a split of it in what seems
PAGE_SIZEpieces.)Quoted 1 line
Quoted 1 line
- So an exact calculation of how much slots we are going to need for
hitting this "
get_next_rx_buffer" upfront in "xenvif_rx_action" seems unfeasible.Quoted 1 line
Quoted 1 line
- A worst case gamble seems impossible either .. if you take multiple
frags * multiple times the "
get_next_rx_buffer" ... you would probably be back at justQuoted 3 lines
Quoted 3 lines
setting the
needed_slotstoMAX_SKB_FRAGS.- Other thing would be checking for the available slots before doing the
"
get_next_rx_buffer" .. how ever .. we don't account for how many slots we still need toQuoted 8 lines
Quoted 2 lines
just process the remaining frags.
We've done a worst case estimation for whole SKB (linear area + all frags) already, at the very first beginning. That's what
max_slots_neededis for.Quoted 1 line
- Just remove the whole "
get_next_rx_buffer".. just tested it but itseems the "
get_next_rx_buffer" is necessary .. when i makestart_new_rx_bufferalways return falseQuoted 3 lines
Quoted 3 lines
i hit the bug below :S
So the questions are ... is the "
get_next_rx_buffer" part really necessary?
Quoted 1 line
Quoted 1 line
- if not, what is the benefit of the "
get_next_rx_buffer" and does thatoutweigh the additional cost of accounting
Quoted 2 lines
Quoted 2 lines
of
needed_slotsfor the frags that have yet to be processed ?
- if yes, erhmmm what would be the best acceptable solution ..returning to using
MAX_SKB_FRAGS?Quoted 4 lines
Quoted 1 line
I think you need to answer several questions first:
1. ismax_slots_neededactually large enough to cover whole SKB?No it's not if, you end up calling "
get_next_rx_buffer" one or multiple
times when processing the SKB
you have the chance of overrunning (or be saved because prod gets
upped before you overrun).Quoted 1 line
2. is the test of ring slot availability acurate?
Seems to be.
Quoted 2 lines
3. is the number of ring slots consumed larger than
max_slots_needed? (I guess the answer is yes)Yes that was the whole point.
Quoted 2 lines
4. which step in the break-down procedure causes backend to overrun the ring?
The "
get_next_rx_buffer" call .. that is not accounted for (which can be
called
multiple times per frag (unless some other none obvious size restriction
limits this
to one time per frag or one time per SKB).
In my errorneous case it is called one time, but it would be nice if there
would be some theoretical proof
instead of just some emperical test.Quoted 4 lines
It doesn't matter how many frags your SKB has and how big a frag is. If every step is correct then you're fine. The code you're looking at (
start_new_rx_buffer/get_next_rx_bufferand friend) needs to be carefully examined.
Quoted 9 lines
Well it seems it only calls "
get_next_rx_buffer" in some special cases .. (and that also what i'm seeing because it doesn't happen
continously.Question is shouldn't this
max_needed_slotscalc be reverted to what it was before 3.14 and take the time in 3.15 to figure out a
the theoretical max (if it can be calculated upfront) .. or another way to guarantee the code is able to process the whole SKB ?
Reverting that patch and falling back to the old slot counting code will simply awaken the bugs that that patch fixed. There is no reason why a worst case skb fragmentation (i.e. assuming no packing of multiple frags into a slot) cannot be calculated up-front.
Paul
Quoted 2 lines
Quoted 1 line
Wei.
Re: Xen-unstable Linux 3.14-rc3 and 3.13 Network troubles "bisected"
In reply to Wei LiuQuoted 41 lines · you
Quoted 40 lines · Sander Eikelenboom
Quoted 26 lines · you
On Wed, Mar 12, 2014 at 03:23:36PM +0100, Sander Eikelenboom wrote:
[...]Quoted 24 lines
Quoted 6 lines
From the look of the code, 0 looks correct to me. Netback won't complain about "bad gref" because it has no idea what a "good gref" looks like. Only Xen has the knowledge whether a gref is legit. All netback sees is the hypercall fails and it tries to push corresponding response to netfront. But you can probably safely assume a gref larger than several thousands be bad.
OK it's indeed netback setting the status to -1:
[ 976.431585] vif vif-7-0 vif7.0: ?!? xenvif_rx_action status err? status:-1 meta_slots_used:1 flags:3 size:958 [ 1030.855057] vif vif-7-0 vif7.0: ?!? xenvif_rx_action status err? status:-1 meta_slots_used:2 flags:7 size:2974 [ 1030.861759] vif vif-7-0 vif7.0: ?!? xenvif_add_frag_responses status err? status:-1 i:0 nr_meta_slots:1 flags:0 size:1460 [ 1030.868499] vif vif-7-0 vif7.0: ?!? xenvif_rx_action status err? status:-1 meta_slots_used:1 flags:3 size:958 [ 1030.875278] vif vif-7-0 vif7.0: ?!? xenvif_rx_action status err? status:-1 meta_slots_used:1 flags:3 size:2974 [ 1068.199650] vif vif-7-0 vif7.0: ?!? xenvif_rx_action status err? status:-1 meta_slots_used:8 flags:7 size:1634 [ 1068.206479] vif vif-7-0 vif7.0: ?!? xenvif_add_frag_responses status err? status:-1 i:0 nr_meta_slots:7 flags:4 size:2848 [ 1068.213158] vif vif-7-0 vif7.0: ?!? xenvif_add_frag_responses status err? status:-1 i:1 nr_meta_slots:7 flags:4 size:4096 [ 1068.219701] vif vif-7-0 vif7.0: ?!? xenvif_add_frag_responses status err? status:-1 i:2 nr_meta_slots:7 flags:4 size:4096 [ 1068.226194] vif vif-7-0 vif7.0: ?!? xenvif_add_frag_responses status err? status:-1 i:3 nr_meta_slots:7 flags:4 size:4096 [ 1068.232728] vif vif-7-0 vif7.0: ?!? xenvif_add_frag_responses status err? status:-1 i:4 nr_meta_slots:7 flags:4 size:4096 [ 1068.239163] vif vif-7-0 vif7.0: ?!? xenvif_add_frag_responses status err? status:-1 i:5 nr_meta_slots:7 flags:4 size:4096 [ 1068.245397] vif vif-7-0 vif7.0: ?!? xenvif_add_frag_responses status err? status:-1 i:6 nr_meta_slots:7 flags:0 size:1168 [ 1068.251457] vif vif-7-0 vif7.0: ?!? xenvif_rx_action status err? status:-1 meta_slots_used:1 flags:3 size:958Quoted 4 lines
Quoted 2 lines
Now to find out why ..
-1 is the error code documented in
netif.h,XEN_NETIF_RSP_ERROR.grant copy fails ->> netback sets response status to -1.
Quoted 3 lines
Assuming the traffic volumn is quite high both way (TX and RX), probably worth checking if RX ring is overflowed. That is, if consumer pointer(s) advance before producer pointer(s).
Quoted 6 lines
Quoted 2 lines
In what function ?
That should be in RX path. Look for "RING_GET_REQUESTS(&vif->rx". That's the macro to get a slot in RX ring; second argument is consumer index. You can see if it advances before producer index.
Ah RING_GET_REQUEST it is ... compiling again ..
Quoted 4 lines
Wei.
Quoted 2 lines
Quoted 1 line
Wei.
Quoted 82 lines · Wei Liu
Quoted 64 lines · Sander Eikelenboom
Quoted 58 lines · you
Quoted 45 lines · you
Quoted 29 lines · Sander Eikelenboom
Quoted 19 lines · you
Quoted 5 lines · Sander Eikelenboom
Hi All,
I'm currently having some network troubles with Xen and recent linux kernels.
- When running with a 3.14-rc3 kernel in dom0 and a 3.13 kernel in domU
Quoted 13 lines
I get what seems to be described in this thread: http://www.spinics.net/lists/netdev/msg242953.html In the guest: [57539.859584] net eth0: rx->offset: 0, size: 4294967295 [57539.859599] net eth0: rx->offset: 0, size: 4294967295 [57539.859605] net eth0: rx->offset: 0, size: 4294967295 [57539.859610] net eth0: Need more slots [58157.675939] net eth0: Need more slots [58725.344712] net eth0: Need more slots [61815.849180] net eth0: rx->offset: 0, size: 4294967295 [61815.849205] net eth0: rx->offset: 0, size: 4294967295 [61815.849216] net eth0: rx->offset: 0, size: 4294967295 [61815.849225] net eth0: Need more slotsQuoted 4 lines
This issue is familiar... and I thought it get fixed.
From original analysis for similar issue I hit before, the root cause
is netback still creates response when the ring is full. I remember larger MTU can trigger this issue before, what is the MTU size?In dom0 both for the physical nics and the guest vif's MTU=1500 In domU the eth0 also has MTU=1500.
Quoted 7 lines
So it's not jumbo frames .. just everywhere the same plain defaults ..
With the patch from Wei that solves the other issue, i'm still seeing the Need more slots issue on 3.14-rc3+wei's patch now.
I have extended the "need more slots warn" to also print the cons, slots, max,rx->offset, size, hope that gives some more insight.
But it indeed is the VM were i had similar issues before, the primary thing this VM does is 2 simultaneous rsync's (one push one pull) with some gigabytes of data.This time it was also acompanied by a "grant_table.c:1857:d0 Bad grant reference " as seen below, don't know if it's a cause or a effect though.
The log "grant_table.c:1857:d0 Bad grant reference " was also seen before. Probably the response overlaps the request and grantcopy return error when using wrong grant reference, Netback returns
resp->statuswith ||XEN_NETIF_RSP_ERROR(-1) which is 4294967295 printed above from frontend. Would it be possible to print log inxenvif_rx_actionof netback to see whether something wrong with max slots and used slots?Quoted 2 lines
Thanks
AnnieLooking more closely it are perhaps 2 different issues ... the bad grant references do not happen at the same time as the netfront messages in the guest.
I added some debugpatches to the kernel netback, netfront and xen granttable code (see below) One of the things was to simplify the code for the debug key to print the granttables, the present code takes too long to execute and brings down the box due to stalls and NMI's. So it now only prints the nr of entries per domain.
Quoted 8 lines
Quoted 7 lines
Issue 1: grant_table.c:1858:d0 Bad grant reference
After running the box for just one night (with 15 VM's) i get these mentions of "Bad grant reference". The maptrack also seems to increase quite fast and the number of entries seem to have gone up quite fast as well.
Most domains have just one disk(blkfront/blkback) and one nic, a few have a second disk. The blk drivers use persistent grants so i would assume it would reuse those and not increase it (by much).
As far as I can tell netfront has a pool of grant references and it will
BUG_ON()if there's no grefs in the pool when you request one. Since your DomU didn't crash so I suspect the book-keeping is still intact.Quoted 3 lines
Quoted 2 lines
Domain 1 seems to have increased it's
nr_grant_entriesfrom 2048 to 3072 somewhere this night. Domain 7 is the domain that happens to give the netfront messages.
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
I also don't get why it is reporting the "Bad grant reference" for domain 0, which seems to have 0 active entries .. Also is this amount of grant entries "normal" ? or could it be a leak somewhere ?
I suppose Dom0 expanding its maptrack is normal. I see as well when I increase the number of domains. But if it keeps increasing while the number of DomUs stay the same then it is not normal.
blkfront/blkback will allocate persistent grants on demand, so it's not strange to see the number of grants increasing while the domain is running (although it should reach a stable state at some point).
Roger.
On Thu, Feb 27, 2014 at 04:36:52PM +0100, Roger Pau Monné wrote:
[...]
Quoted 10 lines
Quoted 5 lines
Quoted 1 line
I suppose Dom0 expanding its maptrack is normal. I see as well when I increase the number of domains. But if it keeps increasing while the number of DomUs stay the same then it is not normal.
blkfront/blkback will allocate persistent grants on demand, so it's not strange to see the number of grants increasing while the domain is running (although it should reach a stable state at some point).
Yes, that's exactly what I meant. :-)
Wei.
Quoted 1 line
Roger.