fixes for device event
v4 cover fixes for device event
From: Yunjian Wang <[email protected]>
This series include three fixes patches for device event.
---
v4:
* add fix a wrong returned value
* remove redundant check suggested by David Marchand
v3:
* modified the format.
Yunjian Wang (3):
eal: fix memory leak when removing event_cb
eal: return error code when failure
eal: fix a wrong returned value when callback exists
lib/librte_eal/common/eal_common_dev.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v4 1/3 eal: fix memory leak when removing event_cb
From: Yunjian Wang <[email protected]>
The event_cb->dev_name is not freed when freeing event_cb, and this causes a memory leak.
--- lib/librte_eal/common/eal_common_dev.c | 1 + 1 file changed, 1 insertion(+)
lib/librte_eal/common/eal_common_dev.c +1 -0
@@ -526,6 +526,7 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)*/ if (event_cb->active ==0 ) {TAILQ_REMOVE (&dev_event_cbs, event_cb, next); +free (event_cb->dev_name);free (event_cb); ret++; }else {
Signature · 1 line
1.8.3.1
PATCH v4 2/3 eal: return error code when failure
In reply to wangyunjianFrom: Yunjian Wang <[email protected]>
Fix return value, using -EAGAIN instead of 0 when the callback is busy and using -ENOENT instead of 0 when the callback is not found.
--- lib/librte_eal/common/eal_common_dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_dev.c +7 -1
@@ -530,9 +530,15 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)free (event_cb); ret++; }else { -continue ; + ret = -EAGAIN ; +break ; } } + +/* this callback is not be registered */ +if (ret ==0 ) + ret = -ENOENT ; +rte_spinlock_unlock (&dev_event_lock);return ret; }
Signature · 1 line
1.8.3.1
PATCH v4 3/3 eal: fix a wrong returned value when callback exists
In reply to wangyunjianFrom: Yunjian Wang <[email protected]>
We should return an error value, when the callback is already exist.
--- lib/librte_eal/common/eal_common_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/common/eal_common_dev.c +2 -2
@@ -431,7 +431,7 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name) void *cb_arg) {struct dev_event_callback *event_cb; -int ret; +int ret =0 ;if (!cb_fn)return -EINVAL ;
@@ -484,7 +484,7 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name) }rte_spinlock_unlock (&dev_event_lock); -return 0 ; +return ret; error:free (event_cb);rte_spinlock_unlock (&dev_event_lock);
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removing event_cb
In reply to wangyunjianPing for review.
Thanks,
Yunjian
Quoted 40 lines
-----Original Message-----
From: wangyunjian
Sent: Friday, July 3, 2020 5:46 PM
To: [email protected]
Cc: [email protected]; Lilijun (Jerry) <[email protected]>; xudingke <[email protected]>; wangyunjian <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removingevent_cbFrom: Yunjian Wang <[email protected]>
The
event_cb->dev_nameis not freed when freeingevent_cb, and this causes a memory leak.Fixes a753e53d517b ("eal: add device event monitor framework")Signed-off-by Yunjian Wang <[email protected]>--- lib/librte_eal/common/eal_common_dev.c | 1 + 1 file changed, 1 insertion(+)lib/librte_eal/common/eal_common_dev.c +1
-0@@ -526,6 +526,7 @@ static int cmp_dev_name(const struct rte_device *dev,const void *_name) */ if (event_cb->active ==0 ) {TAILQ_REMOVE (&dev_event_cbs, event_cb, next); +free (event_cb->dev_name);free (event_cb); ret++;} else {
--
1.8.3.1
Jeff Guo
Acked-byRe: [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removing event_cb
hi, yunjian
The patch seems no problem, but when you update your patch, please add other guys who had comment on your patch and maintainer to see if they have
other opinion, and --in-reply-to is also helpful for patch review, thanks.
Quoted 28 lines · wangyunjian
Ping for review.
Thanks,
YunjianQuoted 23 lines
-----Original Message-----
From: wangyunjian
Sent: Friday, July 3, 2020 5:46 PM
To: [email protected]
Cc: [email protected]; Lilijun (Jerry) <[email protected]>; xudingke <[email protected]>; wangyunjian <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removingevent_cbFrom: Yunjian Wang <[email protected]>
The
event_cb->dev_nameis not freed when freeingevent_cb, and this causes a memory leak.Fixes a753e53d517b ("eal: add device event monitor framework")Signed-off-by Yunjian Wang <[email protected]>--- lib/librte_eal/common/eal_common_dev.c | 1 + 1 file changed, 1 insertion(+)
Quoted 16 lines
Quoted 13 lines
lib/librte_eal/common/eal_common_dev.c +1
-0@@ -526,6 +526,7 @@ static int cmp_dev_name(const struct rte_device *dev,const void *_name) */ if (event_cb->active ==0 ) {TAILQ_REMOVE (&dev_event_cbs, event_cb, next); +free (event_cb->dev_name);free (event_cb); ret++;Quoted 3 lines
} else {
--
1.8.3.1
Hi, Ferruh Yigit & David Marchand
Could you please give any suggestion?
Thanks,
Yunjian
Quoted 31 lines
-----Original Message-----
From: wangyunjian
Sent: Friday, July 3, 2020 5:44 PM
To: [email protected]
Cc: [email protected]; Lilijun (Jerry) <[email protected]>; xudingke <[email protected]>; wangyunjian <[email protected]>
Subject: [dpdk-dev] [PATCH v4 0/3] fixes for device eventFrom: Yunjian Wang <[email protected]>
This series include three fixes patches for device event.
---
v4:
* add fix a wrong returned value
* remove redundant check suggested by David Marchandv3:
* modified the format.Yunjian Wang (3):
eal: fix memory leak when removingevent_cb
eal: return error code when failure
eal: fix a wrong returned value when callback existslib/librte_eal/common/eal_common_dev.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)--
1.8.3.1
Re: [dpdk-dev] [dpdk-stable] [PATCH v4 3/3] eal: fix a wrong returned value when callback exists
In reply to wangyunjianQuoted 36 lines · wangyunjian
From: Yunjian Wang <[email protected]>
We should return an error value, when the callback is already exist.
Fixes a753e53d517b ("eal: add device event monitor framework")Signed-off-by Yunjian Wang <[email protected]>--- lib/librte_eal/common/eal_common_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_eal/common/eal_common_dev.c +2
-3@@ -431,7 +431,7 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name) void *cb_arg) {struct dev_event_callback *event_cb; -int ret; +int ret =0 ;if (!cb_fn)return -EINVAL ;@@ -484,7 +484,7 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name) }rte_spinlock_unlock (&dev_event_lock); -return 0 ; +return ret; error:free (event_cb);rte_spinlock_unlock (&dev_event_lock); --
Quoted 1 line
1.8.3.1
A simpler fix is to directly jump to the error label.
This has the advantage of having all errors go through a single cleanup code:
(quoted diff) +0 -0
b/lib/librte_eal/common/eal_common_dev.c
index 9e4f09d83e..fa47074b0b 100644
lib/librte_eal/common/eal_common_dev.c +2 -0
@@ -480,7 +480,9 @@ rte_dev_event_callback_register(const char *device_name,RTE_LOG (ERR ,EAL ,"The callback is already exist, no need " "to register again.\n" ); + event_cb =NULL ; ret = -EEXIST ; + goto error; }rte_spinlock_unlock (&dev_event_lock);
What do you think?
Signature · 1 line
David Marchand
Re: [dpdk-dev] [dpdk-stable] [PATCH v4 3/3] eal: fix a wrong returned value when callback exists
Quoted 71 lines
-----Original Message-----
From: David Marchand [mailto:[email protected]]
Sent: Tuesday, October 20, 2020 9:19 PM
To: wangyunjian <[email protected]>; Jeff Guo <[email protected]>
Cc: dev <[email protected]>; Lilijun (Jerry) <[email protected]>; xudingke <[email protected]>; dpdk stable <[email protected]>
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v4 3/3] eal: fix a wrong returned value when callback existslib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device
Quoted 19 lines · wangyunjian
From: Yunjian Wang <[email protected]>
We should return an error value, when the callback is already exist.
Fixes a753e53d517b ("eal: add device event monitor framework")Signed-off-by Yunjian Wang <[email protected]>--- lib/librte_eal/common/eal_common_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_eal/common/eal_common_dev.c +0
-0@@ -431,7 +431,7 @@ static int cmp_dev_name(const struct rte_device*dev, const void
*_name)lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device
Quoted 8 lines
lib/librte_eal/common/eal_common_dev.c +1
-1void *cb_arg) {struct dev_event_callback *event_cb; -int ret; +int ret =0 ;if (!cb_fn)return -EINVAL ;@@ -484,7 +484,7 @@ static int cmp_dev_name(const struct rte_device*dev, const void
*_name)Quoted 10 lines
lib/librte_eal/common/eal_common_dev.c +1
-2}rte_spinlock_unlock (&dev_event_lock); -return 0 ; +return ret; error:free (event_cb);rte_spinlock_unlock (&dev_event_lock); --1.8.3.1
A simpler fix is to directly jump to the error label.
This has the advantage of having all errors go through a single cleanup code:lib/librte_eal/common/eal_common_dev.c +2
-0@@ -480,7 +480,9 @@ rte_dev_event_callback_register(const char *device_name,RTE_LOG (ERR ,EAL ,"The callback is already exist, no need " "to register again.\n" ); + event_cb =NULL ; ret = -EEXIST ; + goto error; }rte_spinlock_unlock(&dev_event_lock);
Quoted 1 line
What do you think?
Agree, I will update it in next version.
Yunjian
Quoted 4 lines
--
David Marchand
v5 cover fixes for device event
In reply to wangyunjianFrom: Yunjian Wang <[email protected]>
This series include three fixes patches for device event.
---
v5:
* update patch 3/3 code styles suggested by David Marchand
v4:
* add fix a wrong returned value
* remove redundant check suggested by David Marchand
v3:
* modified the format.
Yunjian Wang (3):
eal: fix memory leak when removing event_cb
eal: return error code when failure
eal: fix a wrong returned value when callback exists
lib/librte_eal/common/eal_common_dev.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
Signature · 1 line
2.23.0
PATCH v5 1/3 eal: fix memory leak when removing event_cb
From: Yunjian Wang <[email protected]>
The event_cb->dev_name is not freed when freeing event_cb, and this causes a memory leak.
--- lib/librte_eal/common/eal_common_dev.c | 1 + 1 file changed, 1 insertion(+)
lib/librte_eal/common/eal_common_dev.c +1 -0
@@ -526,6 +526,7 @@ rte_dev_event_callback_unregister(const char *device_name,*/ if (event_cb->active ==0 ) {TAILQ_REMOVE (&dev_event_cbs, event_cb, next); +free (event_cb->dev_name);free (event_cb); ret++; }else {
Signature · 1 line
2.23.0
PATCH v5 2/3 eal: return error code when failure
In reply to wangyunjianFrom: Yunjian Wang <[email protected]>
Fix return value, using -EAGAIN instead of 0 when the callback is busy and using -ENOENT instead of 0 when the callback is not found.
--- lib/librte_eal/common/eal_common_dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_dev.c +7 -1
@@ -530,9 +530,15 @@ rte_dev_event_callback_unregister(const char *device_name,free (event_cb); ret++; }else { -continue ; + ret = -EAGAIN ; +break ; } } + +/* this callback is not be registered */ +if (ret ==0 ) + ret = -ENOENT ; +rte_spinlock_unlock (&dev_event_lock);return ret; }
Signature · 1 line
2.23.0
PATCH v5 3/3 eal: fix a wrong returned value when callback exists
In reply to wangyunjianFrom: Yunjian Wang <[email protected]>
We should return an error value, when the callback is already exist.
--- lib/librte_eal/common/eal_common_dev.c | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_eal/common/eal_common_dev.c +2 -0
@@ -480,7 +480,9 @@ rte_dev_event_callback_register(const char *device_name,RTE_LOG (ERR ,EAL ,"The callback is already exist, no need " "to register again.\n" ); + event_cb =NULL ; ret = -EEXIST ; + goto error; }rte_spinlock_unlock (&dev_event_lock);
Signature · 1 line
2.23.0
Re: [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure
In reply to wangyunjianQuoted 8 lines · wangyunjian
From: Yunjian Wang <[email protected]>
Fix return value, using
-EAGAINinstead of 0 when the callback is busy and using-ENOENTinstead of 0 when the callback is not found.Fixes a753e53d517b ("eal: add device event monitor framework")
This API is experimental, its description is vague enough and we can change it in the current release.
But I see this as a change in behavior for existing users, not a fix and I would not backport it.
Opinions?
Quoted 31 lines
Signed-off-by Yunjian Wang <[email protected]>Acked-by Jeff Guo <[email protected]>--- lib/librte_eal/common/eal_common_dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)lib/librte_eal/common/eal_common_dev.c +7
-2@@ -530,9 +530,15 @@ rte_dev_event_callback_unregister(const char *device_name,free (event_cb); ret++; }else { -continue ; + ret = -EAGAIN ; +break ; } } + +/* this callback is not be registered */ +if (ret ==0 ) + ret = -ENOENT ; +rte_spinlock_unlock (&dev_event_lock);return ret; } --2.23.0
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when callback exists
In reply to wangyunjianQuoted 7 lines · wangyunjian
From: Yunjian Wang <[email protected]>
We should return an error value, when the callback is already exist.
Fixes a753e53d517b ("eal: add device event monitor framework")
Same question as for the previous patch, should we backport this?
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure
In reply to David MarchandQuoted 21 lines
-----Original Message-----
From: David Marchand [mailto:[email protected]]
Sent: Thursday, October 22, 2020 8:52 PM
To: wangyunjian <[email protected]>
Cc: dev <[email protected]>; Jeff Guo <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Lilijun (Jerry) <[email protected]>; xudingke <[email protected]>; dpdk stable <[email protected]>; Kevin Traynor <[email protected]>; Luca Boccassi <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v5 2/3] eal: return error code when failureQuoted 8 lines · wangyunjian
From: Yunjian Wang <[email protected]>
Fix return value, using
-EAGAINinstead of 0 when the callback is busy and using-ENOENTinstead of 0 when the callback is not found.Fixes a753e53d517b ("eal: add device event monitor framework")
Quoted 6 lines
This API is experimental, its description is vague enough and we can change it in the current release.
But I see this as a change in behavior for existing users, not a fix and I would not backport it.Opinions?
Agree, not backport it.
Yunjian
Quoted 39 lines
lib/librte_eal/common/eal_common_dev.c rte_dev_event_callback_unregister(const char
Quoted 15 lines
Signed-off-by Yunjian Wang <[email protected]>Acked-by Jeff Guo <[email protected]>--- lib/librte_eal/common/eal_common_dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)lib/librte_eal/common/eal_common_dev.c +0
-0@@ -530,9 +530,15 @@ rte_dev_event_callback_unregister(const char
*device_name,Quoted 17 lines
lib/librte_eal/common/eal_common_dev.c +7
-2free (event_cb); ret++; }else { -continue ; + ret = -EAGAIN ; +break ; } } + +/* this callback is not be registered */ +if (ret ==0 ) + ret = -ENOENT ; +rte_spinlock_unlock (&dev_event_lock);return ret; } --Quoted 2 lines
2.23.0
--
David Marchand
Re: [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when callback exists
In reply to David MarchandQuoted 14 lines
-----Original Message-----
From: David Marchand [mailto:[email protected]]
Sent: Thursday, October 22, 2020 8:55 PM
To: wangyunjian <[email protected]>
Cc: dev <[email protected]>; Jeff Guo <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Lilijun (Jerry) <[email protected]>; xudingke <[email protected]>; dpdk stable <[email protected]>; Kevin Traynor <[email protected]>; Luca Boccassi <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when callback existsQuoted 1 line · wangyunjian
Quoted 8 lines
Quoted 6 lines
From: Yunjian Wang <[email protected]>
We should return an error value, when the callback is already exist.
Fixes a753e53d517b ("eal: add device event monitor framework")Same question as for the previous patch, should we backport this?
Agree, not backport it.
Yunjian
Quoted 4 lines
--
David Marchand
Quoted 4 lines · wangyunjian
From: Yunjian Wang <[email protected]>
This series include three fixes patches for device event.
For the series,
Applied, thanks.
Signature · 1 line
David Marchand