Skip to contentSkip to conversation

fixes for device event

PATCH Superseded wangyunjian 3 participants 19 messages Jun 3, 2020 – Jul 3, 2020

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover fixes for device event

From: Yunjian Wang <[email protected]>

This series include three fixes patches for device event.

Yunjian Wang (3):
eal: fix memory leak when removing event_cb
eal: fix remove incorrect event_cb
eal: return error code when failure

 lib/librte_eal/common/eal_common_dev.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 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.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
 lib/librte_eal/common/eal_common_dev.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_eal/common/eal_common_dev.c +2 -0
index 9e4f09d..4cfdb80 100644
@@ -526,6 +526,8 @@ 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);
+			if (event_cb->dev_name)
+				free(event_cb->dev_name);
 			free(event_cb);
 			ret++;
 		} else {
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/3 eal: fix remove incorrect event_cb

In reply to wangyunjian

From: Yunjian Wang <[email protected]>

When the device_name is NULL, it will remove the event_cb directly. We need to compare the 'cb_fn' and 'cb_arg' at the same time.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
 lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_dev.c +6 -1
index 4cfdb80..6b465bc 100644
@@ -516,7 +516,12 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)
 				    event_cb->cb_arg != cb_arg))
 					continue;
 			}
-		} else if (device_name != NULL) {
+		} else if (device_name == NULL && event_cb->dev_name == NULL) {
+			if (event_cb->cb_fn != cb_fn ||
+			    (cb_arg != (void *)-1 &&
+			    event_cb->cb_arg != cb_arg))
+				continue;
+		} else {
 			continue;
 		}
 
Signature · 1 line
1.8.3.1
#3 lore raw

Re: [dpdk-dev] [PATCH 2/3] eal: fix remove incorrect event_cb

hi, yunjian

Quoted 18 lines · wangyunjian

From: Yunjian Wang <[email protected]>

When the device_name is NULL, it will remove the event_cb directly. We need to compare the 'cb_fn' and 'cb_arg' at the same time.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
  lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_dev.c +0 -0
index 4cfdb80..6b465bc 100644

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 524

Quoted 10 lines
lib/librte_eal/common/eal_common_dev.c +6 -1
@@ -516,7 +516,12 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)
  				    event_cb->cb_arg != cb_arg))
  					continue;
  			}
-		} else if (device_name != NULL) {
+		} else if (device_name == NULL && event_cb->dev_name == NULL) {
+			if (event_cb->cb_fn != cb_fn ||
+			    (cb_arg != (void *)-1 &&
+			    event_cb->cb_arg != cb_arg))
+				continue;
+		} else {

If we expect flush all event_cb when device_name is NULL, why we should check the cb_fn and cb_arg?

Quoted 3 lines
lib/librte_eal/common/eal_common_dev.c +0 -0
  			continue;
  		}
 
#4 lore raw

Re: [dpdk-dev] [PATCH 2/3] eal: fix remove incorrect event_cb

Quoted 33 lines

-----Original Message-----
From: Jeff Guo [mailto:[email protected]]
Sent: Friday, June 12, 2020 1:56 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Lilijun (Jerry) <[email protected]>; xudingke <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH 2/3] eal: fix remove incorrect event_cb

hi, yunjian

lib/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]>

When the device_name is NULL, it will remove the event_cb directly. We need to compare the 'cb_fn' and 'cb_arg' at the same time.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
  lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_dev.c +0 -0
index 4cfdb80..6b465bc 100644
@@ -516,7 +516,12 @@ static int cmp_dev_name(const struct rte_device

*dev, const void *_name)

Quoted 14 lines

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 524

Quoted 10 lines
lib/librte_eal/common/eal_common_dev.c +6 -1
  				    event_cb->cb_arg != cb_arg))
  					continue;
  			}
-		} else if (device_name != NULL) {
+		} else if (device_name == NULL && event_cb->dev_name == NULL) {
+			if (event_cb->cb_fn != cb_fn ||
+			    (cb_arg != (void *)-1 &&
+			    event_cb->cb_arg != cb_arg))
+				continue;
+		} else {

If we expect flush all event_cb when device_name is NULL, why we should check the cb_fn and cb_arg?

Oh, sorry! My mistake, I am wrong to think that this function is used like rte_intr_callback_register()/rte_intr_callback_unregister().

Please discard it.

Thanks,
Yunjian

Quoted 5 lines
Quoted 5 lines
lib/librte_eal/common/eal_common_dev.c +0 -0
  			continue;
  		}
 
#5 lore raw

PATCH v2 1/1 eal: fix memory leak when removing event_cb

In reply to wangyunjian

From: Yunjian Wang <[email protected]>

The event_cb->dev_name is not freed when freeing event_cb, and this causes a memory leak.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
 lib/librte_eal/common/eal_common_dev.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_eal/common/eal_common_dev.c +2 -0
index 9e4f09d..4cfdb80 100644
@@ -526,6 +526,8 @@ 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);
+			if (event_cb->dev_name)
+				free(event_cb->dev_name);
 			free(event_cb);
 			ret++;
 		} else {
Signature · 1 line
1.8.3.1
#6 lore raw

Re: [dpdk-dev] [PATCH v2] eal: fix memory leak when removing event_cb

hi, yunjian

Quoted 18 lines · wangyunjian

From: Yunjian Wang <[email protected]>

The event_cb->dev_name is not freed when freeing event_cb, and this causes a memory leak.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
  lib/librte_eal/common/eal_common_dev.c | 2 ++
  1 file changed, 2 insertions(+)
lib/librte_eal/common/eal_common_dev.c +0 -0
index 9e4f09d..4cfdb80 100644

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 533

Quoted 8 lines
lib/librte_eal/common/eal_common_dev.c +2 -0
@@ -526,6 +526,8 @@ 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);
+			if (event_cb->dev_name)
+				free(event_cb->dev_name);
  			free(event_cb);
  			ret++;
  		} else {

Could you please to check is there another part need to check memory leak like that, such as in rte_dev_event_callback_register?

#7 lore raw

Re: [dpdk-dev] [PATCH v2] eal: fix memory leak when removing event_cb

Hi, Jeff

Quoted 33 lines

-----Original Message-----
From: Jeff Guo [mailto:[email protected]]
Sent: Thursday, July 2, 2020 5:28 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Lilijun (Jerry) <[email protected]>; xudingke <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] eal: fix memory leak when removing event_cb

hi, yunjian

Quoted 8 lines · wangyunjian

From: Yunjian Wang <[email protected]>

The event_cb->dev_name is not freed when freeing event_cb, and this causes a memory leak.

Fixes a753e53d517b ("eal: add device event monitor framework")

Review

Quoted 6 lines
---
  lib/librte_eal/common/eal_common_dev.c | 2 ++
  1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/lib/librte_eal/common/eal_common_dev.c

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device

Quoted 4 lines

index 9e4f09d..4cfdb80 100644

lib/librte_eal/common/eal_common_dev.c +0 -0
@@ -526,6 +526,8 @@ static int cmp_dev_name(const struct rte_device

*dev, const void *_name)

Quoted 12 lines

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 533

Quoted 8 lines
lib/librte_eal/common/eal_common_dev.c +2 -0
  		 */
  		if (event_cb->active == 0) {
  			TAILQ_REMOVE(&dev_event_cbs, event_cb, next);
+			if (event_cb->dev_name)
+				free(event_cb->dev_name);
  			free(event_cb);
  			ret++;
  		} else {

Could you please to check is there another part need to check memory leak like that, such as in rte_dev_event_callback_register?

Yes, I have checked and find some same problems. I will also fix them.

Thanks,
Yunjian

#8 lore raw

v3 cover fixes for device event

In reply to wangyunjian

From: Yunjian Wang <[email protected]>

v3: modified the format.

This series include two fixes patches for device event.

Yunjian Wang (2):
eal: fix memory leak when removing event_cb
eal: return error code when failure

 lib/librte_eal/common/eal_common_dev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH v3 1/2 eal: fix memory leak when removing event_cb

In reply to wangyunjian

From: Yunjian Wang <[email protected]>

The event_cb->dev_name is not freed when freeing event_cb, and this causes a memory leak.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
 lib/librte_eal/common/eal_common_dev.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_eal/common/eal_common_dev.c +2 -0
index 9e4f09d..4cfdb80 100644
@@ -526,6 +526,8 @@ 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);
+			if (event_cb->dev_name)
+				free(event_cb->dev_name);
 			free(event_cb);
 			ret++;
 		} else {
Signature · 1 line
1.8.3.1
#10 lore raw

Re: [dpdk-dev] [PATCH v3 1/2] eal: fix memory leak when removing event_cb

hi, yunjian

Quoted 18 lines · wangyunjian

From: Yunjian Wang <[email protected]>

The event_cb->dev_name is not freed when freeing event_cb, and this causes a memory leak.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
  lib/librte_eal/common/eal_common_dev.c | 2 ++
  1 file changed, 2 insertions(+)
lib/librte_eal/common/eal_common_dev.c +0 -0
index 9e4f09d..4cfdb80 100644

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 533

Quoted 8 lines
lib/librte_eal/common/eal_common_dev.c +2 -0
@@ -526,6 +526,8 @@ 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);
+			if (event_cb->dev_name)
+				free(event_cb->dev_name);
  			free(event_cb);
  			ret++;
  		} else {

After you check, don't you think the memory leak would not occur in rte_dev_event_callback_register when free event_cb? And if you have find other same problem, suggest to fix it wholly by this good chance. Thanks.

int
rte_dev_event_callback_register(const char *device_name, rte_dev_event_cb_fn cb_fn,
                void *cb_arg)
{

error:
    free(event_cb);
    rte_spinlock_unlock(&dev_event_lock);
    return ret;

}

#11 lore raw

Re: [dpdk-dev] [PATCH v3 1/2] eal: fix memory leak when removing event_cb

Hi, Jeff

Quoted 32 lines

-----Original Message-----
From: Jeff Guo [mailto:[email protected]]
Sent: Friday, July 3, 2020 2:05 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Lilijun (Jerry) <[email protected]>; xudingke <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 1/2] eal: fix memory leak when removing event_cb

hi, yunjian

lib/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]>

The event_cb->dev_name is not freed when freeing event_cb, and this causes a memory leak.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
  lib/librte_eal/common/eal_common_dev.c | 2 ++
  1 file changed, 2 insertions(+)
lib/librte_eal/common/eal_common_dev.c +0 -0
index 9e4f09d..4cfdb80 100644
@@ -526,6 +526,8 @@ static int cmp_dev_name(const struct rte_device

*dev, const void *_name)

Quoted 14 lines

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 533

Quoted 8 lines
lib/librte_eal/common/eal_common_dev.c +2 -0
  		 */
  		if (event_cb->active == 0) {
  			TAILQ_REMOVE(&dev_event_cbs, event_cb, next);
+			if (event_cb->dev_name)
+				free(event_cb->dev_name);
  			free(event_cb);
  			ret++;
  		} else {

After you check, don't you think the memory leak would not occur in rte_dev_event_callback_register when free event_cb? And if you have find other same problem, suggest to fix it wholly by this good chance. Thanks.

Yes, I've confirmed that it's not necessary. The 'event_cb->dev_name' is not allocated memory on error path in rte_dev_event_callback_register(). But I find the return value is wrong, when the callback is already exist, will include it in next version.

The similar bugs I found in other codes will be fixed in another patches.

Thanks,
Yunjian

Quoted 12 lines

int
rte_dev_event_callback_register(const char *device_name,
                rte_dev_event_cb_fn cb_fn, void *cb_arg)
{

error:
    free(event_cb);
    rte_spinlock_unlock(&dev_event_lock);
    return ret;

}

#12 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v3 1/2] eal: fix memory leak when removing event_cb

In reply to wangyunjian
Quoted 19 lines · wangyunjian

From: Yunjian Wang <[email protected]>

The event_cb->dev_name is not freed when freeing event_cb, and this causes a memory leak.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
 lib/librte_eal/common/eal_common_dev.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_eal/common/eal_common_dev.c +0 -0
index 9e4f09d..4cfdb80 100644

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 530

Quoted 5 lines
lib/librte_eal/common/eal_common_dev.c +2 -0
@@ -526,6 +526,8 @@ 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);
+                       if (event_cb->dev_name)
+                               free(event_cb->dev_name);

No need for the check, free handles a NULL pointer just fine.

Please, could you update your series/patches status in patchwork? I am a bit lost at what is superseded or not.

Thanks.

Signature · 1 line
David Marchand
#13 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v3 1/2] eal: fix memory leak when removing event_cb

Quoted 33 lines

-----Original Message-----
From: David Marchand [mailto:[email protected]]
Sent: Friday, July 3, 2020 3:23 PM
To: wangyunjian <[email protected]>
Cc: dev <[email protected]>; Jeff Guo <[email protected]>; Lilijun (Jerry) <[email protected]>; xudingke <[email protected]>; dpdk stable <[email protected]>
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v3 1/2] eal: fix memory leak when removing event_cb

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device

Quoted 20 lines · wangyunjian

From: Yunjian Wang <[email protected]>

The event_cb->dev_name is not freed when freeing event_cb, and this causes a memory leak.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
 lib/librte_eal/common/eal_common_dev.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_eal/common/eal_common_dev.c +0 -0
index 9e4f09d..4cfdb80 100644
@@ -526,6 +526,8 @@ static int cmp_dev_name(const struct rte_device

*dev, const void *_name)

Quoted 8 lines

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name)

Quoted 3 lines
lib/librte_eal/common/eal_common_dev.c +0 -0
                 */
                if (event_cb->active == 0) {
                        TAILQ_REMOVE(&dev_event_cbs, event_cb,

next);

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 530

Quoted 2 lines
lib/librte_eal/common/eal_common_dev.c +2 -0
+                       if (event_cb->dev_name)
+                               free(event_cb->dev_name);

No need for the check, free handles a NULL pointer just fine.

Thanks for your suggestion, will send the v4 later.

Quoted 3 lines

Please, could you update your series/patches status in patchwork? I am a bit lost at what is superseded or not.

My mistake, please discard them.
https://patchwork.dpdk.org/patch/70824/
https://patchwork.dpdk.org/patch/70825/
https://patchwork.dpdk.org/patch/70826/
https://patchwork.dpdk.org/patch/72452/
https://patchwork.dpdk.org/patch/72825/
https://patchwork.dpdk.org/patch/72826/

Thanks,
Yunjian

Quoted 6 lines

Thanks.

--
David Marchand

#14 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v3 1/2] eal: fix memory leak when removing event_cb

Quoted 10 lines · wangyunjian
Quoted 2 lines

Please, could you update your series/patches status in patchwork? I am a bit lost at what is superseded or not.

My mistake, please discard them.
https://patchwork.dpdk.org/patch/70824/
https://patchwork.dpdk.org/patch/70825/
https://patchwork.dpdk.org/patch/70826/
https://patchwork.dpdk.org/patch/72452/
https://patchwork.dpdk.org/patch/72825/
https://patchwork.dpdk.org/patch/72826/

We have been doing this kind of cleanup with Thomas, Ferruh and other maintainers for some time but this does not scale.
We waste time at figuring out which revision of patches is relevant, or a duplicate, or a mistake...

I'll do it this time (again), but please register to patchwork and handle this for your next patches.
Thanks.

Signature · 1 line
David Marchand
#15 lore raw

PATCH v3 2/2 eal: return error code when failure

In reply to wangyunjian

From: 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.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
 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
index 4cfdb80..f8df8d4 100644
@@ -531,9 +531,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
#16 lore raw

PATCH 3/3 eal: return error code when failure

In reply to wangyunjian

From: 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.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
 lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_dev.c +6 -1
index 6b465bc..5f5e333 100644
@@ -536,9 +536,14 @@ 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
Acked-by on v1 3/3
#17 lore raw

Re: [dpdk-dev] [PATCH 3/3] eal: return error code when failure

hi, yunjian

Quoted 18 lines · wangyunjian

From: 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.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
  lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_dev.c +0 -0
index 6b465bc..5f5e333 100644

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 542

Quoted 8 lines
lib/librte_eal/common/eal_common_dev.c +2 -1
@@ -536,9 +536,14 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)
  			free(event_cb);
  			ret++;
  		} else {
-			continue;
+			ret = -EAGAIN;
+			break;
  		}
  	}

Suggest add a blank line here if there will be another version.

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 549

Quoted 7 lines
lib/librte_eal/common/eal_common_dev.c +4 -0
+	/* this callback is not be registered */
+	if (ret == 0)
+		ret = -ENOENT;
+
  	rte_spinlock_unlock(&dev_event_lock);
  	return ret;
  }

Look good and thanks.

#18 lore raw

Re: [dpdk-dev] [PATCH 3/3] eal: return error code when failure

Quoted 31 lines

-----Original Message-----
From: Jeff Guo [mailto:[email protected]]
Sent: Thursday, July 2, 2020 5:19 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Lilijun (Jerry) <[email protected]>; xudingke <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH 3/3] eal: return error code when failure

hi, yunjian

lib/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]>

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.

Fixes a753e53d517b ("eal: add device event monitor framework")
---
  lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_dev.c +0 -0
index 6b465bc..5f5e333 100644
@@ -536,9 +536,14 @@ static int cmp_dev_name(const struct rte_device

*dev, const void *_name)

Quoted 11 lines

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 542

Quoted 8 lines
lib/librte_eal/common/eal_common_dev.c +2 -1
  			free(event_cb);
  			ret++;
  		} else {
-			continue;
+			ret = -EAGAIN;
+			break;
  		}
  	}

Suggest add a blank line here if there will be another version.

Thanks, I will fix it in next version.

Yunjian

Quoted 13 lines

lib/librte_eal/common/eal_common_dev.c static int cmp_dev_name(const struct rte_device *dev, const void *_name) · line 549

Quoted 9 lines
lib/librte_eal/common/eal_common_dev.c +4 -0
+	/* this callback is not be registered */
+	if (ret == 0)
+		ret = -ENOENT;
+
  	rte_spinlock_unlock(&dev_event_lock);
  	return ret;
  }

Look good and thanks.