Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp854953imm; Wed, 4 Jul 2018 07:09:03 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfMBDswRcX3Jw+eVcHLFTvaI3P6/Bpayq+4QtZ8tfmsMGhcR8brRvjtdc7GW8F8Yka/1smR X-Received: by 2002:a62:930c:: with SMTP id b12-v6mr2336217pfe.193.1530713343777; Wed, 04 Jul 2018 07:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530713343; cv=none; d=google.com; s=arc-20160816; b=L0YT/vPwaUv3gzUozjRcWfcd6jjHG49iGlxhIUZ4juy9JECYP2FlYceYUL5Z7s25tv 6sLiCr/ZCrbf3KG0s/RvOiq3obwKUQII1Z2uFNp1YW59wJTjPx/K0gi26EFpx0DtUoeM FbEKhv8x0lQmlFvVwEr0b5A2s/Bl9fpq/0m5QbLCDoVBugX6MkNacSI8aEhOLHI0QJix s/tTP5ETG/bswYBjG2VOznGDBu7AARW+JImpCTR+fKEB3oZ1vDYrrbvCUp5kJN6yV/3Z TWJsfcIAxklhH14xtjpL6U82CyFJ/WCaPpIwGuG5R+ir5jpi/PtFOc+jJeYs3G2Vr1Pr 3flQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=kaee/WfJcFAdX7pvt6dDMPsct5ZYy4vay1MxBBmNmrY=; b=ljdTnKUdwKhRlY5YLds8Vaegcsec/cnMVGt1WbKtQzhLiHFvaXCl37ZvuS7JLkhZTg CphGreG7jiMb8w3FTKoytitClosvweLmtjIYenLBrRBNIanfh/+cvEtuXzh3VKp6RXhi DzC1c95KYBQsx6gErI1E2QFX7A/PNiQAAEW+5GZ39eWgHMqdByQ9afTZB4xPlKa0xKM7 e1NvYWetrWRJEmZ+0pNV9ZQQLrME5N/hK1B+NWwTb0PHDhgCKa7pAL051LyNYm5eFTd+ nQqgEyXoG5J1EbNYkEiexKyHxsp22Lk99CdlovtpFmLbFmBiCPm1N4fDcUmMC1+WCr8+ v/LQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s184-v6si3309301pgs.492.2018.07.04.07.08.49; Wed, 04 Jul 2018 07:09:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752458AbeGDOIK (ORCPT + 99 others); Wed, 4 Jul 2018 10:08:10 -0400 Received: from foss.arm.com ([217.140.101.70]:37954 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751761AbeGDOIJ (ORCPT ); Wed, 4 Jul 2018 10:08:09 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C3AA018A; Wed, 4 Jul 2018 07:08:08 -0700 (PDT) Received: from red-moon (unknown [10.1.206.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8F9EA3F5A0; Wed, 4 Jul 2018 07:08:06 -0700 (PDT) Date: Wed, 4 Jul 2018 15:09:55 +0100 From: Lorenzo Pieralisi To: Dexuan Cui Cc: 'Bjorn Helgaas' , "'linux-pci@vger.kernel.org'" , KY Srinivasan , Stephen Hemminger , "'olaf@aepfle.de'" , "'apw@canonical.com'" , "'jasowang@redhat.com'" , "'linux-kernel@vger.kernel.org'" , "'driverdev-devel@linuxdriverproject.org'" , Haiyang Zhang , "'vkuznets@redhat.com'" , "'marcelo.cerri@canonical.com'" Subject: Re: [PATCH v2] PCI: hv: Disable/enable irq rather than bh in hv_compose_msi_msg() Message-ID: <20180704140955.GA12863@red-moon> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 01, 2018 at 06:22:23PM +0000, Dexuan Cui wrote: > > Commit de0aa7b2f97d ("PCI: hv: Fix 2 hang issues in hv_compose_msi_msg()") > uses local_bh_disable()/enable(), because hv_pci_onchannelcallback() can > also run in tasklet context as the channel event callback, and here we > want to avoid the race. > > With CONFIG_PROVE_LOCKING=y in the recent mainline, or old kernels that > don't have commit f71b74bca637 ("irq/softirqs: Use lockdep to assert IRQs > are disabled/enabled"), when the upper layer irq code calls > hv_compose_msi_msg() with local irq DISABLED, we'll see a warning at the > beginning of __local_bh_enable_ip(): > > IRQs not enabled as expected > WARNING: CPU: 0 PID: 408 at kernel/softirq.c:162 __local_bh_enable_ip > > The warning exposes an issue in de0aa7b2f97d: local_bh_enable() can > potentially call do_softirq(), which is not supposed to run when local > irq is DISABLED. Let's fix this by using local_irq_save()/restore() > instead. > > Note: hv_pci_onchannelcallback() is not a hot path because it's only > called when the PCI device is hot added and removed, which is infrequent. > > Fixes: de0aa7b2f97d ("PCI: hv: Fix 2 hang issues in hv_compose_msi_msg()") > Signed-off-by: Dexuan Cui > Reviewed-by: Haiyang Zhang > Cc: > Cc: Stephen Hemminger > Cc: K. Y. Srinivasan > --- > > A trimmed version of the warning is: > > IRQs not enabled as expected > WARNING: CPU: 0 PID: 408 at kernel/softirq.c:162 __local_bh_enable_ip+0xb0/0xe0 > Call Trace: > hv_compose_msi_msg+0x209/0x462 [pci_hyperv] > irq_chip_compose_msi_msg+0x41/0x50 > msi_domain_activate+0x1a/0x40 > __irq_domain_activate_irq+0x59/0x90 > irq_domain_activate_irq+0x25/0x40 > __setup_irq+0x3ec/0x730 > request_threaded_irq+0xfa/0x1a0 > mlx4_init_eq_table+0x3c3/0x5f0 [mlx4_core] > mlx4_setup_hca+0x1db/0x750 [mlx4_core] > mlx4_load_one+0xad2/0x13b0 [mlx4_core] > mlx4_init_one+0x578/0x710 [mlx4_core] > local_pci_probe+0x1e/0x50 > work_for_cpu_fn+0x10/0x20 > process_one_work+0x1d4/0x5a0 > worker_thread+0x1cb/0x3d0 > kthread+0xf5/0x130 > > > Changes since v1: > Updated the changelog only (fixed typos and some inaccuracy) > > > drivers/pci/controller/pci-hyperv.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) Applied to pci/controller-fixes, to be tentatively sent for an upcoming -rc, thanks. Lorenzo > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c > index ba1d4b5..eb20296 100644 > --- a/drivers/pci/controller/pci-hyperv.c > +++ b/drivers/pci/controller/pci-hyperv.c > @@ -1073,6 +1073,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) > struct pci_bus *pbus; > struct pci_dev *pdev; > struct cpumask *dest; > + unsigned long flags; > struct compose_comp_ctxt comp; > struct tran_int_desc *int_desc; > struct { > @@ -1164,14 +1165,15 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) > * the channel callback directly when channel->target_cpu is > * the current CPU. When the higher level interrupt code > * calls us with interrupt enabled, let's add the > - * local_bh_disable()/enable() to avoid race. > + * local_irq_save()/restore() to avoid race: > + * hv_pci_onchannelcallback() can also run in tasklet. > */ > - local_bh_disable(); > + local_irq_save(flags); > > if (hbus->hdev->channel->target_cpu == smp_processor_id()) > hv_pci_onchannelcallback(hbus); > > - local_bh_enable(); > + local_irq_restore(flags); > > if (hpdev->state == hv_pcichild_ejecting) { > dev_err_once(&hbus->hdev->device, > -- > 2.7.4 >