Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752142AbcLFDJv (ORCPT ); Mon, 5 Dec 2016 22:09:51 -0500 Received: from mail-bn3nam01on0134.outbound.protection.outlook.com ([104.47.33.134]:13488 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751972AbcLFDJt (ORCPT ); Mon, 5 Dec 2016 22:09:49 -0500 X-Greylist: delayed 7191 seconds by postgrey-1.27 at vger.kernel.org; Mon, 05 Dec 2016 22:09:49 EST From: Long Li To: Stephen Hemminger CC: KY Srinivasan , Haiyang Zhang , Bjorn Helgaas , "devel@linuxdriverproject.org" , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" Subject: RE: [PATCH] pci-hyperv: use kmalloc to allocate hypercall params buffer Thread-Topic: [PATCH] pci-hyperv: use kmalloc to allocate hypercall params buffer Thread-Index: AQHSOfxEf2ONCoilDUSMYrgmYn91NaD5vAIAgAB93hA= Date: Tue, 6 Dec 2016 00:37:08 +0000 Message-ID: References: <1478642678-31659-1-git-send-email-longli@exchange.microsoft.com> <20161205085240.23f686fc@xeon-e3> In-Reply-To: <20161205085240.23f686fc@xeon-e3> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=longli@microsoft.com; x-originating-ip: [2001:4898:80e8::735] x-ms-office365-filtering-correlation-id: fb950cd7-3e9d-4ee6-de2b-08d41d700284 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN3PR03MB1414; x-microsoft-exchange-diagnostics: 1;BN3PR03MB1414;7:N9qiMM6ABgajmyJKvmVj74ouwe/wJQcoWEoi1j6rMIRuAUuE04cqN3zDLF6kU0ZBzlOpxREUloGZJMn70lY1ORL/CYaIMRtAOrFBqHiv5ug5w3zw/IroAIN1f1c7ZtsmGFAZiMZ8xXZKmzhg1USEUZGEnDANa7y+waMx3M0qJYmO4iSaGNLyNQM7y9vc78tJsJOoLU7Ew32HI6/Nr+METD3Do0I0TSNOtG+unkzeL7nwRZk+x1C/FxZaOP3DvhcnlGXV7FUB/HxUVHScUEXye+rmEv/yuOFl8F/iO0EDrHUuxpmi2OFUrmeF00yLAMcLu3KEov2jKCEmW7kQF31UY0RQc85Hs2YuweVzKP1caAg5GfKLbfEmM3CAoFCk9Q7sZC7IcDmguY6kBGi7tTkIfJNwtwiyF/Cu+HE3YW48JDlEjFG1un3zIVHfsLIR+TFU2RMlWFWkCz+0J45FwQr6FQKAM28ftu9krtof7RCliIg= x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(140211028294663)(211936372134217); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(6042181)(6072148)(6047074);SRVR:BN3PR03MB1414;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1414; x-forefront-prvs: 01480965DA x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(199003)(13464003)(377454003)(24454002)(189002)(3660700001)(7696004)(86362001)(74316002)(77096006)(2906002)(7846002)(3280700002)(9686002)(229853002)(6506006)(76576001)(2900100001)(189998001)(2950100002)(92566002)(10090500001)(38730400001)(6116002)(5660300001)(10290500002)(106356001)(97736004)(110136003)(81166006)(33656002)(101416001)(68736007)(102836003)(86612001)(122556002)(106116001)(8676002)(305945005)(105586002)(6916009)(5005710100001)(7736002)(81156014)(50986999)(54356999)(99286002)(76176999)(4326007)(8936002)(8990500004);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR03MB1414;H:BN3PR03MB2227.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Dec 2016 00:37:08.1246 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1414 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id uB639u01004257 Content-Length: 2216 Lines: 49 > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Monday, December 5, 2016 8:53 AM > To: Long Li > Cc: KY Srinivasan ; Haiyang Zhang > ; Bjorn Helgaas ; > devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; linux- > pci@vger.kernel.org > Subject: Re: [PATCH] pci-hyperv: use kmalloc to allocate hypercall params > buffer > > On Tue, 8 Nov 2016 14:04:38 -0800 > Long Li wrote: > > > + spin_lock_irqsave(&hbus->retarget_msi_interrupt_lock, flags); > > + > > + params = &hbus->retarget_msi_interrupt_params; > > + memset(params, 0, sizeof(*params)); > > + params->partition_id = HV_PARTITION_ID_SELF; > > + params->source = 1; /* MSI(-X) */ > > + params->address = msi_desc->msg.address_lo; > > + params->data = msi_desc->msg.data; > > + params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | > > (hbus->hdev->dev_instance.b[4] << 16) | > > (hbus->hdev->dev_instance.b[7] << 8) | > > (hbus->hdev->dev_instance.b[6] & 0xf8) | > > PCI_FUNC(pdev->devfn); > > - params.vector = cfg->vector; > > + params->vector = cfg->vector; > > > > for_each_cpu_and(cpu, dest, cpu_online_mask) > > - params.vp_mask |= (1ULL << > vmbus_cpu_number_to_vp_number(cpu)); > > + params->vp_mask |= (1ULL << > vmbus_cpu_number_to_vp_number(cpu)); > > + > > + hv_do_hypercall(HVCALL_RETARGET_INTERRUPT, params, NULL); > > > > - hv_do_hypercall(HVCALL_RETARGET_INTERRUPT, ¶ms, NULL); > > + spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags); > > It looks like the additional locking here is being overly paranoid. > The caller is already holding the irq descriptor lock. Look at fixup_irqs. You are right. On my test machine, there are two possible places calling hv_irq_unmask(): request _irq() and handle_edge_irq(). They both have desc->lock held when calling .irq_unmask on the chip. A review of the IRQ code shows that desc->lock is always held while calling chip->irq_unmask(). Since the lock doesn't do any harm and it is not on performance code path, we can remove the lock in the upcoming patches.