From patchwork Thu Apr 5 17:55:34 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: 895483 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]) by ozlabs.org (Postfix) with ESMTP id 40H9VS0HwKz9rxp; Fri, 6 Apr 2018 03:56:00 +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 1f4976-00076R-R4; Thu, 05 Apr 2018 17:55:56 +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 1f4975-00074i-Ay for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:55 +0000 Received: from mail-qk0-f200.google.com ([209.85.220.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1f4975-0000Tw-0y for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:55 +0000 Received: by mail-qk0-f200.google.com with SMTP id a125so17491659qkd.4 for ; Thu, 05 Apr 2018 10:55:54 -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:in-reply-to :references; bh=HHspJjWZ0TqKdmJNudiMaSe7PADCFM+ij+qdaulQROY=; b=TvvFjXn5mGTKnJ78FLKfhKI3hOhSlICUFSmKqvKF5xY8s0g5e0SHp/aE/BUMLelGmJ iIm/d00mQRLE5yAgIEajmff8UypBjT2j46kl9HJ4TfUPmilAjKK49paJFTE74T42+Lek o15ynBnsdjIkr8e09pIebblJNVLkLzDcPhzqbBkRS1rTuojxjGfbCSAxdOLSxVf2XVyp sB4c5UF02rtwX7SV/8Cd/vpjBQObTW3hG2eKkUVplZ8dHnFIZ410l+NqkGBIK2tLS6YV aOx4yNN9+jZlvCMC6nTZ8eaEe3b56LKlaCiWXSzT5Hrgs7jljbGvrOn4hnebYkrNQKY3 scvQ== X-Gm-Message-State: ALQs6tAAmG8YgbuMOvJEHzQ14mh0fStLFR4OdObT7MGyOV1vPilIjaAY IN6xfS9c0evKuTERyNjx9/akGKP4sW6f3fI7emLSYIuYdeKOWwRpBoP1+qigUUkoq718qLqeZeB uPNzzmbpobTpnBhOi143sDnQPHMEqbXGAg2uihret X-Received: by 10.237.60.155 with SMTP id d27mr33502697qtf.210.1522950953829; Thu, 05 Apr 2018 10:55:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+MkoK+scua0KVjCCXWOTGahP94HA442Ge9s8GK552JyKfoUyEpQhkwng6sMZfgRoBkeZjFGA== X-Received: by 10.237.60.155 with SMTP id d27mr33502679qtf.210.1522950953593; Thu, 05 Apr 2018 10:55:53 -0700 (PDT) Received: from localhost.localdomain ([191.8.81.129]) by smtp.gmail.com with ESMTPSA id m53sm6854230qtf.67.2018.04.05.10.55.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 10:55:52 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure:x][PATCH 5/5] UBUNTU: SAUCE: PCI: hv: Only queue new work items in hv_pci_devices_present() if necessary Date: Thu, 5 Apr 2018 14:55:34 -0300 Message-Id: <1522950934-8127-6-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> References: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> 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: Dexuan Cui BugLink: http://bugs.launchpad.net/bugs/1758378 If there is pending work in hv_pci_devices_present() we just need to add the new dr entry into the dr_list. Add a check to detect pending work items and update the code to skip queuing work if pending work items are detected. Signed-off-by: Dexuan Cui [lorenzo.pieralisi@arm.com: updated commit log] Signed-off-by: Lorenzo Pieralisi Reviewed-by: Michael Kelley Acked-by: Haiyang Zhang Cc: Vitaly Kuznetsov Cc: Jack Morgenstein Cc: Stephen Hemminger Cc: K. Y. Srinivasan Signed-off-by: Marcelo Henrique Cerri --- drivers/pci/host/pci-hyperv.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index f639be35381b..415aaad2e924 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -1805,6 +1805,7 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus, struct hv_dr_state *dr; struct hv_dr_work *dr_wrk; unsigned long flags; + bool pending_dr; dr_wrk = kzalloc(sizeof(*dr_wrk), GFP_NOWAIT); if (!dr_wrk) @@ -1828,11 +1829,21 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus, } spin_lock_irqsave(&hbus->device_list_lock, flags); + /* + * If pending_dr is true, we have already queued a work, + * which will see the new dr. Otherwise, we need to + * queue a new work. + */ + pending_dr = !list_empty(&hbus->dr_list); list_add_tail(&dr->list_entry, &hbus->dr_list); spin_unlock_irqrestore(&hbus->device_list_lock, flags); - get_hvpcibus(hbus); - queue_work(hbus->wq, &dr_wrk->wrk); + if (pending_dr) { + kfree(dr_wrk); + } else { + get_hvpcibus(hbus); + queue_work(hbus->wq, &dr_wrk->wrk); + } } /**