Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2822588iof; Wed, 8 Jun 2022 12:47:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRbpxA4rQUOPfea1u6iYNfGdQVOZm45zsYE6tdy4BwL1DXIJXXZ9kma/BaHnJ9nQ82weaP X-Received: by 2002:a05:6402:42d5:b0:433:1727:b31c with SMTP id i21-20020a05640242d500b004331727b31cmr4399942edc.9.1654717674927; Wed, 08 Jun 2022 12:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654717674; cv=none; d=google.com; s=arc-20160816; b=E6kfqOta6y4ZP5EIn5LJnHZ0lSBFWPTnX9FXbvpx1r+ClpItS7X1VddypvrEighLpH hhTscN218tnkMXwHGU73MjKVGQQUBaMSLzBI1mDZ5D3EvjGGAjlnFi9IK2ib1EeX5yJG 1e86vv24vzLvLN62E8QIUJz5gXI9Z+AebLC2OdSLhfEchi6TIx0nv7hhShylzt7zda2W Bx4RrGtQ32INIc87E3nHMIQd1rNTjJrv13pqxYGID1ejf3ABpJ9/FwCZM4jveLGXKbvD yi2hN8IPr7KWyHkgngIDu7Swe2siSRGsifSulkAwJCfMWX6JYVlQOvulUkcQq0NsAIfq Et4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=AfoOPjkYQrEaNb53IR1QvRQobYVx2Vr8rdAOeH9yK0o=; b=jJBFzTdNvW0rZlQdI6DMAqCm0bEhwDJ5I1zwQxwhM9/Y7MLoOu+ZCNJ5KFBTBGoUe3 Ocrr4rt78lRTu0j+9blJ0+nCCfYX7zoF4YtQ/PbZ2H/1l8nRqHGCCNCvj+9swJ4zdmh6 Qtvgcx10CdTbnQzmW3HHTkvnNY2Dh5Kat5GIMW0CPVlDkKL/VztTWtdRmfIMxf3LUJy6 D7hMNFjPkNWcg0G2mOJvj4oeGtxAOzZ/gfnFRtOxzm2KYzTEnqkWrlP5BmVhE2bzCmEU M+oZ5cKhPPUkgT7/aesAftZzXMbJDFO0fz3ojb+D4FouoYhH0ns5z5HcI/2hLuYt5Om3 t/TA== 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 dz15-20020a0564021d4f00b004316f91d4d7si10385262edb.100.2022.06.08.12.46.58; Wed, 08 Jun 2022 12:47:54 -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 S234704AbiFHTHh (ORCPT + 99 others); Wed, 8 Jun 2022 15:07:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235054AbiFHTH3 (ORCPT ); Wed, 8 Jun 2022 15:07:29 -0400 Received: from smtp.smtpout.orange.fr (smtp07.smtpout.orange.fr [80.12.242.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91DAD3FDAB for ; Wed, 8 Jun 2022 12:06:07 -0700 (PDT) Received: from [192.168.1.18] ([90.11.190.129]) by smtp.orange.fr with ESMTPA id z10FnxNJJOOQ1z10FnBYWW; Wed, 08 Jun 2022 21:06:05 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Wed, 08 Jun 2022 21:06:05 +0200 X-ME-IP: 90.11.190.129 Message-ID: <66584227-9688-b738-1300-4b379ea0689c@wanadoo.fr> Date: Wed, 8 Jun 2022 21:06:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] virtio: Directly use ida_alloc_range()/ida_free() Content-Language: en-US To: Deming Wang , 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 References: <20220608060826.1681-1-wangdeming@inspur.com> From: Christophe JAILLET In-Reply-To: <20220608060826.1681-1-wangdeming@inspur.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 Hi, Le 08/06/2022 à 08:08, Deming Wang a écrit : > 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 = > 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 = ida_simple_get(&vhost_vdpa_ida, 0, > - VHOST_VDPA_DEV_MAX, GFP_KERNEL); > + minor = ida_alloc_range(&vhost_vdpa_ida, 0, VHOST_VDPA_DEV_MAX - 1, GFP_KERNEL); ida_alloc_max() would be better here. It is less verbose. An explanation in the commit log of why the -1 is needed would also help reviewer/maintainer, IMHO. It IS correct, but it is not that obvious without looking at ida_simple_get() and ida_alloc_range(). CJ > if (minor < 0) { > kfree(v); > return minor;