From: Jan Blunck <jblunck@infradead.org>
To: Gaetan Rivet <gaetan.rivet@6wind.com>
Cc: dev <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v3 2/8] devargs: introduce removal function
Date: Wed, 12 Jul 2017 04:27:34 -0400 [thread overview]
Message-ID: <CALe+Z02bsS_1bZtRWRVWhB9xky2c_Tg5ey5ypFmpRY-jDFw++A@mail.gmail.com> (raw)
In-Reply-To: <7d819b3f9666620afa3324e47de7698a7e203328.1499814957.git.gaetan.rivet@6wind.com>
On Tue, Jul 11, 2017 at 7:25 PM, Gaetan Rivet <gaetan.rivet@6wind.com> 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.
Besides that the comment says that its current user is inside the EAL
so I wonder why it is exported.
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> ---
> 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 <string.h>
>
> #include <rte_devargs.h>
> +#include <rte_tailq.h>
> #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
>
next prev parent reply other threads:[~2017-07-12 8:27 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-09 1:45 [dpdk-dev] [PATCH 0/9] fix hotplug API Gaetan Rivet
2017-07-09 1:45 ` [dpdk-dev] [PATCH 1/9] eal: return device handle upon plugin Gaetan Rivet
2017-07-09 1:45 ` [dpdk-dev] [PATCH 2/9] eal: fix hotplug add Gaetan Rivet
2017-07-09 1:45 ` [dpdk-dev] [PATCH 3/9] devargs: introduce removal function Gaetan Rivet
2017-07-09 1:45 ` [dpdk-dev] [PATCH 4/9] eal: release devargs on device removal Gaetan Rivet
2017-07-09 1:45 ` [dpdk-dev] [PATCH 5/9] pci: use given name as generic name Gaetan Rivet
2017-07-09 1:45 ` [dpdk-dev] [PATCH 6/9] pci: fix generic driver pointer on probe error Gaetan Rivet
2017-07-09 1:45 ` [dpdk-dev] [PATCH 7/9] pci: fix hotplug operations Gaetan Rivet
2017-07-09 1:45 ` [dpdk-dev] [PATCH 8/9] vdev: implement plug operation Gaetan Rivet
2017-07-09 1:45 ` [dpdk-dev] [PATCH 9/9] bus: remove useless plug parameter Gaetan Rivet
2017-07-09 10:38 ` [dpdk-dev] [PATCH 0/9] fix hotplug API Jan Blunck
2017-07-09 12:19 ` Gaëtan Rivet
2017-07-09 14:19 ` Thomas Monjalon
[not found] ` <20170711160211.GW11154@bidouze.vm.6wind.com>
[not found] ` <CALe+Z00Rc_6cn_ckWrK1cD2RsdWENM3s+ytOpxNymTmaqh8e0g@mail.gmail.com>
2017-07-11 19:21 ` Gaëtan Rivet
2017-07-10 23:18 ` [dpdk-dev] [PATCH v2 0/8] " Gaetan Rivet
2017-07-10 23:19 ` [dpdk-dev] [PATCH v2 1/8] vdev: implement plug operation Gaetan Rivet
2017-07-10 23:19 ` [dpdk-dev] [PATCH v2 2/8] devargs: introduce removal function Gaetan Rivet
2017-07-10 23:19 ` [dpdk-dev] [PATCH v2 3/8] devargs: introduce insert function Gaetan Rivet
2017-07-11 22:13 ` Thomas Monjalon
2017-07-10 23:19 ` [dpdk-dev] [PATCH v2 4/8] eal: fix hotplug add / remove Gaetan Rivet
2017-07-11 22:18 ` Thomas Monjalon
2017-07-10 23:19 ` [dpdk-dev] [PATCH v2 5/8] pci: use given name as generic name Gaetan Rivet
2017-07-11 22:05 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2017-07-10 23:19 ` [dpdk-dev] [PATCH v2 6/8] pci: fix generic driver pointer on probe error Gaetan Rivet
2017-07-10 23:19 ` [dpdk-dev] [PATCH v2 7/8] pci: fix hotplug operations Gaetan Rivet
2017-07-10 23:19 ` [dpdk-dev] [PATCH v2 8/8] bus: remove useless plug parameter Gaetan Rivet
2017-07-11 23:25 ` [dpdk-dev] [PATCH v3 0/8] fix hotplug API Gaetan Rivet
2017-07-11 23:25 ` [dpdk-dev] [PATCH v3 1/8] vdev: implement plug operation Gaetan Rivet
2017-07-11 23:25 ` [dpdk-dev] [PATCH v3 2/8] devargs: introduce removal function Gaetan Rivet
2017-07-12 8:27 ` Jan Blunck [this message]
2017-07-12 17:22 ` Gaëtan Rivet
2017-07-11 23:25 ` [dpdk-dev] [PATCH v3 3/8] devargs: introduce insert function Gaetan Rivet
2017-07-12 8:20 ` Jan Blunck
2017-07-12 17:20 ` Gaëtan Rivet
2017-07-13 19:44 ` Jan Blunck
2017-07-11 23:25 ` [dpdk-dev] [PATCH v3 4/8] eal: fix hotplug add / remove Gaetan Rivet
2017-07-12 8:44 ` Jan Blunck
2017-07-12 17:33 ` Gaëtan Rivet
2017-07-11 23:25 ` [dpdk-dev] [PATCH v3 5/8] pci: use given name as generic name Gaetan Rivet
2017-07-11 23:25 ` [dpdk-dev] [PATCH v3 6/8] pci: fix generic driver pointer on probe error Gaetan Rivet
2017-07-11 23:25 ` [dpdk-dev] [PATCH v3 7/8] pci: fix hotplug operations Gaetan Rivet
2017-07-11 23:25 ` [dpdk-dev] [PATCH v3 8/8] bus: remove useless plug parameter Gaetan Rivet
2017-07-15 17:56 ` [dpdk-dev] [PATCH v4 0/8] fix hotplug API Gaetan Rivet
2017-07-15 17:56 ` [dpdk-dev] [PATCH v4 1/8] vdev: implement plug operation Gaetan Rivet
2017-07-15 17:56 ` [dpdk-dev] [PATCH v4 2/8] devargs: introduce removal function Gaetan Rivet
2017-07-15 17:56 ` [dpdk-dev] [PATCH v4 3/8] devargs: introduce insert function Gaetan Rivet
2017-07-15 17:56 ` [dpdk-dev] [PATCH v4 4/8] eal: fix hotplug add / remove Gaetan Rivet
2017-07-15 17:56 ` [dpdk-dev] [PATCH v4 5/8] pci: use given name as generic name Gaetan Rivet
2017-07-15 17:56 ` [dpdk-dev] [PATCH v4 6/8] pci: fix generic driver pointer on probe error Gaetan Rivet
2017-07-15 17:56 ` [dpdk-dev] [PATCH v4 7/8] pci: fix hotplug operations Gaetan Rivet
2017-07-15 17:56 ` [dpdk-dev] [PATCH v4 8/8] bus: remove useless plug parameter Gaetan Rivet
2017-07-19 21:27 ` [dpdk-dev] [PATCH v4 0/8] fix hotplug API Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALe+Z02bsS_1bZtRWRVWhB9xky2c_Tg5ey5ypFmpRY-jDFw++A@mail.gmail.com \
--to=jblunck@infradead.org \
--cc=dev@dpdk.org \
--cc=gaetan.rivet@6wind.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).