From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750950AbdALXKE (ORCPT ); Thu, 12 Jan 2017 18:10:04 -0500 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:7353 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750730AbdALXKD (ORCPT ); Thu, 12 Jan 2017 18:10:03 -0500 X-IronPort-AV: E=Sophos;i="5.33,220,1477958400"; d="scan'208";a="660385264" Subject: Re: [PATCH] xen-netfront: Fix Rx stall during network stress and OOM To: David Miller References: <1484176637-2869-1-git-send-email-vineethp@amazon.com> <20170112.151706.1389870722624942785.davem@davemloft.net> CC: , , , , , , From: Vineeth Remanan Pillai Message-ID: <0cb06b48-cb3c-47aa-2ae6-3a70197a5b64@amazon.com> Date: Thu, 12 Jan 2017 15:09:43 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170112.151706.1389870722624942785.davem@davemloft.net> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.43.160.82] X-ClientProxiedBy: EX13D03UWA002.ant.amazon.com (10.43.160.144) To EX13D08UWC003.ant.amazon.com (10.43.162.21) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/12/2017 12:17 PM, David Miller wrote: > From: Vineeth Remanan Pillai > 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: /* 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; } 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