bus/vdev: fix device argument corrupt after bus scan
PATCH 1/1 bus/vdev: fix device argument corrupt after bus scan
It's not necessary to insert device argment to devargs_list during bus scan, but this happens when we try to attach a device on secondary process. The patch fix the issue.
--- drivers/bus/vdev/vdev.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/bus/vdev/vdev.c +7 -4
@@ -202,7 +202,9 @@ alloc_devargs(const char *name, const char *args) }static int -insert_vdev (const char *name,const char *args,struct rte_vdev_device **p_dev) +insert_vdev (const char *name,const char *args, +struct rte_vdev_device **p_dev, +bool init) {struct rte_vdev_device *dev;struct rte_devargs *devargs;
@@ -237,7 +239,8 @@ insert_vdev(const char *name, const char *args, struct rte_vdev_device **p_dev) }TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); -rte_devargs_insert (devargs); +if (init) +rte_devargs_insert (devargs);if (p_dev) *p_dev = dev;
@@ -257,7 +260,7 @@ rte_vdev_init(const char *name, const char *args)int ret;rte_spinlock_recursive_lock (&vdev_device_list_lock); - ret =insert_vdev (name, args, &dev); + ret =insert_vdev (name, args, &dev, true);if (ret ==0 ) { ret =vdev_probe_all_drivers (dev);if (ret) {
@@ -383,7 +386,7 @@ vdev_action(const struct rte_mp_msg *mp_msg, const void *peer)break ;case VDEV_SCAN_ONE :VDEV_LOG (INFO ,"receive vdev, %s" , in->name); - ret =insert_vdev (in->name,NULL ,NULL ); + ret =insert_vdev (in->name,NULL ,NULL , false);if (ret == -EEXIST )VDEV_LOG (DEBUG ,"device already exist, %s" , in->name);else if (ret <0 )
Signature · 1 line
2.13.6
Quoted 17 lines · Qi Zhang
It's not necessary to insert device argment to
devargs_listduring bus scan, but this happens when we try to attach a device on secondary process. The patch fix the issue.Fixes cdb068f031c6 ("bus/vdev: scan by multi-process channel")Signed-off-by Qi Zhang <[email protected]>--- drivers/bus/vdev/vdev.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/bus/vdev/vdev.c +0
-0
drivers/bus/vdev/vdev.c alloc_devargs(const char *name, const char *args) · line 207
Quoted 7 lines
drivers/bus/vdev/vdev.c +3
-1@@ -202,7 +202,9 @@ alloc_devargs(const char *name, const char *args) }static int -insert_vdev (const char *name,const char *args,struct rte_vdev_device **p_dev) +insert_vdev (const char *name,const char *args, +struct rte_vdev_device **p_dev, +bool init)
Why is vdev the only bus not using hotplug API itself and reimplementing it on its own?
It should not have to insert devargs at all, not even in the primary process. If it called rte_dev_probe(), this would normally already be properly handled I think.
Quoted 34 lines
drivers/bus/vdev/vdev.c +4
-3{struct rte_vdev_device *dev;struct rte_devargs *devargs;@@ -237,7 +239,8 @@ insert_vdev(const char *name, const char *args, struct rte_vdev_device **p_dev) }TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); -rte_devargs_insert (devargs); +if (init) +rte_devargs_insert (devargs);if (p_dev) *p_dev = dev;@@ -257,7 +260,7 @@ rte_vdev_init(const char *name, const char *args)int ret;rte_spinlock_recursive_lock (&vdev_device_list_lock); - ret =insert_vdev (name, args, &dev); + ret =insert_vdev (name, args, &dev, true);if (ret ==0 ) { ret =vdev_probe_all_drivers (dev);if (ret) {@@ -383,7 +386,7 @@ vdev_action(const struct rte_mp_msg *mp_msg, const void *peer)break ;case VDEV_SCAN_ONE :VDEV_LOG (INFO ,"receive vdev, %s" , in->name); - ret =insert_vdev (in->name,NULL ,NULL ); + ret =insert_vdev (in->name,NULL ,NULL , false);if (ret == -EEXIST )VDEV_LOG (DEBUG ,"device already exist, %s" , in->name);else if (ret <0 )Signature · 1 line
2.13.6
Signature · 2 lines
Gaëtan Rivet 6WIND
Quoted 29 lines
-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Thursday, October 25, 2018 4:51 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] bus/vdev: fix device argument corrupt after bus scanQuoted 19 lines · Qi Zhang
It's not necessary to insert device argment to
devargs_listduring bus scan, but this happens when we try to attach a device on secondary process. The patch fix the issue.Fixes cdb068f031c6 ("bus/vdev: scan by multi-process channel")Signed-off-by Qi Zhang <[email protected]>--- drivers/bus/vdev/vdev.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/bus/vdev/vdev.c index renamed from drivers/bus/vdev/vdev.c +0
-0
688e31c21..818a2bfc2100644drivers/bus/vdev/vdev.c +0
-0@@ -202,7 +202,9 @@ alloc_devargs(const char *name, const char *args) }
Quoted 9 lines
drivers/bus/vdev/vdev.c alloc_devargs(const char *name, const char *args) · line 207
Quoted 6 lines
drivers/bus/vdev/vdev.c +3
-1static int -insert_vdev (const char *name,const char *args,struct rte_vdev_device **p_dev) +insert_vdev(const char *name, const char *args, + struct rte_vdev_device **p_dev, + bool init)Why is vdev the only bus not using hotplug API itself and reimplementing it on its own?
I don't know the history,
but replace insert_vdev with hotplug API will not solve all the problem (see my below comments)
Quoted 4 lines
It should not have to insert devargs at all, not even in the primary process. If it called
rte_dev_probe(), this would normally already be properly handled I think.
Currently insert_vdev is shared by two scenarios
1. rte_vdev_init, which is called by application to attach a new device, I agree it's better to have rte_dev_probe here so, no need to have insert_vdev here.
2. during secondary's vdev->scan when it receive a SCAN_ONE event from primary, it should not call rte_devargs_insert,
The patch is going to fix the issue on secondary scenario and we can do the cleanup for first issue in a separate patch
Quoted 41 lines
drivers/bus/vdev/vdev.c insert_vdev(const char *name, const char *args,
Quoted 5 lines
drivers/bus/vdev/vdev.c +0
-0{struct rte_vdev_device *dev;drivers/bus/vdev/vdev.c +0
-0struct rte_devargs *devargs;@@ -237,7 +239,8 @@ insert_vdev(const char *name, const char *args,struct
rte_vdev_device**p_dev)drivers/bus/vdev/vdev.c vdev_action(const struct rte_mp_msg *mp_msg,
Quoted 19 lines
drivers/bus/vdev/vdev.c +3
-2}TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); -rte_devargs_insert (devargs); +if (init) +rte_devargs_insert (devargs);if (p_dev) *p_dev = dev;@@ -257,7 +260,7 @@ rte_vdev_init(const char *name, const char *args)int ret;rte_spinlock_recursive_lock (&vdev_device_list_lock); - ret =insert_vdev (name, args, &dev); + ret =insert_vdev (name, args, &dev, true);if (ret ==0 ) { ret =vdev_probe_all_drivers (dev);if (ret) {@@ -383,7 +386,7 @@ vdev_action(const struct rte_mp_msg *mp_msg,const void *peer)
Quoted 11 lines
drivers/bus/vdev/vdev.c +1
-2break ;case VDEV_SCAN_ONE :VDEV_LOG (INFO ,"receive vdev, %s" , in->name); - ret =insert_vdev (in->name,NULL ,NULL ); + ret =insert_vdev (in->name,NULL ,NULL , false);if (ret == -EEXIST )VDEV_LOG (DEBUG ,"device already exist, %s" , in->name);else if (ret <0 ) --2.13.6
--
Gaëtan Rivet
6WIND
Quoted 43 lines · Qi Z
Quoted 29 lines
-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Thursday, October 25, 2018 4:51 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] bus/vdev: fix device argument corrupt after bus scanQuoted 19 lines · Qi Zhang
It's not necessary to insert device argment to
devargs_listduring bus scan, but this happens when we try to attach a device on secondary process. The patch fix the issue.Fixes cdb068f031c6 ("bus/vdev: scan by multi-process channel")Signed-off-by Qi Zhang <[email protected]>--- drivers/bus/vdev/vdev.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/bus/vdev/vdev.c index renamed from drivers/bus/vdev/vdev.c +0
-0
688e31c21..818a2bfc2100644drivers/bus/vdev/vdev.c +0
-0@@ -202,7 +202,9 @@ alloc_devargs(const char *name, const char *args) }Quoted 9 lines
drivers/bus/vdev/vdev.c alloc_devargs(const char *name, const char *args) · line 207
Quoted 6 lines
drivers/bus/vdev/vdev.c +3
-1static int -insert_vdev (const char *name,const char *args,struct rte_vdev_device **p_dev) +insert_vdev(const char *name, const char *args, + struct rte_vdev_device **p_dev, + bool init)Why is vdev the only bus not using hotplug API itself and reimplementing it on its own?
I don't know the history,
but replaceinsert_vdevwith hotplug API will not solve all the problem (see my below comments)Quoted 1 line
Quoted 8 lines
Quoted 3 lines
It should not have to insert devargs at all, not even in the primary process. If it called
rte_dev_probe(), this would normally already be properly handled I think.Currently
insert_vdevis shared by two scenarios
1.rte_vdev_init, which is called by application to attach a new device, I agree it's better to haverte_dev_probehere so, no need to haveinsert_vdevhere.
2. during secondary'svdev->scanwhen it receive aSCAN_ONEevent from primary, it should not callrte_devargs_insert,
The patch is going to fix the issue on secondary scenario and we can do the cleanup for first issue in a separate patch
In 2., won't dev_probe() check for secondary process context and in this case, send the request to primary, which will see that the device is already probed, which would thus fix your issue?
My take on it is that it seems to be fixing both your issue and cleaning up history.
Quoted 44 lines
Quoted 44 lines
drivers/bus/vdev/vdev.c insert_vdev(const char *name, const char *args,
Quoted 8 lines
drivers/bus/vdev/vdev.c +0
-0{struct rte_vdev_device *dev;drivers/bus/vdev/vdev.c +0
-0struct rte_devargs *devargs;@@ -237,7 +239,8 @@ insert_vdev(const char *name, const char *args,struct
rte_vdev_device**p_dev)drivers/bus/vdev/vdev.c vdev_action(const struct rte_mp_msg *mp_msg,
Quoted 19 lines
drivers/bus/vdev/vdev.c +3
-2}TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); -rte_devargs_insert (devargs); +if (init) +rte_devargs_insert (devargs);if (p_dev) *p_dev = dev;@@ -257,7 +260,7 @@ rte_vdev_init(const char *name, const char *args)int ret;rte_spinlock_recursive_lock (&vdev_device_list_lock); - ret =insert_vdev (name, args, &dev); + ret =insert_vdev (name, args, &dev, true);if (ret ==0 ) { ret =vdev_probe_all_drivers (dev);if (ret) {@@ -383,7 +386,7 @@ vdev_action(const struct rte_mp_msg *mp_msg,const void *peer)
Quoted 11 lines
drivers/bus/vdev/vdev.c +1
-2break ;case VDEV_SCAN_ONE :VDEV_LOG (INFO ,"receive vdev, %s" , in->name); - ret =insert_vdev (in->name,NULL ,NULL ); + ret =insert_vdev (in->name,NULL ,NULL , false);if (ret == -EEXIST )VDEV_LOG (DEBUG ,"device already exist, %s" , in->name);else if (ret <0 ) --2.13.6
--
Gaëtan Rivet
6WIND
Signature · 2 lines
Gaëtan Rivet 6WIND
Quoted 63 lines
-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Thursday, October 25, 2018 10:03 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] bus/vdev: fix device argument corrupt after bus scanQuoted 46 lines · Qi Z
Quoted 31 lines
-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Thursday, October 25, 2018 4:51 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] bus/vdev: fix device argument corrupt after bus scanQuoted 20 lines · Qi Zhang
It's not necessary to insert device argment to
devargs_listduring bus scan, but this happens when we try to attach a device on secondary process. The patch fix the issue.Fixes cdb068f031c6 ("bus/vdev: scan by multi-process channel")Signed-off-by Qi Zhang <[email protected]>--- drivers/bus/vdev/vdev.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/bus/vdev/vdev.c +0
-0index
688e31c21..818a2bfc2100644drivers/bus/vdev/vdev.c +0
-0@@ -202,7 +202,9 @@ alloc_devargs(const char *name, const char *args) }Quoted 9 lines
drivers/bus/vdev/vdev.c alloc_devargs(const char *name, const char *args) · line 207
Quoted 6 lines
drivers/bus/vdev/vdev.c +3
-1static int -insert_vdev (const char *name,const char *args,struct rte_vdev_device **p_dev) +insert_vdev(const char *name, const char *args, + struct rte_vdev_device **p_dev, + bool init)Why is vdev the only bus not using hotplug API itself and reimplementing it on its own?
I don't know the history,
but replaceinsert_vdevwith hotplug API will not solve all the problem (see my below comments)Quoted 1 line
Quoted 6 lines
Quoted 3 lines
It should not have to insert devargs at all, not even in the primary process. If it called
rte_dev_probe(), this would normally already be properly handled I think.Currently
insert_vdevis shared by two scenarios 1.rte_vdev_init, which is called by application to attach a new device, I agree it's better tohave
rte_dev_probehere so, no need to haveinsert_vdevhere.
Quoted 8 lines
Quoted 4 lines
2. during secondary's
vdev->scanwhen it receive aSCAN_ONEevent from primary, it should not callrte_devargs_insert, The patch is going to fix the issue on secondary scenario and we can do the cleanup for first issue in a separate patchIn 2., won't
dev_probe()check for secondary process context and in this case, send the request to primary, which will see that the device is already probed, which would thus fix your issue?
No, It's not the case that we issue a device attaching from secondary, but the case that we try to sync with primary for a device already be attached So we are in the context of dev->scan, we should not do dev_probe in dev->scan, since dev_probe will call dev->scan again, then it go dead loop.
Quoted 55 lines
My take on it is that it seems to be fixing both your issue and cleaning up history.
Quoted 12 lines
Quoted 12 lines
drivers/bus/vdev/vdev.c insert_vdev(const char *name, const char · line 239
Quoted 9 lines
drivers/bus/vdev/vdev.c +0
-0{struct rte_vdev_device *dev;drivers/bus/vdev/vdev.c +0
-0struct rte_devargs *devargs;@@ -237,7 +239,8 @@ insert_vdev(const char *name, const char *args,struct
rte_vdev_device**p_dev)Quoted 2 lines
drivers/bus/vdev/vdev.c +0
-0}Quoted 8 lines
Quoted 8 lines
drivers/bus/vdev/vdev.c rte_vdev_init(const char *name, const char
Quoted 8 lines
drivers/bus/vdev/vdev.c +2
-1TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); -rte_devargs_insert (devargs); +if (init) +rte_devargs_insert (devargs);if (p_dev)drivers/bus/vdev/vdev.c +0
-0*p_dev = dev;@@ -257,7 +260,7 @@ rte_vdev_init(const char *name, const char*args)
Quoted 9 lines
Quoted 9 lines
drivers/bus/vdev/vdev.c vdev_action(const struct rte_mp_msg
Quoted 9 lines
drivers/bus/vdev/vdev.c +1
-1int ret;rte_spinlock_recursive_lock (&vdev_device_list_lock); - ret =insert_vdev (name, args, &dev); + ret =insert_vdev (name, args, &dev, true);if (ret ==0 ) { ret =vdev_probe_all_drivers (dev);if (ret) {@@ -383,7 +386,7 @@ vdev_action(const struct rte_mp_msg
*mp_msg,Quoted 16 lines
Quoted 16 lines
const void *peer)
Quoted 11 lines
drivers/bus/vdev/vdev.c +1
-2break ;case VDEV_SCAN_ONE :VDEV_LOG (INFO ,"receive vdev, %s" , in->name); - ret =insert_vdev (in->name,NULL ,NULL ); + ret =insert_vdev (in->name,NULL ,NULL , false);if (ret == -EEXIST )VDEV_LOG (DEBUG ,"device already exist, %s" , in->name);else if (ret <0 ) --2.13.6
--
Gaëtan Rivet
6WIND--
Gaëtan Rivet
6WIND
Quoted 68 lines · Qi Z
Quoted 68 lines
-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Thursday, October 25, 2018 10:03 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] bus/vdev: fix device argument corrupt after bus scanQuoted 46 lines · Qi Z
Quoted 31 lines
-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Thursday, October 25, 2018 4:51 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] bus/vdev: fix device argument corrupt after bus scanQuoted 20 lines · Qi Zhang
It's not necessary to insert device argment to
devargs_listduring bus scan, but this happens when we try to attach a device on secondary process. The patch fix the issue.Fixes cdb068f031c6 ("bus/vdev: scan by multi-process channel")Signed-off-by Qi Zhang <[email protected]>--- drivers/bus/vdev/vdev.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/bus/vdev/vdev.c +0
-0index
688e31c21..818a2bfc2100644drivers/bus/vdev/vdev.c +0
-0@@ -202,7 +202,9 @@ alloc_devargs(const char *name, const char *args) }Quoted 9 lines
drivers/bus/vdev/vdev.c alloc_devargs(const char *name, const char *args) · line 207
Quoted 6 lines
drivers/bus/vdev/vdev.c +3
-1static int -insert_vdev (const char *name,const char *args,struct rte_vdev_device **p_dev) +insert_vdev(const char *name, const char *args, + struct rte_vdev_device **p_dev, + bool init)Why is vdev the only bus not using hotplug API itself and reimplementing it on its own?
I don't know the history,
but replaceinsert_vdevwith hotplug API will not solve all the problem (see my below comments)Quoted 1 line
Quoted 6 lines
Quoted 3 lines
It should not have to insert devargs at all, not even in the primary process. If it called
rte_dev_probe(), this would normally already be properly handled I think.Currently
insert_vdevis shared by two scenarios 1.rte_vdev_init, which is called by application to attach a new device, I agree it's better tohave
rte_dev_probehere so, no need to haveinsert_vdevhere.Quoted 4 lines
2. during secondary's
vdev->scanwhen it receive aSCAN_ONEevent from primary, it should not callrte_devargs_insert, The patch is going to fix the issue on secondary scenario and we can do the cleanup for first issue in a separate patch
Quoted 10 lines
Quoted 3 lines
In 2., won't
dev_probe()check for secondary process context and in this case, send the request to primary, which will see that the device is already probed, which would thus fix your issue?No, It's not the case that we issue a device attaching from secondary, but the case that we try to sync with primary for a device already be attached So we are in the context of
dev->scan, we should not dodev_probeindev->scan, sincedev_probewill calldev->scanagain, then it go dead loop.Quoted 4 lines
My take on it is that it seems to be fixing both your issue and cleaning up history.
Ok!
As long as you are confident this is the simplest way to write this, while taking into consideration the future rework of vdev_init(), all good :)
Signature · 2 lines
Gaëtan Rivet 6WIND
Thomas Monjalon
Applied25/10/2018 05:30, Qi Zhang:
Quoted 8 lines
It's not necessary to insert device argment to
devargs_listduring bus scan, but this happens when we try to attach a device on secondary process. The patch fix the issue.Fixes cdb068f031c6 ("bus/vdev: scan by multi-process channel")Signed-off-by Qi Zhang <[email protected]>
Applied, thanks