Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8980683rwp; Wed, 19 Jul 2023 19:51:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlGKmaNwNhU6eQ6kqni/NZ+VHobyLM/Le1hhCuqoha0K4B0AcD82Kbnw97b7z3Fe+AMh7uT1 X-Received: by 2002:a17:906:8441:b0:99b:4e75:52bb with SMTP id e1-20020a170906844100b0099b4e7552bbmr875470ejy.69.1689821509095; Wed, 19 Jul 2023 19:51:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1689821509; cv=pass; d=google.com; s=arc-20160816; b=GKJkUY+wes1eUo776jT4yBlAK8NfeJ9faN9xWsmCEWarj6zgJReLU0AChMP8sJHBIY z73vvg+UmpDYABHbqpDMpgkMVUr/ch5cADrPMFM0Q3HBPPBJuU5xB56zf0xIeGycE+Ok 6x5KXY5mtIw82kLqXXSXIIQoDeNNaeSSIKgpNh7WkGWtGgoa/BYvRBoo/OOECmrF1m9t b+M4iFZmUYYrKJxweJ6/FE8/yTkw88ZnnfN42/+BDV/d4O1DURZGkSzYcTsOXUDGGoSM MUzkTQeDxXXTRzrM4T/LSu+XVEbFK/yeoc/ZPTWEGPlDWjLAMrUwxlLgF7M3/Xj7YnUm PkAg== 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 :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=PdkzE+vdXZ4zagiBRENQF76KqINoaFG/99bdtqKWRzk=; fh=uCA2/HFLmTOZhgLAVrwzvSzWDLhIwefzvs6ZIaIDh0o=; b=0BPUJ5B+zKvMi5LVUDesLHrRTsJg07TRaVH5U+Bn97ddrB8mJ00O8bZAa6GWj3APPH F3qQe2Qwtor3gTL2DC0+iqKz5AyeZey+LsiHmV3i6wAoGNeipjqKAXrRUTnOXwm31OVB T/U+rU5KbFRciyMahsQO08dhxH+tfvCqeZO+LKCW8e6QSI6W+S5IKXkTxb98+lLeXV/5 gFvPh9av2ULu0AiIhe+10jba2QXq38bzPIqd6ut7xB6gdwZG1ffBUvLGdeFs3bO6VADq xIFDgt2CnvlBbl8Nc1ktHfC/tdq32EvyIJM2VkKVD9lGfJvkUfxotSMRpoAcjJ1h9bRN 6LJA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TyUtATo6; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m12-20020a170906848c00b00982c06b45d9si3673795ejx.816.2023.07.19.19.51.24; Wed, 19 Jul 2023 19:51:49 -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=@intel.com header.s=Intel header.b=TyUtATo6; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229642AbjGTCgY (ORCPT + 99 others); Wed, 19 Jul 2023 22:36:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjGTCgX (ORCPT ); Wed, 19 Jul 2023 22:36:23 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 415DF1FE2; Wed, 19 Jul 2023 19:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689820582; x=1721356582; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=BJmv01zHm8SYwrVVzTaFgqAC6SafLqd9n1YN+pmm25A=; b=TyUtATo6Hw1GicY3uH7EtsddjJUsZ/Gh0ljfhD09degK4vJwQp795kDF WYpz80u9qJt/KRhd2LHjIsuOut6LyS0+UbO+Q6GGRCC6J1e6/yAWkesy5 R4yosCzBAL+kCqOWtWJ/v1Ugi7Wi9hhdwMNYgF8Le72CyTKE1o8Pgq3eh 3QjA9aUx3Xp5VGA2Dt56IZcfRqEeyBrbByOakIGM+jB8wS00UphtqUqhW TzK9oqJo54sphTxm7sngRI0YXftPmHdlskmAz0eGdt3eN7oGYfGcXg6ik R7AhCB19hwvrQaq/MkZrsf0j2sAA0pVZuLcVrdg1+2gWY5qNBprwxf9m6 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="351483113" X-IronPort-AV: E=Sophos;i="6.01,216,1684825200"; d="scan'208";a="351483113" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2023 19:36:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="674528779" X-IronPort-AV: E=Sophos;i="6.01,216,1684825200"; d="scan'208";a="674528779" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga003.jf.intel.com with ESMTP; 19 Jul 2023 19:36:21 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 19 Jul 2023 19:36:21 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Wed, 19 Jul 2023 19:36:21 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.173) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Wed, 19 Jul 2023 19:36:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SuRxQmtefiHNgYaEfF/aoV+NcwumukyTLoz4rMpRhY6pFM8D50qnmT71iqHtDdOIB5rGb0iY8wgD4v34+hsU/VbVYjiL+iIHzaZ+kDKCnlMjZ7rHCjqUUvqIsF3YnSOe90hT+9W39558dF/4mS5oph0ns1uStkx8sfOicEo7lf6OwOLAtkuZU4q9yJqjd9Rf9wy5AhWGtu+ukuSEY1xxtTWf9VEz4OY9i+5WEBVqbRxizDiTg2X5nip2SJdRd7z55emBA+0M1Kz8jAbXRSZvxw3K8nG80qyToXz+MbGQKq7an6oGBsFWANJGgpaWcknvvtg7DpTC0T8DjChAPnfO5Q== 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=PdkzE+vdXZ4zagiBRENQF76KqINoaFG/99bdtqKWRzk=; b=aXOqwFPl90+8rZrG71E410VqdVg+ufX3jfS1jadvTXBdyw4zPY5H9lfY5WUy1U4qllNlzdTh5sRyhYT20km0VWQABSQUrX6/1tMG+Gu0QK0fIyeHLlVck0ILmMmlFC28ufquO5EIBooSuvbTxOdNr8KPLXnj0/VLYc+FF5DdPYgSua29CeZnxrTaS6M6J+DmN5JopNOtLXTzVzfrf75oQNW2a8O13b644wLopng6OP7gytuvV45NNzQJCPSDjVcNraQujjzV0fsRVxVdJGYcfCWLcEEx5dOu7j1Ebskfr4LwWlF7pzLwSSZ0ndv6uS5KJCSSjtx1TqIBdrUSjqthKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from BN9PR11MB5276.namprd11.prod.outlook.com (2603:10b6:408:135::18) by SA1PR11MB6712.namprd11.prod.outlook.com (2603:10b6:806:25c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33; Thu, 20 Jul 2023 02:36:18 +0000 Received: from BN9PR11MB5276.namprd11.prod.outlook.com ([fe80::137b:ec82:a88c:8159]) by BN9PR11MB5276.namprd11.prod.outlook.com ([fe80::137b:ec82:a88c:8159%4]) with mapi id 15.20.6609.024; Thu, 20 Jul 2023 02:36:17 +0000 From: "Tian, Kevin" To: Dmitry Torokhov CC: Paolo Bonzini , Alex Williamson , Greg KH , "Christopherson,, Sean" , "Bradescu, Roxana" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v3 2/2] kvm/vfio: avoid bouncing the mutex when adding and deleting groups Thread-Topic: [PATCH v3 2/2] kvm/vfio: avoid bouncing the mutex when adding and deleting groups Thread-Index: AQHZtqT6WmtjXEfJ/0GeKcImZTi8I6/AlmDwgAAL0ICAAVYmUA== Date: Thu, 20 Jul 2023 02:36:16 +0000 Message-ID: References: <20230714224538.404793-1-dmitry.torokhov@gmail.com> <20230714224538.404793-2-dmitry.torokhov@gmail.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BN9PR11MB5276:EE_|SA1PR11MB6712:EE_ x-ms-office365-filtering-correlation-id: ee566edc-de9a-473d-aeb6-08db88ca17da x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KumYXwd0fTQVU4lwdnR4APkgmYnJ8d2rEypKa9F6KnA8AWfFTmXRXZ2vfHX365syaVuL8+P2zclwYW0ubD19lrkrHTQ1Yl9IQcG5CCtUqwtoT3Do/1yas9iACrCyKeMke6p4841Ky7pyxLCpBMMe9nOtOlVPhvFNPMwvt+iqMwlLvRtnymOLelSWhqP1tTBjrpaNUypoFvmHSMtOqh5KtJwB4821Yby4BtjYF2g7o0b97fHtvlMJCVqwEsDtlJyav7j/rZzosPEZMNkTayJycJmAeCeT0RSZC8fC103r7hGX2fOLGhTxK3ZfFNw1dpFIAnwMuOGY6OSEq7LMSD4lJOWVai3FWz2VCwABdzggh8ZS8RapXP3KTxpGr3bt+JENfvUf3GEHLGLvt10dDEGdDnrTbi/I8KWSOuADSieQxxEUvbltXdIB25gagaRWhsiXXKy+1pWX8dXA1MolN38Ji8akPSt2ktfm3G/k9oGfmNtM3aDhnDwPKJXqJUFPQT9oW0UuvMLDzxnX79fZIHrNlvUr30lyXaeVhTMdKdAt8vtPTE1bTVs95sXBEh4dZhAf9HMGrSCtH39VWpRYhQMzKF9C67qGvf7UmcUow8ILvBulvOJbfMmJV1uBZi80n4E5 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR11MB5276.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(396003)(376002)(366004)(39860400002)(451199021)(64756008)(66556008)(6916009)(66446008)(83380400001)(9686003)(316002)(478600001)(82960400001)(4326008)(7696005)(55016003)(66946007)(54906003)(6506007)(26005)(186003)(76116006)(71200400001)(2906002)(33656002)(38070700005)(86362001)(41300700001)(66476007)(5660300002)(52536014)(38100700002)(122000001)(8676002)(8936002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?+yzhI5NskqEL0X/n/S9C+rwjgDNLN5APOUefTVTw2HJUaVCxLJotIdyjMhDZ?= =?us-ascii?Q?sxMWoQ5ceNlNGRNXmo8MjHb9zvcCzh7axmWkQvFBp5xm0QszdNqRQL2BOxSw?= =?us-ascii?Q?kV13mDl4PGdsDhGRrmR4/5PBZNmVCxtTzTy9JN3jIhFdF0hmKvqdkq+ro7ng?= =?us-ascii?Q?QJwo5EgvU7LG06YNPhb6Z0wp8pRt993+e+XSjtjXuvLve6OmdxiJ35azENuI?= =?us-ascii?Q?ZdwFc7JunyD1AY3xjulvR13XJRtQc2QMbQaf72BzKvgHIuDUaelolZ5JnyPH?= =?us-ascii?Q?MRuvikMZ1Z8MZiCvy7XXJvOtDOyqaMXLmeh4GnreY/St2nz624vGzVj9KOWF?= =?us-ascii?Q?9q4kpPVPlFxOZhzisuefzow/O2LShCWzElcHJ7iRcxnoZ9Yd+/VLVs5dITto?= =?us-ascii?Q?JXBtU3Ca2uQjrw/duug1iPLHlPW3clPWKZsxBygMYwr/lcMTdlu9CLf76Fu7?= =?us-ascii?Q?v3vEAFLvWN5dwL+avwO3NGmHaL3NSE6Rx9srqYEY202WVmw7BsXqFbuajgeI?= =?us-ascii?Q?7RocsJufcRi3aKXoBQgW6s304Quap1VPlgQ9miYc4vngy9LHeUeKpqR7FdC0?= =?us-ascii?Q?57cVYZpyxWQhQYNmAthvIib9H52iJbnHe/nzciSPN+l9nCLF8aA+3uvciDsu?= =?us-ascii?Q?v7G3WW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tlo/rdoKBof?= =?us-ascii?Q?S+FGa9RyIRtG8QW+JOADyoWwkia5EaZ9UaSgV5C8?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5276.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee566edc-de9a-473d-aeb6-08db88ca17da X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jul 2023 02:36:16.7983 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: b4h5EQNrKK8tBQC1NPQj3SmHg3e849Dj+ro0nnbb03yoD2m00o4J2alCL+X337USJSM6hMs4jNZYr5CUXmKQ9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB6712 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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: Dmitry Torokhov > Sent: Wednesday, July 19, 2023 2:11 PM >=20 > On Wed, Jul 19, 2023 at 05:32:27AM +0000, Tian, Kevin wrote: > > > From: Dmitry Torokhov > > > Sent: Saturday, July 15, 2023 6:46 AM > > > > > > @@ -165,30 +161,26 @@ static int kvm_vfio_group_add(struct > kvm_device > > > *dev, unsigned int fd) > > > list_for_each_entry(kvg, &kv->group_list, node) { > > > if (kvg->file =3D=3D filp) { > > > ret =3D -EEXIST; > > > - goto err_unlock; > > > + goto out_unlock; > > > } > > > } > > > > > > kvg =3D kzalloc(sizeof(*kvg), GFP_KERNEL_ACCOUNT); > > > if (!kvg) { > > > ret =3D -ENOMEM; > > > - goto err_unlock; > > > + goto out_unlock; > > > } > > > > > > - kvg->file =3D filp; > > > + kvg->file =3D get_file(filp); > > > > Why is another reference required here? >=20 > Because the function now has a single exit point and the original > reference is dropped unconditionally on exit. It looks cleaner than > checking for non-zero "ret" and deciding whether the reference should be > dropped or kept. >=20 A comment is appreciated. otherwise, Reviewed-by: Kevin Tian