Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp158359iof; Wed, 8 Jun 2022 18:04:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv+bXV1JwdoKCkGJnxbDyES1W33+eCLAGC8A7dXuBdJsVimjAH/VDB7Yu8S50jyQJag1eD X-Received: by 2002:a05:6402:c1:b0:42a:b8a5:8d5e with SMTP id i1-20020a05640200c100b0042ab8a58d5emr42517252edu.266.1654736654966; Wed, 08 Jun 2022 18:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654736654; cv=none; d=google.com; s=arc-20160816; b=fkcusYOfSaYMHOj9imkbjElboU8JK+62k/A2hxwu4ce91O36Nqe6zMy00g+XTBvzke StuNDTCKah70tpgv5ZY+L41UHivCsXPRpIDFA3KDnoWF/WCoGF1gR7gtxTrAq25Xv8DP XM0bG+S3qvAs0kaBRMWlCIA7y0pRuYfVTQf1AVdbqSU5tt7qL5XXFOfHxpyFbh/CqDdQ AB0asluvrtrukOzasEgbyoewa022O4YBHBzh7MPVDibs2w2ziekJ7PE8Qp+NVGG1R9+h unWX1F33yjLZGyi5Un95xdbo4Fd9kv0FlS0vRbLjjI6zq3DVlm3wi+GlmYbJlVP6kC5D JnKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:abuse-reports-to:tuid:mime-version :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=KqUVYz6Dighc0uWw2neIgC2Pkaci9QEPldkMQ9q6iiA=; b=Tc+DL7cXk2RuvNroeiDcaHYF0KOKS0sVTqfcljbxSXyai+OS/fTZ2tEuJndbJ4rrz4 k9Q6diPSnjN39DPDczbTbFBeOu9q/WEL7NbNnbMgzeNSDzW7YKmko89Kp/3gmZ1hm674 I+P6v9UQfhwCC0vjEcBE5Bn6xPwmRK+qEXV2fi4L1s32Jby/OQ6dJepOv9M9Q6DFVOLY GXSWgfaQU1TprhoPhPJ2w2IvAZD+VLxi0i10Fikr5cWiZSxAdUB3FH3KPOEoF5hvlhok RQtqMgbvY1Cj/BW8kG0U2RKaWobZBYwpQBOMBHddNv5grEeK5atwziYKt8Koc/URN0xg 5rfA== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a17090674d000b00711f55a31c9si3585702ejl.675.2022.06.08.18.03.48; Wed, 08 Jun 2022 18:04:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235306AbiFIAoY (ORCPT + 99 others); Wed, 8 Jun 2022 20:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbiFIAoW (ORCPT ); Wed, 8 Jun 2022 20:44:22 -0400 X-Greylist: delayed 122 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 08 Jun 2022 17:44:18 PDT Received: from unicom145.biz-email.net (unicom145.biz-email.net [210.51.26.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97275D571C; Wed, 8 Jun 2022 17:44:18 -0700 (PDT) Received: from ([60.208.111.195]) by unicom145.biz-email.net ((D)) with ASMTP (SSL) id DWZ00012; Thu, 09 Jun 2022 08:42:12 +0800 Received: from jtjnmail201620.home.langchao.com (10.100.2.20) by jtjnmail201624.home.langchao.com (10.100.2.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 9 Jun 2022 08:42:11 +0800 Received: from jtjnmail201620.home.langchao.com ([fe80::24f6:b8e5:a824:6a6b]) by jtjnmail201620.home.langchao.com ([fe80::24f6:b8e5:a824:6a6b%9]) with mapi id 15.01.2308.027; Thu, 9 Jun 2022 08:42:11 +0800 From: =?utf-8?B?dG9tb3Jyb3cgV2FuZyAo546L5b635piOKQ==?= To: "christophe.jaillet@wanadoo.fr" , "mst@redhat.com" , "jasowang@redhat.com" CC: "kvm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] virtio: Directly use ida_alloc_range()/ida_free() Thread-Topic: [PATCH] virtio: Directly use ida_alloc_range()/ida_free() Thread-Index: Adh7mb9eZpqq33w2TJqw0eKPxw85VQ== Date: Thu, 9 Jun 2022 00:42:11 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.200.104.82] Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg=SHA1; boundary="----=_NextPart_000_0000_01D87BDC.CEDC3830" MIME-Version: 1.0 tUid: 20226090842122a7f7fdd4e8e961b0d4b71845f6bf44e X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,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 ------=_NextPart_000_0000_01D87BDC.CEDC3830 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, > Hi, >=20 > Le 08/06/2022 =C3=A0 08:08, Deming Wang a =C3=A9crit : > > Use ida_alloc_range()/ida_free() instead of deprecated > > ida_simple_get()/ida_simple_remove() . > > > > Signed-off-by: Deming Wang > > --- > > drivers/vhost/vdpa.c | 5 ++--- > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index > > 935a1d0ddb97..384049cfca8d 100644 > > --- a/drivers/vhost/vdpa.c > > +++ b/drivers/vhost/vdpa.c > > @@ -1293,7 +1293,7 @@ static void vhost_vdpa_release_dev(struct = device > *device) > > struct vhost_vdpa *v =3D > > container_of(device, struct vhost_vdpa, dev); > > > > - ida_simple_remove(&vhost_vdpa_ida, v->minor); > > + ida_free(&vhost_vdpa_ida, v->minor); > > kfree(v->vqs); > > kfree(v); > > } > > @@ -1316,8 +1316,7 @@ static int vhost_vdpa_probe(struct vdpa_device > *vdpa) > > if (!v) > > return -ENOMEM; > > > > - minor =3D ida_simple_get(&vhost_vdpa_ida, 0, > > - VHOST_VDPA_DEV_MAX, GFP_KERNEL); > > + minor =3D ida_alloc_range(&vhost_vdpa_ida, 0, VHOST_VDPA_DEV_MAX - > 1, > > +GFP_KERNEL); >=20 > ida_alloc_max() would be better here. It is less verbose. >=20 > An explanation in the commit log of why the -1 is needed would also = help > reviewer/maintainer, IMHO. >=20 > It IS correct, but it is not that obvious without looking at > ida_simple_get() and ida_alloc_range(). >=20 > CJ >=20 >=20 > > if (minor < 0) { > > kfree(v); > > return minor; can I mention one patch about repair ida_free for this. ------=_NextPart_000_0000_01D87BDC.CEDC3830 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIK8zCCA6Iw ggKKoAMCAQICEGPKUixTOHaa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