From patchwork Thu Aug 16 15:39:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 958414 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41rrBT5Blsz9s4s; Fri, 17 Aug 2018 01:40:17 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fqKNc-0001ji-MP; Thu, 16 Aug 2018 15:40:08 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fqKNb-0001jW-A5 for kernel-team@lists.ubuntu.com; Thu, 16 Aug 2018 15:40:07 +0000 Received: from mail-qk0-f197.google.com ([209.85.220.197]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fqKNb-0006ZS-0V for kernel-team@lists.ubuntu.com; Thu, 16 Aug 2018 15:40:07 +0000 Received: by mail-qk0-f197.google.com with SMTP id l11-v6so4897505qkk.0 for ; Thu, 16 Aug 2018 08:40:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=zO5M0CXibAWnrn0afpEdaBQ18yYFbeIyhlWU/f58V6Q=; b=dgO7pkacFgfnK46YCxmdktvAb+iFOhV+z/fIuXH4ybAm9kjDunjRUljGi6oinIjFAZ NdPo370HoAXaaLXbZRlu35l3Z51/MP0hnhIH34zT+5uIDh8ujb8Qu+TNwC/EiZFVAvyd YrFB5UT5MuKO1X1JsAbu9PmwC3oEyHddzp6QjlqvE8HwR/6W4NQy0DfOMfGDg0Aayb7Z GQ+Apg3Gtd4/mcHSXkXNQgbRUUUI9Hhzw38RqMs/XHA7MLkG9n5X1zsDOz6r3Mvt180d I4io3VWuiF1nYEFdQVm8QQos987JJKpQLL7qwvgz3ANPVgUPORKJlKPfsg2raoZ5r99s stRA== X-Gm-Message-State: AOUpUlEghNmPOPG5nrCNCgZezS2rOpLxlaqUsRqOj4RU9zWCQGK3TTAb BYIbVTut2jDUL/9htBX0zAo42IRgNK2NgipA0+RkCDsQy+znAMfGplnx3eKA3tvZhIBDPb6UrCL 25+14v8HFBZvqww0gJj11EqqcSkrg7R3SPZuI+sQ0 X-Received: by 2002:a37:32cb:: with SMTP id y194-v6mr27716390qky.11.1534434005794; Thu, 16 Aug 2018 08:40:05 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwSy2J6RT2vVw5PvweCpfHZn9/sMpA+f4RUHfiRqNtW01HLt3LDrYT3mHmh9Kz9BdNCT9814A== X-Received: by 2002:a37:32cb:: with SMTP id y194-v6mr27716376qky.11.1534434005506; Thu, 16 Aug 2018 08:40:05 -0700 (PDT) Received: from localhost.localdomain ([177.9.56.109]) by smtp.gmail.com with ESMTPSA id u25-v6sm13355025qkk.7.2018.08.16.08.40.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 08:40:04 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic/linux-azure][PATCH] hv_netvsc: Fix napi reschedule while receive completion is busy Date: Thu, 16 Aug 2018 12:39:59 -0300 Message-Id: <20180816153959.6489-1-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Haiyang Zhang BugLink: http://bugs.launchpad.net/bugs/1786313 If out ring is full temporarily and receive completion cannot go out, we may still need to reschedule napi if certain conditions are met. Otherwise the napi poll might be stopped forever, and cause network disconnect. Fixes: 7426b1a51803 ("netvsc: optimize receive completions") Signed-off-by: Stephen Hemminger Signed-off-by: Haiyang Zhang Signed-off-by: David S. Miller (cherry picked from commit 6b81b193b83e87da1ea13217d684b54fccf8ee8a) Signed-off-by: Marcelo Henrique Cerri Acked-by: Colin Ian King Acked-by: Kamal Mostafa --- drivers/net/hyperv/netvsc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index b500baf99eba..b2c3a28381b9 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -1222,6 +1222,7 @@ int netvsc_poll(struct napi_struct *napi, int budget) struct hv_device *device = netvsc_channel_to_device(channel); struct net_device *ndev = hv_get_drvdata(device); int work_done = 0; + int ret; /* If starting a new interval */ if (!nvchan->desc) @@ -1233,16 +1234,18 @@ int netvsc_poll(struct napi_struct *napi, int budget) nvchan->desc = hv_pkt_iter_next(channel, nvchan->desc); } - /* If send of pending receive completions suceeded - * and did not exhaust NAPI budget this time - * and not doing busy poll + /* Send any pending receive completions */ + ret = send_recv_completions(ndev, net_device, nvchan); + + /* If it did not exhaust NAPI budget this time + * and not doing busy poll * then re-enable host interrupts - * and reschedule if ring is not empty. + * and reschedule if ring is not empty + * or sending receive completion failed. */ - if (send_recv_completions(ndev, net_device, nvchan) == 0 && - work_done < budget && + if (work_done < budget && napi_complete_done(napi, work_done) && - hv_end_read(&channel->inbound) && + (ret || hv_end_read(&channel->inbound)) && napi_schedule_prep(napi)) { hv_begin_read(&channel->inbound); __napi_schedule(napi);