Skip to contentSkip to conversation

bus/vdev: fix devargs memory leak

PATCH Applied Mingjin Ye 4 participants 8 messages Sep 1, 2023 – Mar 6, 2024

lore
Share & tools
lore

Mingjin Ye

author
#0 lore raw

PATCH 1/1 bus/vdev: fix devargs memory leak

When a device is created by a secondary process, an empty devargs is temporarily generated and bound to it. This causes the device to not be associated with the correct devargs, and the empty devargs are not released when the resource is freed.

This patch fixes the issue by matching the devargs when inserting a device in secondary process.

Fixes dda987315ca2 ("vdev: make virtual bus use its device struct")
Fixes a16040453968 ("eal: extract vdev infra")
---
 drivers/bus/vdev/vdev.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/bus/vdev/vdev.c +21 -1
index 7974b27295..fe39a98a9c 100644
@@ -259,6 +259,22 @@ alloc_devargs(const char *name, const char *args)
 	return devargs;
 }
 
+static struct rte_devargs *
+vdev_devargs_lookup(const char *name)
+{
+	struct rte_devargs *devargs;
+	char dev_name[32];
+
+	RTE_EAL_DEVARGS_FOREACH("vdev", devargs) {
+		devargs->bus->parse(devargs->name, &dev_name);
+		if (strcmp(dev_name, name) == 0) {
+			VDEV_LOG(INFO, "**Devargs matched %s", dev_name);
+			return devargs;
+		}
+	}
+	return NULL;
+}
+
 static int
 insert_vdev(const char *name, const char *args,
 		struct rte_vdev_device **p_dev,
@@ -271,7 +287,11 @@ insert_vdev(const char *name, const char *args,
 	if (name == NULL)
 		return -EINVAL;
 
-	devargs = alloc_devargs(name, args);
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+		devargs = alloc_devargs(name, args);
+	else
+		devargs = vdev_devargs_lookup(name);
+
 	if (!devargs)
 		return -ENOMEM;
 
Signature · 1 line
2.25.1
Tested-by on v1 1/1
#1 lore raw
Quoted 17 lines

-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Friday, September 1, 2023 3:24 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: [PATCH] bus/vdev: fix devargs memory leak

When a device is created by a secondary process, an empty devargs is temporarily generated and bound to it. This causes the device to not be associated with the correct devargs, and the empty devargs are not released when the resource is freed.

This patch fixes the issue by matching the devargs when inserting a device in secondary process.

Quoted 6 lines
Fixes dda987315ca2 ("vdev: make virtual bus use its device struct")
Fixes a16040453968 ("eal: extract vdev infra")

---

#2 lore raw

Hi Anatoly,

Could you please review and provide suggestions if any.

Thanks,
Mingjin

Quoted 34 lines

-----Original Message-----
From: Ling, WeiX <[email protected]>
Sent: Tuesday, September 12, 2023 5:08 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: RE: [PATCH] bus/vdev: fix devargs memory leak

Quoted 17 lines

-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Friday, September 1, 2023 3:24 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: [PATCH] bus/vdev: fix devargs memory leak

When a device is created by a secondary process, an empty devargs is temporarily generated and bound to it. This causes the device to not be associated with the correct devargs, and the empty devargs are not released when the resource is freed.

This patch fixes the issue by matching the devargs when inserting a device in secondary process.

Quoted 6 lines
Fixes dda987315ca2 ("vdev: make virtual bus use its device struct")
Fixes a16040453968 ("eal: extract vdev infra")

---

#3 lore raw

Hi Anatoly,

can you please take a look at this patch.

Thanks,
Mingjin

Quoted 50 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Friday, September 15, 2023 4:56 PM
To: Burakov, Anatoly <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; [email protected]; Ling, WeiX <[email protected]>
Subject: RE: [PATCH] bus/vdev: fix devargs memory leak

Hi Anatoly,

Could you please review and provide suggestions if any.

Thanks,
Mingjin

Quoted 34 lines

-----Original Message-----
From: Ling, WeiX <[email protected]>
Sent: Tuesday, September 12, 2023 5:08 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: RE: [PATCH] bus/vdev: fix devargs memory leak

Quoted 17 lines

-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Friday, September 1, 2023 3:24 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: [PATCH] bus/vdev: fix devargs memory leak

When a device is created by a secondary process, an empty devargs is temporarily generated and bound to it. This causes the device to not be associated with the correct devargs, and the empty devargs are not released when the resource is freed.

This patch fixes the issue by matching the devargs when inserting a device in secondary process.

Quoted 6 lines
Fixes dda987315ca2 ("vdev: make virtual bus use its device struct")
Fixes a16040453968 ("eal: extract vdev infra")

---

#4 lore raw
In reply to Ye, MingjinX

Hi Burakov,

can you please take a look at this patch.

Thanks,
Mingjin

Quoted 34 lines
Quoted 34 lines

-----Original Message-----
From: Ling, WeiX <[email protected]>
Sent: Tuesday, September 12, 2023 5:08 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: RE: [PATCH] bus/vdev: fix devargs memory leak

Quoted 17 lines

-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Friday, September 1, 2023 3:24 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: [PATCH] bus/vdev: fix devargs memory leak

When a device is created by a secondary process, an empty devargs is temporarily generated and bound to it. This causes the device to not be associated with the correct devargs, and the empty devargs are not released when the resource is freed.

This patch fixes the issue by matching the devargs when inserting a device in secondary process.

Quoted 6 lines
Fixes dda987315ca2 ("vdev: make virtual bus use its device struct")
Fixes a16040453968 ("eal: extract vdev infra")

---

#5 lore raw

Hi Burakov,

The patch has been sent for your review for quite some time. Can you please help to take a look and give some feedback? Your prompt response will be appreciated a lot and very helpful for our next step moving forward.

-Mingjin

Quoted 52 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: 2023年11月17日 18:29
To: Ye, MingjinX <[email protected]>; Burakov, Anatoly <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; [email protected]; Ling, WeiX <[email protected]>
Subject: RE: [PATCH] bus/vdev: fix devargs memory leak

Hi Burakov,

can you please take a look at this patch.

Thanks,
Mingjin

Quoted 35 lines
Quoted 35 lines

-----Original Message-----
From: Ling, WeiX <[email protected]>
Sent: Tuesday, September 12, 2023 5:08 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: RE: [PATCH] bus/vdev: fix devargs memory leak

Quoted 17 lines

-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Friday, September 1, 2023 3:24 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: [PATCH] bus/vdev: fix devargs memory leak

When a device is created by a secondary process, an empty devargs is temporarily generated and bound to it. This causes the device to not be associated with the correct devargs, and the empty devargs are not released when the resource is freed.

This patch fixes the issue by matching the devargs when inserting a device in secondary process.

Quoted 7 lines
Fixes dda987315ca2 ("vdev: make virtual bus use its device

struct")

Fixes a16040453968 ("eal: extract vdev infra")

---

Acked-by on v1 1/1
#6 lore raw
In reply to Mingjin Ye
Quoted 8 lines · Mingjin Ye

When a device is created by a secondary process, an empty devargs is temporarily generated and bound to it. This causes the device to not be associated with the correct devargs, and the empty devargs are not released when the resource is freed.

This patch fixes the issue by matching the devargs when inserting a device in secondary process.

Quoted 6 lines
Fixes dda987315ca2 ("vdev: make virtual bus use its device struct")
Fixes a16040453968 ("eal: extract vdev infra")

---

Signature · 2 lines
Thanks,
Anatoly
#7 lore raw
In reply to Mingjin Ye

01/09/2023 09:24, Mingjin Ye:

Quoted 14 lines

When a device is created by a secondary process, an empty devargs is temporarily generated and bound to it. This causes the device to not be associated with the correct devargs, and the empty devargs are not released when the resource is freed.

This patch fixes the issue by matching the devargs when inserting a device in secondary process.

Fixes dda987315ca2 ("vdev: make virtual bus use its device struct")
Fixes a16040453968 ("eal: extract vdev infra")

---

drivers/bus/vdev/vdev.c alloc_devargs(const char *name, const char *args) · line 271

Quoted 10 lines
drivers/bus/vdev/vdev.c +10 -0
+static struct rte_devargs *
+vdev_devargs_lookup(const char *name)
+{
+	struct rte_devargs *devargs;
+	char dev_name[32];
+
+	RTE_EAL_DEVARGS_FOREACH("vdev", devargs) {
+		devargs->bus->parse(devargs->name, &dev_name);
+		if (strcmp(dev_name, name) == 0) {
+			VDEV_LOG(INFO, "**Devargs matched %s", dev_name);

The beginning of the log does not need such attention characters. Removing while merging.

With Acked-by: Anatoly Burakov <[email protected]>

Applied, thanks.