* [PATCH net-next] xen-netback: Schedule NAPI from dealloc thread instead of callback
@ 2014-03-12 21:04 Zoltan Kiss
2014-03-13 10:17 ` Wei Liu
0 siblings, 1 reply; 5+ messages in thread
From: Zoltan Kiss @ 2014-03-12 21:04 UTC (permalink / raw)
To: ian.campbell, wei.liu2, xen-devel
Cc: netdev, linux-kernel, jonathan.davies, Zoltan Kiss
If there are unconsumed requests in the ring, but there isn't enough free
pending slots, the NAPI instance deschedule itself. As the frontend won't send
any more interrupts in this case, it is the task of whoever release the pending
slots to schedule the NAPI instance in this case. Originally it was done in the
callback, but it's better at the end of the dealloc thread, otherwise there is
a risk that the NAPI instance just deschedule itself as the dealloc thread
couldn't release any used slot yet. However, as there are a lot of pending
packets, NAPI will be scheduled again, and it is very unlikely that the dealloc
thread can't release enough slots in the meantime.
Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com>
---
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index eae9724..07c9677 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -1516,13 +1516,6 @@ void xenvif_zerocopy_callback(struct ubuf_info *ubuf, bool zerocopy_success)
wake_up(&vif->dealloc_wq);
spin_unlock_irqrestore(&vif->callback_lock, flags);
- if (RING_HAS_UNCONSUMED_REQUESTS(&vif->tx) &&
- xenvif_tx_pending_slots_available(vif)) {
- local_bh_disable();
- napi_schedule(&vif->napi);
- local_bh_enable();
- }
-
if (likely(zerocopy_success))
vif->tx_zerocopy_success++;
else
@@ -1594,6 +1587,13 @@ static inline void xenvif_tx_dealloc_action(struct xenvif *vif)
for (i = 0; i < gop - vif->tx_unmap_ops; ++i)
xenvif_idx_release(vif, pending_idx_release[i],
XEN_NETIF_RSP_OKAY);
+
+ if (RING_HAS_UNCONSUMED_REQUESTS(&vif->tx) &&
+ xenvif_tx_pending_slots_available(vif)) {
+ local_bh_disable();
+ napi_schedule(&vif->napi);
+ local_bh_enable();
+ }
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] xen-netback: Schedule NAPI from dealloc thread instead of callback
2014-03-12 21:04 [PATCH net-next] xen-netback: Schedule NAPI from dealloc thread instead of callback Zoltan Kiss
@ 2014-03-13 10:17 ` Wei Liu
2014-03-13 10:42 ` Ian Campbell
0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2014-03-13 10:17 UTC (permalink / raw)
To: Zoltan Kiss
Cc: jonathan.davies, wei.liu2, ian.campbell, netdev, linux-kernel,
xen-devel
On Wed, Mar 12, 2014 at 09:04:41PM +0000, Zoltan Kiss wrote:
> If there are unconsumed requests in the ring, but there isn't enough free
> pending slots, the NAPI instance deschedule itself. As the frontend won't send
> any more interrupts in this case, it is the task of whoever release the pending
> slots to schedule the NAPI instance in this case. Originally it was done in the
> callback, but it's better at the end of the dealloc thread, otherwise there is
> a risk that the NAPI instance just deschedule itself as the dealloc thread
> couldn't release any used slot yet. However, as there are a lot of pending
> packets, NAPI will be scheduled again, and it is very unlikely that the dealloc
> thread can't release enough slots in the meantime.
>
So this patch restores the property that "only two parties access the
ring", right?
Wei.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] xen-netback: Schedule NAPI from dealloc thread instead of callback
2014-03-13 10:17 ` Wei Liu
@ 2014-03-13 10:42 ` Ian Campbell
2014-03-13 15:44 ` Zoltan Kiss
0 siblings, 1 reply; 5+ messages in thread
From: Ian Campbell @ 2014-03-13 10:42 UTC (permalink / raw)
To: Wei Liu; +Cc: Zoltan Kiss, xen-devel, netdev, linux-kernel, jonathan.davies
On Thu, 2014-03-13 at 10:17 +0000, Wei Liu wrote:
> On Wed, Mar 12, 2014 at 09:04:41PM +0000, Zoltan Kiss wrote:
> > If there are unconsumed requests in the ring, but there isn't enough free
> > pending slots, the NAPI instance deschedule itself. As the frontend won't send
> > any more interrupts in this case, it is the task of whoever release the pending
> > slots to schedule the NAPI instance in this case. Originally it was done in the
> > callback, but it's better at the end of the dealloc thread, otherwise there is
> > a risk that the NAPI instance just deschedule itself as the dealloc thread
> > couldn't release any used slot yet. However, as there are a lot of pending
> > packets, NAPI will be scheduled again, and it is very unlikely that the dealloc
> > thread can't release enough slots in the meantime.
> >
>
> So this patch restores the property that "only two parties access the
> ring", right?
I think so, and therefore:
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Ian.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] xen-netback: Schedule NAPI from dealloc thread instead of callback
2014-03-13 10:42 ` Ian Campbell
@ 2014-03-13 15:44 ` Zoltan Kiss
2014-03-13 19:48 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Zoltan Kiss @ 2014-03-13 15:44 UTC (permalink / raw)
To: Ian Campbell, Wei Liu; +Cc: xen-devel, netdev, linux-kernel, jonathan.davies
On 13/03/14 10:42, Ian Campbell wrote:
> On Thu, 2014-03-13 at 10:17 +0000, Wei Liu wrote:
>> On Wed, Mar 12, 2014 at 09:04:41PM +0000, Zoltan Kiss wrote:
>>> If there are unconsumed requests in the ring, but there isn't enough free
>>> pending slots, the NAPI instance deschedule itself. As the frontend won't send
>>> any more interrupts in this case, it is the task of whoever release the pending
>>> slots to schedule the NAPI instance in this case. Originally it was done in the
>>> callback, but it's better at the end of the dealloc thread, otherwise there is
>>> a risk that the NAPI instance just deschedule itself as the dealloc thread
>>> couldn't release any used slot yet. However, as there are a lot of pending
>>> packets, NAPI will be scheduled again, and it is very unlikely that the dealloc
>>> thread can't release enough slots in the meantime.
>>>
>>
>> So this patch restores the property that "only two parties access the
>> ring", right?
>
> I think so, and therefore:
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
I've just discussed this with Ian, this solution still doesn't solve the
racing between NAPI and the dealloc thread, however it only causes some
unnecessary napi_schedule's, not ring stalls.
There is a better solution, I'll post it as soon as it passes all the test!
Zoli
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] xen-netback: Schedule NAPI from dealloc thread instead of callback
2014-03-13 15:44 ` Zoltan Kiss
@ 2014-03-13 19:48 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2014-03-13 19:48 UTC (permalink / raw)
To: zoltan.kiss
Cc: Ian.Campbell, wei.liu2, xen-devel, netdev, linux-kernel,
jonathan.davies
From: Zoltan Kiss <zoltan.kiss@citrix.com>
Date: Thu, 13 Mar 2014 15:44:37 +0000
> I've just discussed this with Ian, this solution still doesn't solve
> the racing between NAPI and the dealloc thread, however it only causes
> some unnecessary napi_schedule's, not ring stalls.
> There is a better solution, I'll post it as soon as it passes all the
> test!
Ok, I'm skipping this patch therefore.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-03-13 19:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-12 21:04 [PATCH net-next] xen-netback: Schedule NAPI from dealloc thread instead of callback Zoltan Kiss
2014-03-13 10:17 ` Wei Liu
2014-03-13 10:42 ` Ian Campbell
2014-03-13 15:44 ` Zoltan Kiss
2014-03-13 19:48 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).