From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) by dpdk.org (Postfix) with ESMTP id 736B72E83 for ; Wed, 12 Jul 2017 19:22:55 +0200 (CEST) Received: by mail-wr0-f181.google.com with SMTP id c11so41365232wrc.3 for ; Wed, 12 Jul 2017 10:22:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=u4wocCbzAR9DQZfeZpeVZRk5zdjgjQ6E3lzmRABfzaY=; b=yzwrFB3navfjQpX0m8zDu0AFbsct1mFPB65qmsWQzPTNT4aYhGDPQAENFMblJJMnfD AkVbq0qwu6hr9K7Jk4+xlWTesbi/VTX990aiYSwb/a5C+EQk3b29zgxhFHbCdYU/y7FL u7mN3Sw1pasHDie8cKWYgRuxLVAKeQOmADD2r8J3pfU5An2UrEEcmtDmJzWGW+F8fgUE 6L10lJKWja1wykOP4bUi0SWH0kTHEmNjyxHAlseeieHogeA3xkFpNvKMuEqF90IFrqVI qFJaocQvCei7ejaLy59xfXjbsMAnolf5aruI+qCMC4LU9y40ZkJnIwO8FQah53Ohxipr m3jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=u4wocCbzAR9DQZfeZpeVZRk5zdjgjQ6E3lzmRABfzaY=; b=lgxXsvjJjCWBPum4fr/JYHL6dyc08u7qMnk1uxUbm3C5xGh9Q6Ie4Ccjd4zsiIoTA5 tJYM/8A2DLXwRB2rUROFPFbS/19FgNZ5UzXP05MzK/wQRGqGhT794JH+Imgv6uSlsTEM BI8hZyuFUn6syGwBMD/2dR7KtV6mhUJsA7MJx+yIrjrRXJU5KXIvCMmGr18PVJ1g8c9X Ays5xApbiMe0QbtC4yiX+33PVtKKYIcKeLIpTvs6ycSQjpDNhP+/JCXv746lpb1PwBlM Xe5svVkStxXjmf4Y+TabDKX7zhsOOEigQfymLmasfPe463o1LEk7eGPLi4svOp3vNpdO u8kg== X-Gm-Message-State: AIVw110PTAF6Xm7DIeTDjXwGRC7C7PitisHTCZV3dsJmtlzWc8vkEvHl p7lPUI/npB7tm+oT9lw= X-Received: by 10.223.165.13 with SMTP id i13mr3329155wrb.35.1499880175005; Wed, 12 Jul 2017 10:22:55 -0700 (PDT) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id a126sm2371357wmh.14.2017.07.12.10.22.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jul 2017 10:22:54 -0700 (PDT) Date: Wed, 12 Jul 2017 19:22:46 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Jan Blunck Cc: dev Message-ID: <20170712172245.GE11154@bidouze.vm.6wind.com> References: <7d819b3f9666620afa3324e47de7698a7e203328.1499814957.git.gaetan.rivet@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v3 2/8] devargs: introduce removal function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jul 2017 17:22:55 -0000 On Wed, Jul 12, 2017 at 04:27:34AM -0400, Jan Blunck wrote: > On Tue, Jul 11, 2017 at 7:25 PM, Gaetan Rivet wrote: > > Hotplug support introduces the possibility of removing devices from the > > system. Allocated resources must be freed. > > > > Extend the rte_devargs API to allow freeing allocated resources. > > > > This API is experimental and bound to change. It is currently designed > > as a symetrical to rte_eal_devargs_add(), but the latter will evolve > > shortly anyway. > > > > Its DEVTYPE parameter is currently only used to specify scan policies, > > and those will evolve in the next release. This evolution should > > rationalize the rte_devargs API. > > > > As such, the proposed API here is not the most convenient, but is > > taylored to follow the current design and integrate easily with its main > > use within rte_eal_hotplug_* functions. > > I don't think that this is safe to do. The rte_device is using a > reference to the allocated rte_devargs so before we remove it we need > to make sure that the device is gone. > I think you're right. No bus should need to use the rte_devargs to remove a device, but we cannot be sure. > Besides that the comment says that its current user is inside the EAL > so I wonder why it is exported. > I agree that there isn't much use outside. However, the converse rte_eal_devargs_add is exposed so it makes sense to also offer the possibility of removing one. But it will all change with the deprecation of rte_eal_devargs_add anyway, so let's not expose it if there is no need. > > Signed-off-by: Gaetan Rivet > > --- > > lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + > > lib/librte_eal/common/eal_common_devargs.c | 19 +++++++++++++++++++ > > lib/librte_eal/common/include/rte_devargs.h | 18 ++++++++++++++++++ > > lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + > > 4 files changed, 39 insertions(+) > > > > diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map > > index 381f895..40cd523 100644 > > --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map > > +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map > > @@ -207,6 +207,7 @@ EXPERIMENTAL { > > global: > > > > rte_eal_devargs_parse; > > + rte_eal_devargs_remove; > > rte_eal_hotplug_add; > > rte_eal_hotplug_remove; > > > > diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c > > index 49d43a3..bcdee13 100644 > > --- a/lib/librte_eal/common/eal_common_devargs.c > > +++ b/lib/librte_eal/common/eal_common_devargs.c > > @@ -41,6 +41,7 @@ > > #include > > > > #include > > +#include > > #include "eal_private.h" > > > > /** Global list of user devices */ > > @@ -182,6 +183,24 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) > > return -1; > > } > > > > +int > > +rte_eal_devargs_remove(const char *busname, const char *devname) > > +{ > > + struct rte_devargs *d; > > + void *tmp; > > + > > + TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { > > + if (strcmp(d->bus->name, busname) == 0 && > > + strcmp(d->name, devname) == 0) { > > + TAILQ_REMOVE(&devargs_list, d, next); > > + free(d->args); > > + free(d); > > + return 0; > > + } > > + } > > + return 1; > > +} > > + > > /* count the number of devices of a specified type */ > > unsigned int > > rte_eal_devargs_type_count(enum rte_devtype devtype) > > diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h > > index a0427cd..36453b6 100644 > > --- a/lib/librte_eal/common/include/rte_devargs.h > > +++ b/lib/librte_eal/common/include/rte_devargs.h > > @@ -163,6 +163,24 @@ rte_eal_devargs_parse(const char *dev, > > int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str); > > > > /** > > + * Remove a device from the user device list. > > + * Its resources are freed. > > + * If the devargs cannot be found, nothing happens. > > + * > > + * @param busname > > + * bus name of the devargs to remove. > > + * > > + * @param devname > > + * device name of the devargs to remove. > > + * > > + * @return > > + * 0 on success. > > + * <0 on error. > > + * >0 if the devargs was not within the user device list. > > + */ > > +int rte_eal_devargs_remove(const char *busname, const char *devname); > > + > > +/** > > * Count the number of user devices of a specified type > > * > > * @param devtype > > diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map > > index 0f9e009..a8ee349 100644 > > --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map > > +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map > > @@ -212,6 +212,7 @@ EXPERIMENTAL { > > global: > > > > rte_eal_devargs_parse; > > + rte_eal_devargs_remove; > > rte_eal_hotplug_add; > > rte_eal_hotplug_remove; > > > > -- > > 2.1.4 > > -- Gaëtan Rivet 6WIND