From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755295AbdKAUxB (ORCPT ); Wed, 1 Nov 2017 16:53:01 -0400 Received: from mail-dm3nam03on0129.outbound.protection.outlook.com ([104.47.41.129]:6273 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755233AbdKAUw7 (ORCPT ); Wed, 1 Nov 2017 16:52:59 -0400 From: Jake Oshins To: Dexuan Cui , Bjorn Helgaas , "linux-pci@vger.kernel.org" , KY Srinivasan , Stephen Hemminger CC: "devel@linuxdriverproject.org" , "linux-kernel@vger.kernel.org" , Haiyang Zhang , Jork Loeser , "Chris Valean (Cloudbase Solutions SRL)" , "Adrian Suhov (Cloudbase Solutions SRL)" , Simon Xiao , "'Eyal Mizrachi'" , "Jack Morgenstein" , Armen Guezalian , Firas Mahameed , Tziporet Koren , Daniel Jurgens Subject: RE: [PATCH] PCI: hv: use effective affinity mask Thread-Topic: [PATCH] PCI: hv: use effective affinity mask Thread-Index: AdNTSQFbm8/mhC8xRuOwOLkoIvvyZgACkLZA Date: Wed, 1 Nov 2017 20:52:56 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2001:4898:80e8:2::1ad] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR21MB0842;6:mR2gfFuj5SHYKN+cT0TEPeSlkSj8qJ4pDy5HqIU3XLtxvVIO6Z3/bIDz8oWA7jm3W3Wt5LHqRdmzNVYEW5W2ei2uAORgAKufD1TGrW7V1FZhCXS35EsiFIzlAm6FV7MYSSsq4HmyyxJsVUUjo177LBl0fRUcKfQWO4QALqdaa6QbHAfE1hf78ZyK3m9ssjMakgF9H3UgDwkGf/mu9wmPaxO3kx9JprvLtA7knvLcDtwEHL58rxXdo7k4EVcrWk3p4rjVP2S5rJMKyNWP5IoClfhLWsM8iuagUJa7ej3FUq6LYwbBpvTtOvElxdHxKpAO4040r4vTYdUGJ9f5bQu+oowh63zqlU8Tq2BeLeTzAxg=;5:oSHNSu0383ba5CPnu1YVRZHLhbGztvA3Pm8LBdCrV0Bo/VBU9pAznOQ/3Q7YNjO4dr169M+iWqw7tqpG/allJM8+Vp2PuI1eKXy4Q46NF9+z42hIspR4QJIvDJSKmSfW7zZKtS9br3HsQrzpQmikvQSgfQzpLNMK0X6bUk7sG3c=;24:Q2HoLd3IJw26VNnc4SMlvNQLEC6z4bRXmcxwsNfwHtC371m+bt30nUTKD48Ok8OWFB9YfUJ2q287yraKcIUuouQAH9w2ziNKKP3yv5/4N8I=;7:SDlc4NGqlp3vHk2M+kAxRkwxNFwqjSy/dZeQlctPtVvDWN9JSXG2jqqNhpF+lX6AI5wY08ejvGenAX44oESxTsO5CIbSY58UsihQlJC++wTP/PDbkEXB5Zl+yErUQxhzCQEpeDXwAcsz8jPqH48GmJOB5mzmveTecEv2FQ0kBGmmndMYu00SNGg2EuXg8dUgsmjm8TOOUVArJQjtGuicw394vz5MIN8jlzbsSfFBRNPTAxQLwtTY0ajCdb8g2h/2 x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: fc2adb60-71ba-4d42-ee47-08d5216a87de x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(4534020)(4602075)(2017052603238);SRVR:DM5PR21MB0842; x-ms-traffictypediagnostic: DM5PR21MB0842: x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-exchange-antispam-report-test: UriScan:(89211679590171)(9452136761055)(211936372134217)(153496737603132); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(61425038)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(3231020)(920507026)(6055026)(61426038)(61427038)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123560025)(20161123562025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR21MB0842;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR21MB0842; x-forefront-prvs: 0478C23FE0 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(376002)(346002)(47760400005)(199003)(13464003)(189002)(2906002)(2900100001)(7736002)(8990500004)(2950100002)(6636002)(68736007)(25786009)(3280700002)(7696004)(3660700001)(1511001)(5660300001)(10090500001)(99286004)(2421001)(10290500003)(97736004)(53546010)(6246003)(7416002)(86612001)(2501003)(8936002)(478600001)(86362001)(189998001)(81166006)(110136005)(105586002)(54356999)(74316002)(2561002)(34040400001)(316002)(33656002)(55016002)(106356001)(54906003)(305945005)(50986999)(22452003)(9686003)(102836003)(14454004)(8676002)(81156014)(229853002)(53936002)(4326008)(77096006)(101416001)(6116002)(76176999)(6506006)(6436002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR21MB0842;H:DM5PR21MB0122.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; authentication-results: spf=none (sender IP is ) smtp.mailfrom=jakeo@microsoft.com; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc2adb60-71ba-4d42-ee47-08d5216a87de X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2017 20:52:57.0858 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR21MB0842 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 nfs id vA1Ks3LH031646 > -----Original Message----- > From: Dexuan Cui > Sent: Wednesday, November 1, 2017 1:31 PM > To: Bjorn Helgaas ; linux-pci@vger.kernel.org; Jake > Oshins ; KY Srinivasan ; > Stephen Hemminger > Cc: devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; Haiyang > Zhang ; Jork Loeser > ; Chris Valean (Cloudbase Solutions SRL) chvale@microsoft.com>; Adrian Suhov (Cloudbase Solutions SRL) adsuho@microsoft.com>; Simon Xiao ; 'Eyal > Mizrachi' ; Jack Morgenstein > ; Armen Guezalian ; Firas > Mahameed ; Tziporet Koren > ; Daniel Jurgens > Subject: [PATCH] PCI: hv: use effective affinity mask > > > The effective_affinity_mask is always set when an interrupt is assigned in > __assign_irq_vector() -> apic->cpu_mask_to_apicid(), e.g. for struct apic > apic_physflat: -> default_cpu_mask_to_apicid() -> > irq_data_update_effective_affinity(), but it looks d->common->affinity > remains all-1's before the user space or the kernel changes it later. > > In the early allocation/initialization phase of an irq, we should use the > effective_affinity_mask, otherwise Hyper-V may not deliver the interrupt to > the expected cpu. Without the patch, if we assign 7 Mellanox ConnectX-3 > VFs to a 32-vCPU VM, one of the VFs may fail to receive interrupts. > > Signed-off-by: Dexuan Cui > Cc: Jake Oshins > Cc: Jork Loeser > Cc: Stephen Hemminger > Cc: K. Y. Srinivasan > --- > > Please consider this for v4.14, if it's not too late. > > drivers/pci/host/pci-hyperv.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c > index 5ccb47d..8b5f66d 100644 > --- a/drivers/pci/host/pci-hyperv.c > +++ b/drivers/pci/host/pci-hyperv.c > @@ -879,7 +879,7 @@ static void hv_irq_unmask(struct irq_data *data) > int cpu; > u64 res; > > - dest = irq_data_get_affinity_mask(data); > + dest = irq_data_get_effective_affinity_mask(data); > pdev = msi_desc_to_pci_dev(msi_desc); > pbus = pdev->bus; > hbus = container_of(pbus->sysdata, struct hv_pcibus_device, > sysdata); @@ -1042,6 +1042,7 @@ static void hv_compose_msi_msg(struct > irq_data *data, struct msi_msg *msg) > struct hv_pci_dev *hpdev; > struct pci_bus *pbus; > struct pci_dev *pdev; > + struct cpumask *dest; > struct compose_comp_ctxt comp; > struct tran_int_desc *int_desc; > struct { > @@ -1056,6 +1057,7 @@ static void hv_compose_msi_msg(struct irq_data > *data, struct msi_msg *msg) > int ret; > > pdev = msi_desc_to_pci_dev(irq_data_get_msi_desc(data)); > + dest = irq_data_get_effective_affinity_mask(data); > pbus = pdev->bus; > hbus = container_of(pbus->sysdata, struct hv_pcibus_device, > sysdata); > hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); > @@ -1081,14 +1083,14 @@ static void hv_compose_msi_msg(struct irq_data > *data, struct msi_msg *msg) > switch (pci_protocol_version) { > case PCI_PROTOCOL_VERSION_1_1: > size = hv_compose_msi_req_v1(&ctxt.int_pkts.v1, > - irq_data_get_affinity_mask(data), > + dest, > hpdev->desc.win_slot.slot, > cfg->vector); > break; > > case PCI_PROTOCOL_VERSION_1_2: > size = hv_compose_msi_req_v2(&ctxt.int_pkts.v2, > - irq_data_get_affinity_mask(data), > + dest, > hpdev->desc.win_slot.slot, > cfg->vector); > break; > -- > 2.7.4 Signed-off-by: Jake Oshins From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-dm3nam03on0129.outbound.protection.outlook.com ([104.47.41.129]:6273 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755233AbdKAUw7 (ORCPT ); Wed, 1 Nov 2017 16:52:59 -0400 From: Jake Oshins To: Dexuan Cui , Bjorn Helgaas , "linux-pci@vger.kernel.org" , KY Srinivasan , Stephen Hemminger CC: "devel@linuxdriverproject.org" , "linux-kernel@vger.kernel.org" , Haiyang Zhang , Jork Loeser , "Chris Valean (Cloudbase Solutions SRL)" , "Adrian Suhov (Cloudbase Solutions SRL)" , Simon Xiao , 'Eyal Mizrachi' , "Jack Morgenstein" , Armen Guezalian , Firas Mahameed , Tziporet Koren , Daniel Jurgens Subject: RE: [PATCH] PCI: hv: use effective affinity mask Date: Wed, 1 Nov 2017 20:52:56 +0000 Message-ID: References: In-Reply-To: Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org List-ID: > -----Original Message----- > From: Dexuan Cui > Sent: Wednesday, November 1, 2017 1:31 PM > To: Bjorn Helgaas ; linux-pci@vger.kernel.org; Jake > Oshins ; KY Srinivasan ; > Stephen Hemminger > Cc: devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; Haiyang > Zhang ; Jork Loeser > ; Chris Valean (Cloudbase Solutions SRL) chvale@microsoft.com>; Adrian Suhov (Cloudbase Solutions SRL) adsuho@microsoft.com>; Simon Xiao ; 'Eyal > Mizrachi' ; Jack Morgenstein > ; Armen Guezalian ; Firas > Mahameed ; Tziporet Koren > ; Daniel Jurgens > Subject: [PATCH] PCI: hv: use effective affinity mask >=20 >=20 > The effective_affinity_mask is always set when an interrupt is assigned i= n > __assign_irq_vector() -> apic->cpu_mask_to_apicid(), e.g. for struct apic > apic_physflat: -> default_cpu_mask_to_apicid() -> > irq_data_update_effective_affinity(), but it looks d->common->affinity > remains all-1's before the user space or the kernel changes it later. >=20 > In the early allocation/initialization phase of an irq, we should use the > effective_affinity_mask, otherwise Hyper-V may not deliver the interrupt = to > the expected cpu. Without the patch, if we assign 7 Mellanox ConnectX-3 > VFs to a 32-vCPU VM, one of the VFs may fail to receive interrupts. >=20 > Signed-off-by: Dexuan Cui > Cc: Jake Oshins > Cc: Jork Loeser > Cc: Stephen Hemminger > Cc: K. Y. Srinivasan > --- >=20 > Please consider this for v4.14, if it's not too late. >=20 > drivers/pci/host/pci-hyperv.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.= c > index 5ccb47d..8b5f66d 100644 > --- a/drivers/pci/host/pci-hyperv.c > +++ b/drivers/pci/host/pci-hyperv.c > @@ -879,7 +879,7 @@ static void hv_irq_unmask(struct irq_data *data) > int cpu; > u64 res; >=20 > - dest =3D irq_data_get_affinity_mask(data); > + dest =3D irq_data_get_effective_affinity_mask(data); > pdev =3D msi_desc_to_pci_dev(msi_desc); > pbus =3D pdev->bus; > hbus =3D container_of(pbus->sysdata, struct hv_pcibus_device, > sysdata); @@ -1042,6 +1042,7 @@ static void hv_compose_msi_msg(struct > irq_data *data, struct msi_msg *msg) > struct hv_pci_dev *hpdev; > struct pci_bus *pbus; > struct pci_dev *pdev; > + struct cpumask *dest; > struct compose_comp_ctxt comp; > struct tran_int_desc *int_desc; > struct { > @@ -1056,6 +1057,7 @@ static void hv_compose_msi_msg(struct irq_data > *data, struct msi_msg *msg) > int ret; >=20 > pdev =3D msi_desc_to_pci_dev(irq_data_get_msi_desc(data)); > + dest =3D irq_data_get_effective_affinity_mask(data); > pbus =3D pdev->bus; > hbus =3D container_of(pbus->sysdata, struct hv_pcibus_device, > sysdata); > hpdev =3D get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); > @@ -1081,14 +1083,14 @@ static void hv_compose_msi_msg(struct irq_data > *data, struct msi_msg *msg) > switch (pci_protocol_version) { > case PCI_PROTOCOL_VERSION_1_1: > size =3D hv_compose_msi_req_v1(&ctxt.int_pkts.v1, > - irq_data_get_affinity_mask(data), > + dest, > hpdev->desc.win_slot.slot, > cfg->vector); > break; >=20 > case PCI_PROTOCOL_VERSION_1_2: > size =3D hv_compose_msi_req_v2(&ctxt.int_pkts.v2, > - irq_data_get_affinity_mask(data), > + dest, > hpdev->desc.win_slot.slot, > cfg->vector); > break; > -- > 2.7.4 Signed-off-by: Jake Oshins