Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp993243rwi; Thu, 27 Oct 2022 09:50:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7IXnlYonZEiwvtKn4SmO+inzHLL7jHEmHh8aqT5C7bwGdNw8naAyLqXkRlahFPaqW8gNY1 X-Received: by 2002:a50:fe99:0:b0:45c:329a:40f6 with SMTP id d25-20020a50fe99000000b0045c329a40f6mr46619370edt.425.1666889453117; Thu, 27 Oct 2022 09:50:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666889453; cv=pass; d=google.com; s=arc-20160816; b=v7KY2Z4PzZfh6Bl2vzI7oR7icAa0lCy9JGWZQT28zCIpMzk14AH/JhBZ9LBafUHx8g hqfeAGwOa9/YqdOVkFijojzlVK3yLeVkLyHABRvU2RDiFS3XIXxpht2z4+uJ4898PSWi Qr/1cb/jfk+XO9r0sl3msRHxyuu4iRHgN6ixhVRghnyc707ItfB5CbFQmDVppDtaBWH2 75djWyGTODiLhwRUjG7I0hFEsqIwplI9IC0S7FWXbjWkNDxJeRrW3T49FFG26rGCPg62 GcZtiVT7G8qlFZlBrGUsCWw1Ck1xWeqEh9VrhFVdo4YLosdpdRnnrD09R2a/iDR3dEuj OAoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :msip_labels:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:to:from :dkim-signature; bh=u0j6HheXjPjnSuH+TV1OrRcMqCBRr4+Q5CdTL2s1jOQ=; b=sJKT5s9ApJg1eZc8p7LisdbY77+2oCxMI5X1PjeON+t+bl1XVq78nhx+AFj3M6jDpq BITVf6tV2dxWyI5NKTQ+rowQwvDkR+xoR9oz4Cf9U95EXMJ/5fJGAzRzJ+33wgBxEK7q BQ8CNho/YwMCQsHsbajq7ESKKayVSkPx1KmlXjBI97VB4eoTyfMuwfbMwRk1AViU1jDB vYFjhOP57IA1dxWfDaXkVoiz2UAkZIwwk5UR5fvLc3E87pC1k7MwLiziG6cXTTzfOSFm at75PjRGs1EpsSp5b/t0u2X24eMc3cwxYtITAnzbsgVqnQm8/86ZNiNu8qOgHebISqEO 3Ang== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b="elsJWIT/"; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f25-20020a05640214d900b004549b880c67si1761951edx.42.2022.10.27.09.50.28; Thu, 27 Oct 2022 09:50:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b="elsJWIT/"; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236550AbiJ0QYo (ORCPT + 99 others); Thu, 27 Oct 2022 12:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236415AbiJ0QY0 (ORCPT ); Thu, 27 Oct 2022 12:24:26 -0400 Received: from na01-obe.outbound.protection.outlook.com (mail-eastusazon11020023.outbound.protection.outlook.com [52.101.51.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F1A913F0F; Thu, 27 Oct 2022 09:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YFE3KyqrVwnQ2lSvhXQ4Rq/NScFBWc9bAsNu8Y9Xf+loaSzBtXBve9B2xKlk67g/rgu27wtAbyeCee22vQJ1DmlTf1on6LI2SBaKdWc+KRJBoq7PaCt++QscIEP9q7MGply6R9BC7Ic0Dddoyph5Od85FtK2LPHaGa4KCMJGuoLOOLJoPVXmu7GKOzqwFhYgGbAz9D4SwWSymvbOzZSNkkuuMHhY5gkl08U0QMpwSQELYkduHqOghTrGJ4ZeiNmLpB2l8vxktWixYSV+M+LVVE3K00tyVvO/QL7HEjRAX26Bs/OesC/KIXwHehRNSWDXkZ3gJxfgvaFY+XMyW+gVAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=u0j6HheXjPjnSuH+TV1OrRcMqCBRr4+Q5CdTL2s1jOQ=; b=nNdUUCINAOVrNzm16kRSzhUXx9yOkjp1/2QA2+Xrj6/FzjLyfWML9XUbfp1InfL4LX7vq0nQalC8Sq9ovlGlsP6s6z7K+jdWCcsydbZXRIYT1+FiBodbp8fyk/108e1NdYQmnoGH8D38xIb5YtFuzjWHfSVnACKmh9db52SbQE+6qp2nYpefadixNDebsC/AVVu4VIfgQ5yKB+wJny/kYNX5mhItcMXIfaWr5B1CM/g2zbjEC+jrdVI8ka5W+OqZSUkxMb7lE8yVoFXrS7TF2cWWzIcofGsDSqEQZ4VMowZpznW0lzo/g4pljok66KDpuEsxcsJJ7Bh0xPbvNZYO6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u0j6HheXjPjnSuH+TV1OrRcMqCBRr4+Q5CdTL2s1jOQ=; b=elsJWIT/vXJ3yRk92A1G63HGEY2vDO9cn2Zx4EiPupyNTBVERun4RnDwJkmPyn9KslzssStjjPxI3ziL7ZWlnADZeErxavvRZzpo2IUDw9oGLYJiZhYz9hUwRiD3BqahzXCM8b/nqw76dMCdUp+taqM1RMdHZVVMxeZCDSTmWU0= Received: from SA1PR21MB1335.namprd21.prod.outlook.com (2603:10b6:806:1f2::11) by DM4PR21MB3248.namprd21.prod.outlook.com (2603:10b6:8:68::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.9; Thu, 27 Oct 2022 16:22:53 +0000 Received: from SA1PR21MB1335.namprd21.prod.outlook.com ([fe80::600e:e49e:869e:4c2f]) by SA1PR21MB1335.namprd21.prod.outlook.com ([fe80::600e:e49e:869e:4c2f%5]) with mapi id 15.20.5791.008; Thu, 27 Oct 2022 16:22:53 +0000 From: Dexuan Cui To: "Michael Kelley (LINUX)" , "quic_jhugo@quicinc.com" , "quic_carlv@quicinc.com" , "wei.liu@kernel.org" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , "lpieralisi@kernel.org" , "bhelgaas@google.com" , "linux-hyperv@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "robh@kernel.org" , "kw@linux.com" , "helgaas@kernel.org" , "alex.williamson@redhat.com" , "boqun.feng@gmail.com" , Boqun Feng Subject: RE: [PATCH v2] PCI: hv: Only reuse existing IRTE allocation for Multi-MSI Thread-Topic: [PATCH v2] PCI: hv: Only reuse existing IRTE allocation for Multi-MSI Thread-Index: AQHY6AEkY2TDPPxGMUaLzNKIsTJo9a4faSzAgACBzzA= Date: Thu, 27 Oct 2022 16:22:53 +0000 Message-ID: References: <20221024233342.22758-1-decui@microsoft.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=5d66bf82-f0a4-4933-b4a0-1e42373af77b;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2022-10-25T18:07:06Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR21MB1335:EE_|DM4PR21MB3248:EE_ x-ms-office365-filtering-correlation-id: 6bfc4a62-8f00-4b61-dcf5-08dab8377ffc x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pi++Ln9Klsz6o21y/ftFXPfqAa2FvxtjabIF5BD0+qMVHnAIonL6gJAWHn23p6+ak0RS0qyx0bMf30kgjp7PhLl2O9zDAR2KFuVMR9uuw4/XG9XYpsYi3adCMoZrN+eScLwTj3adHHiioBo1FDf42TUmGDxuaQ0SsXgCi7vXXZ5EAwHLR6bMUp0Oe5Tjcds8aH5YzXa4Lf3qsw7e5VBA7+xH+nwMCZ06f9BhSipzrU7cv6vdodQZWjoQtUdseOHCyVOzMdkEQ11B/AIe7veai52jxLrncUz6i+sKZlyVa0NbUI2xanrtKeKFn445GqP+lOGhS7rSBmSsJMHk864owskazHNCzpibfM4b5j+BlEFaODFeOgiD4kJO3hl5BSbg+z2o5Ff0peinGHyoHKDqf2ZxjA59H5hqTSwMyHIoCBOE472isGzm270gdBGWAmOWoga6EtpqN1iwODzG38xWnfOjCo2oL3pkZ7xJZOpYvS7bSeNWGespMQiaK/SFrMfZiC0okfaFt/Bu9sE2Xt16AL3Q0hlqBrHawkEhnvFUbI700grvuZ6FDP+4ret3eE3EPRkvdpCwJ2pz4Ffcgw0ngLBU1l2j/5xImnsBNBdTEiYQ74UMcXAJUn9yHNLet9Iv9peySwjAjzSmT+ZL6tNF02YnwJIXeqai5mTAUmjCbw4zOoGLkbw9W6eRzZ/a/FCGyCojlDYNCSSdVSIjYGmuoFOp6YVeHiaYJj7Da17L9+LVjrvmQctN+fuw+rWF87WhDFaEFipIOWvY88xHTgFu8XfF5VcHElNRI4HITUDGrjuQkN/1xgRHaTqC6IJSlB9JCUb9S3Gr0syRgAzAwAc+uQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR21MB1335.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(366004)(346002)(136003)(376002)(451199015)(66556008)(66476007)(6506007)(7696005)(66446008)(8676002)(66946007)(33656002)(64756008)(76116006)(110136005)(6636002)(82950400001)(316002)(10290500003)(83380400001)(82960400001)(8990500004)(38100700002)(921005)(122000001)(8936002)(52536014)(26005)(55016003)(5660300002)(9686003)(86362001)(41300700001)(2906002)(38070700005)(7416002)(186003)(71200400001)(478600001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?5v2XiQj1J/QRUo5fWOAkQP1OHiyKREmThiSo6388dymcTPxDO/ipVLLUHMBI?=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omEMogrZsaXrIN3F?= =?us-ascii?Q?oKa3IHXQqL0OZQuY63KaZ8iZyeDWSMVb4jRNO53wZIsDnCv1Dlh64RRJ3nl9?= =?us-ascii?Q?5FjrkvCiaPvpM4ekDLALRFcl/zZRsKXypc6z1kyY3ccyFX4Ta5ymQ0dlA+uf?= =?us-ascii?Q?EMmo5q+xGsJXm0jHtOnESlz5ClXsSctMaPluH2qsp85Q74aVK4VSh+MiJUgw?= =?us-ascii?Q?Jov3d30PYskSR4tM4obSHIXKaya4/iJ70zQaUaQ6dUfCI/8SsvyfqIuwV3ws?= =?us-ascii?Q?AItHunEHr2Xhq1afSFC50uHGahU4rcoM9SuhfKNJMYYe2WwOAX6T5qXLCfvT?= =?us-ascii?Q?0o3wb5OciGBnfdVqVOs2kh/Ej+hmcpeCjOpwN6R/6Qp783wnjGnY/LX56zeV?= =?us-ascii?Q?vc2xZ3J8xpqV50hFm2G9Mhi+QmY95xjlzMy+aU15bH/064J6BfN0PXpoplg8?= =?us-ascii?Q?Rq5gOAttdBhyQt1L9+6VS3lnXOgxhEZoeWeChpJOaK1THyyThj+GX92Qhltc?= =?us-ascii?Q?/IJC/Y8UOnRvtFtQWUXHZRdU3xptC7XXk6EpWLlwpFM1Eyaqnq0e4gAKzVho?= =?us-ascii?Q?H9Br2Ziz0WkavbkahaDHt6oBtf7pBQ4Mvhk+KDfQT/1tds4EvxZ3mXHUe/Cr?= =?us-ascii?Q?WIlnmooXAyUjhDQUzyO/5Q75zUF4aYDwwkiIU9iu?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR21MB1335.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bfc4a62-8f00-4b61-dcf5-08dab8377ffc X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Oct 2022 16:22:53.5868 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: cYakQAur7XeDMl5N2SLP+ukHtGl14HGOh9BfowZH9Jw0cDWtrVZRO7lGVHa1jKHpbc1vxMlfeVIQrU12cRBK3w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR21MB3248 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Michael Kelley (LINUX) > Sent: Tuesday, October 25, 2022 11:18 AM > > ... > > -static u32 hv_compose_msi_req_v2( > > - struct pci_create_interrupt2 *int_pkt, const struct cpumask *affinity= , > > - u32 slot, u8 vector, u8 vector_count) > > +/* > > + * Make sure the dummy vCPU values for multi-MSI don't all point to vC= PU0. > > + */ > > +static int hv_compose_multi_msi_req_get_cpu(void) > > { > > + static DEFINE_SPINLOCK(multi_msi_cpu_lock); > > + > > + /* -1 means starting with CPU 0 */ > > + static int cpu_next =3D -1; > > + > > + unsigned long flags; > > int cpu; > > > > + spin_lock_irqsave(&multi_msi_cpu_lock, flags); > > + > > + cpu_next =3D cpumask_next_wrap(cpu_next, cpu_online_mask, > nr_cpu_ids, > > + false); >=20 > I have a modest concern about using cpu_online_mask. The CPUs in this > mask > can change if a CPU is taken online or offline in Linux. I don't think th= ere's > a requirement to pick on an online CPU, especially since if we pick a CPU= that's > online now, it might not be online later. Using cpu_present_mask would b= e > more correct. That's the CPUs that are present in the VM, which won't > change > over time since Hyper-V doesn't hot-add or hot-remove CPUs in a VM. >=20 > A similar concern applies to hv_compose_msi_req_get_cpu(). >=20 > Michael Here cpu_online_mask is better than cpu_present_mask. It doesn't matter an online target CPU becomes offline later, because when the CPU is brought offline, the kernel should automatically migrate the interrupt to a different online CPU. hv_compose_multi_msi_req_get_cpu() is called when a PCI devic driver's .probe() function is called, and the .probe() is called from the context of pci_call_probe(), where CPU hotplug is temporarily disabled/enabled, so here cpu_online_mask should not be an issue. Thanks, Dexuan