From patchwork Fri Jun 8 18:39:11 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: 926982 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 412WR95Pqdz9ry1; Sat, 9 Jun 2018 04:39:33 +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 1fRMIJ-0007Sx-0j; Fri, 08 Jun 2018 18:39:27 +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 1fRMIH-0007Rl-2E for kernel-team@lists.ubuntu.com; Fri, 08 Jun 2018 18:39:25 +0000 Received: from mail-qk0-f198.google.com ([209.85.220.198]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fRMIG-0007bb-Nv for kernel-team@lists.ubuntu.com; Fri, 08 Jun 2018 18:39:24 +0000 Received: by mail-qk0-f198.google.com with SMTP id i64-v6so13880426qkh.14 for ; Fri, 08 Jun 2018 11:39:24 -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=ZViEggJe3wyPr1XwJbN5Re2qWwba+YUhODiCEeLj+sY=; b=rmgABgVjJ0CM9+YXnG3XVsvJ/38z5dvK3wlHz0V+/bHz0Iq59xB6AXux07VX4ZHrTp BCo6/cfpXNrIR9+UZ4vngRxqfWbxLjMG3zWoaZG+REWaOoARE8mHXW+orqbxd1ZsYaox 0/YA+YC3C1eXgcNbeYftlnog0oB1MdyJ+b+7aUaBy4hdTl8BVb8LoeeqJfqqn7/Ux63K ILjDEaj+zuqH1sxNTh/cybizvoKjVQ/81k+ngXDQTMD32Tuu8RoO06Y6Z1YcxQKuUoeP 1ImcMnrnlSNOwKPYELVWYrL+A+ZIHflqnNCS63+2J0rzpDPcgNheO8HAeNtCecw/GGwp H/VA== X-Gm-Message-State: APt69E1EV0ptU0KlFDJqFypfDA2XKaz2kSyCtUJaf/ce4Eti38UD4ocy 3xZqSlyeKN+xCael4y7ANUroQFlyESThTvh+lzkwEoXVUA4KWyJK4sOT8ygREJ3iENFBGnqipU9 sEt9H2G9nH2VSj+qZNJo6IKcIg68PPjdmksWf8hrC X-Received: by 2002:a37:5687:: with SMTP id k129-v6mr2588604qkb.163.1528483163476; Fri, 08 Jun 2018 11:39:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIdasUG/JPGVqhcYwpD9CJwRYdc8HOVCYjzUPc/j9Q/QwGXMAcdueEoh+RD3h0uV4TohPn6JA== X-Received: by 2002:a37:5687:: with SMTP id k129-v6mr2588592qkb.163.1528483163248; Fri, 08 Jun 2018 11:39:23 -0700 (PDT) Received: from localhost.localdomain ([179.97.166.78]) by smtp.gmail.com with ESMTPSA id k2-v6sm35111688qkl.95.2018.06.08.11.39.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jun 2018 11:39:22 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [SRU][Bionic][PATCH 3/3] PCI: hv: Only queue new work items in hv_pci_devices_present() if necessary Date: Fri, 8 Jun 2018 15:39:11 -0300 Message-Id: <20180608183911.24395-4-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180608183911.24395-1-marcelo.cerri@canonical.com> References: <20180608183911.24395-1-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 (cherry picked from commit 948373b3ed1bcf05a237c24675b84804315aff14) 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 5eb7954ee584..f7d36c03486c 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -1801,6 +1801,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) @@ -1824,11 +1825,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); + } } /**