[v4,02/24] bus/vdev: enable one device scan
Checks
Commit Message
The patch implemented the ops scan_one for vdev bus, it gives two benifits
1. Improve scan efficiency when a device is attached as hotplug, since no
need to pupulate a new device by iterating all devargs in devargs_list.
2. It also avoid sync IPC invoke (which happens in vdev->scan on secondary
process). The benifit is this removes the potential deadlock in the case
when secondary process receive a request from primary process to attach a
new device, since vdev->scan will be invoked on mp thread itself in that
case.
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
drivers/bus/vdev/vdev.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
Comments
On 26/06/2018 08:08, Qi Zhang wrote:
> The patch implemented the ops scan_one for vdev bus, it gives two benifits
> 1. Improve scan efficiency when a device is attached as hotplug, since no
> need to pupulate a new device by iterating all devargs in devargs_list.
> 2. It also avoid sync IPC invoke (which happens in vdev->scan on secondary
> process). The benifit is this removes the potential deadlock in the case
> when secondary process receive a request from primary process to attach a
> new device, since vdev->scan will be invoked on mp thread itself in that
> case.
Slight rewording and spelling corrections within description:
The patch implements the ops scan_one for the vdev bus, which gives two
benefits:
1. Improves scan efficiency when a device is attached as hotplug, since
there is no need to populate a new device by iterating all devargs in
devargs_list
2. It also avoids sync IPC invoke (which happens in vdev->scan on
secondary process). The benefit is this removes the potential deadlock
in the case when a secondary process receives a request from primary
process to attach a new device, since vdev->scan will be invoked on mp
thread itself in that case.
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
>
> drivers/bus/vdev/vdev.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
Acked-by: Remy Horton <remy.horton@intel.com>
@@ -467,6 +467,35 @@ vdev_scan(void)
return 0;
}
+static struct rte_device *vdev_scan_one(struct rte_devargs *devargs)
+{
+ struct rte_vdev_device *dev = NULL;
+
+ dev = calloc(1, sizeof(*dev));
+ if (!dev) {
+ VDEV_LOG(ERR, "failed to allocate memory for new device");
+ return NULL;
+ }
+
+ rte_spinlock_recursive_lock(&vdev_device_list_lock);
+
+ if (find_vdev(devargs->name)) {
+ VDEV_LOG(ERR, "device %s already exist", devargs->name);
+ free(dev);
+ rte_spinlock_recursive_unlock(&vdev_device_list_lock);
+ return NULL;
+ }
+
+ dev->device.devargs = devargs;
+ dev->device.numa_node = SOCKET_ID_ANY;
+ dev->device.name = devargs->name;
+ TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
+
+ rte_spinlock_recursive_unlock(&vdev_device_list_lock);
+
+ return &dev->device;
+}
+
static int
vdev_probe(void)
{
@@ -531,6 +560,7 @@ vdev_unplug(struct rte_device *dev)
static struct rte_bus rte_vdev_bus = {
.scan = vdev_scan,
+ .scan_one = vdev_scan_one,
.probe = vdev_probe,
.find_device = vdev_find_device,
.plug = vdev_plug,