Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756084AbbLCRHT (ORCPT ); Thu, 3 Dec 2015 12:07:19 -0500 Received: from mail-by2on0143.outbound.protection.outlook.com ([207.46.100.143]:41268 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753212AbbLCRHQ convert rfc822-to-8bit (ORCPT ); Thu, 3 Dec 2015 12:07:16 -0500 From: Jake Oshins To: Jiang Liu , "gregkh@linuxfoundation.org" , KY Srinivasan , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "vkuznets@redhat.com" , "tglx@redhat.com" , Haiyang Zhang , "marc.zyngier@arm.com" , "bhelgaas@google.com" , "linux-pci@vger.kernel.org" Subject: RE: [PATCH v6 7/7] PCI: hv: New paravirtual PCI front-end for Hyper-V VMs Thread-Topic: [PATCH v6 7/7] PCI: hv: New paravirtual PCI front-end for Hyper-V VMs Thread-Index: AQHRFbYjmHGCp0lJxUaOMJLWfNsnXZ64xUaAgADosjA= Date: Thu, 3 Dec 2015 17:07:14 +0000 Message-ID: References: <1446499996-1350-1-git-send-email-jakeo@microsoft.com> <1446499996-1350-8-git-send-email-jakeo@microsoft.com> <565FB2F5.6050504@linux.intel.com> In-Reply-To: <565FB2F5.6050504@linux.intel.com> 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=jakeo@microsoft.com; x-originating-ip: [2001:4898:80e8:8::349] x-microsoft-exchange-diagnostics: 1;DM2PR0301MB0781;5:5ePk3v7TKZy6Wwspxq8w9/kUyDfXM8+T8DMSxPPvf6V92NCwZTKoNc6vp5/tyU1M7ON56SmbRfs6xoIK5CdtczhFkg9OwYuKzXi5bkjR34qxxkpRPmkPh5Pwiwm77vrEl8Vd4gAxfYtsatoAYCjY6w==;24:ur463Ijx90B8B61I+5rr7uR763Bj+bqsW8HQRTwtEetE2298hpV9Y0dziKwXmQG5DtLJitMDgwfWZ3tO/q9PEcHYrJws59Q/8SJrjFw7hQw= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0781; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(211936372134217)(108003899814671)(180628864354917)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001)(61426038)(61427038);SRVR:DM2PR0301MB0781;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0781; x-forefront-prvs: 077929D941 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(199003)(377454003)(479174004)(24454002)(189002)(13464003)(76176999)(50986999)(5002640100001)(1096002)(19580395003)(586003)(19580405001)(81156007)(1220700001)(2950100001)(97736004)(6116002)(10090500001)(189998001)(2900100001)(5001770100001)(5004730100002)(102836003)(74316001)(77096005)(5001960100002)(107886002)(54356999)(40100003)(92566002)(1511001)(99286002)(10400500002)(105586002)(5003600100002)(2201001)(106116001)(122556002)(86612001)(2501003)(106356001)(101416001)(8990500004)(2561002)(11100500001)(10290500002)(5008740100001)(86362001)(2421001)(87936001)(76576001)(5005710100001)(33656002)(921003)(3826002)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0301MB0781;H:DM2PR0301MB1232.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Dec 2015 17:07:14.1868 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0781 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3126 Lines: 76 > -----Original Message----- > From: Jiang Liu [mailto:jiang.liu@linux.intel.com] > Sent: Wednesday, December 2, 2015 7:12 PM > To: Jake Oshins ; gregkh@linuxfoundation.org; KY > Srinivasan ; linux-kernel@vger.kernel.org; > devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com; > vkuznets@redhat.com; tglx@redhat.com; Haiyang Zhang > ; marc.zyngier@arm.com; > bhelgaas@google.com; linux-pci@vger.kernel.org > Subject: Re: [PATCH v6 7/7] PCI: hv: New paravirtual PCI front-end for Hyper- > V VMs > > On 2015/11/3 5:33, jakeo@microsoft.com wrote: > > From: Jake Oshins > > [...] > > + > > +/** > > + * hv_irq_unmask() - "Unmask" the IRQ by setting its current > > + * affinity. > > + * @data: Describes the IRQ > > + * > > + * Build new a destination for the MSI and make a hypercall to > > + * update the Interrupt Redirection Table. "Device Logical ID" > > + * is built out of this PCI bus's instance GUID and the function > > + * number of the device. > > + */ > > +void hv_irq_unmask(struct irq_data *data) > > +{ > > + struct msi_desc *msi_desc = irq_data_get_msi_desc(data); > > + struct irq_cfg *cfg = irqd_cfg(data); > > + struct retarget_msi_interrupt params; > > + struct hv_pcibus_device *hbus; > > + struct cpumask *dest; > > + struct pci_bus *pbus; > > + struct pci_dev *pdev; > > + int cpu; > > + > > + dest = irq_data_get_affinity_mask(data); > > + pdev = msi_desc_to_pci_dev(msi_desc); > > + pbus = pdev->bus; > > + hbus = container_of(pbus->sysdata, struct hv_pcibus_device, > sysdata); > > + > > + memset(¶ms, 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; > > + > > + for_each_cpu_and(cpu, dest, cpu_online_mask) > > + params.vp_mask |= (1 << > vmbus_cpu_number_to_vp_number(cpu)); > No knowledge about the HV implementation details, but feel some chances > of race here between hv_irq_unmask(), hv_set_affinity() and > cpu_up()/cpu_down() when accessing 'dest' and cpu_online_mask. > Thanks. Is there any architectural contract here? I tried implementing this by doing this work in the set_affinity() callback, but the vector was often wrong when that callback was invoked. (It seems to get changed just after set_affinity().) Can you suggest a durable strategy? I'll respond to all the other comments you sent (and this one, once I understand the right response) and resend. Thanks for your review, Jake Oshins -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/