All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] xen-netfront: Fix Rx stall during network stress and OOM
@ 2017-01-18 20:25 ` Remanan Pillai
  0 siblings, 0 replies; 31+ messages in thread
From: Remanan Pillai @ 2017-01-18 20:25 UTC (permalink / raw)
  To: boris.ostrovsky, jgross, davem, xen-devel, netdev, linux-kernel
  Cc: Vineeth Remanan Pillai, kamatam, aliguori

From: Vineeth Remanan Pillai <vineethp@amazon.com>

During an OOM scenario, request slots could not be created as skb
allocation fails. So the netback cannot pass in packets and netfront
wrongly assumes that there is no more work to be done and it disables
polling. This causes Rx to stall.

The issue is with the retry logic which schedules the timer if the
created slots are less than NET_RX_SLOTS_MIN. The count of new request
slots to be pushed are calculated as a difference between new req_prod
and rsp_cons which could be more than the actual slots, if there are
unconsumed responses.

The fix is to calculate the count of newly created slots as the
difference between new req_prod and old req_prod.

Signed-off-by: Vineeth Remanan Pillai <vineethp@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
---
Changes in v2:
	- Removed the old implementation of enabling polling on
	  skb allocation error.
	- Corrected the refill timer logic to schedule when newly
	  created slots since last push is less than NET_RX_SLOTS_MIN.

 drivers/net/xen-netfront.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 40f26b6..2c7c29f 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -321,7 +321,7 @@ static void xennet_alloc_rx_buffers(struct netfront_queue *queue)
 	queue->rx.req_prod_pvt = req_prod;
 
 	/* Not enough requests? Try again later. */
-	if (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN) {
+	if (req_prod - queue->rx.sring->req_prod < NET_RX_SLOTS_MIN) {
 		mod_timer(&queue->rx_refill_timer, jiffies + (HZ/10));
 		return;
 	}
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 31+ messages in thread
* Re: [PATCH] xen-netfront: Fix Rx stall during network stress and OOM
@ 2017-01-12 23:09 Vineeth Remanan Pillai
  2017-01-13 17:55   ` Remanan Pillai
  0 siblings, 1 reply; 31+ messages in thread
From: Vineeth Remanan Pillai @ 2017-01-12 23:09 UTC (permalink / raw)
  To: David Miller
  Cc: boris.ostrovsky, jgross, xen-devel, netdev, linux-kernel,
	kamatam, aliguori



On 01/12/2017 12:17 PM, David Miller wrote:
> From: Vineeth Remanan Pillai <vineethp@amazon.com>
> Date: Wed, 11 Jan 2017 23:17:17 +0000
>
>> @@ -1054,7 +1059,11 @@ static int xennet_poll(struct napi_struct *napi, int budget)
>>   		napi_complete(napi);
>>   
>>   		RING_FINAL_CHECK_FOR_RESPONSES(&queue->rx, more_to_do);
>> -		if (more_to_do)
>> +
>> +		/* If there is more work to do or could not allocate
>> +		 * rx buffers, re-enable polling.
>> +		 */
>> +		if (more_to_do || err != 0)
>>   			napi_schedule(napi);
> Just polling endlessly in a loop retrying the SKB allocation over and over
> again until it succeeds is not very nice behavior.
>
> You already have that refill timer, so please use that to retry instead
> of wasting cpu cycles looping in NAPI poll.
Thanks Dave for the inputs.
On further look, I think I can fix it much simpler by correcting the 
test condition
for minimum slots for pushing requests. Existing test is like this:

<snip>
         /* Not enough requests? Try again later. */
        if (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN) {
                 mod_timer(&queue->rx_refill_timer, jiffies + (HZ/10));
                 return;
         }
</snip>

Actually the above check counts more than the newly created request slots
as it counts from rsp_cons. The actual count should be the difference 
between
new req_prod and old req_prod(in the queue). If skbs cannot be created, 
this
count remains small and hence we would schedule the timer. So the fix 
could be:

         /* Not enough requests? Try again later. */
-       if (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN) {
+       if (req_prod - queue->rx.sring->req_prod < NET_RX_SLOTS_MIN) {


I have done some initial testing to verify the fix. Will send out v2 
patch after couple
more round of testing.

Thanks,
Vineeth

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

end of thread, other threads:[~2017-01-31 16:53 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-18 20:25 [PATCH v2] xen-netfront: Fix Rx stall during network stress and OOM Remanan Pillai
2017-01-18 20:25 ` Remanan Pillai
2017-01-19 16:35 ` Vineeth Remanan Pillai
2017-01-19 17:11   ` David Miller
2017-01-19 17:17     ` Vineeth Remanan Pillai
2017-01-19 18:10       ` David Miller
2017-01-20 19:09   ` David Miller
2017-01-29 23:09   ` Boris Ostrovsky
2017-01-29 23:09     ` Boris Ostrovsky
2017-01-30 16:47     ` Vineeth Remanan Pillai
2017-01-30 16:47       ` Vineeth Remanan Pillai
2017-01-30 16:47       ` Vineeth Remanan Pillai
2017-01-30 17:06       ` Boris Ostrovsky
2017-01-30 17:06         ` Boris Ostrovsky
2017-01-30 17:13         ` Vineeth Remanan Pillai
2017-01-30 17:13         ` Vineeth Remanan Pillai
2017-01-31 16:47       ` Vineeth Remanan Pillai
2017-01-31 16:47         ` Vineeth Remanan Pillai
  -- strict thread matches above, loose matches on Subject: below --
2017-01-12 23:09 [PATCH] " Vineeth Remanan Pillai
2017-01-13 17:55 ` [PATCH v2] " Remanan Pillai
2017-01-13 17:55   ` Remanan Pillai
2017-01-16  6:24   ` Juergen Gross
2017-01-16  6:24   ` Juergen Gross
2017-01-18 17:02     ` Vineeth Remanan Pillai
2017-01-18 17:02       ` Vineeth Remanan Pillai
2017-01-18 17:02       ` Vineeth Remanan Pillai
2017-01-18 20:08       ` David Miller
2017-01-18 20:08         ` David Miller
2017-01-18 20:10       ` David Miller
2017-01-18 20:10         ` David Miller
2017-01-18 20:24         ` Vineeth Remanan Pillai
2017-01-18 20:24           ` Vineeth Remanan Pillai

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