Skip to contentSkip to conversation

ethdev: fix wrong memset

PATCH Applied Yuanhan Liu 5 participants 23 messages Jan 20, 2017 – Jan 30, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethdev: fix wrong memset

Fix an silly error by auto-complete while managing the merge conflicts. It's the eth_dev_data (but not eth_dev) entry should be memset.

Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +1 -1
index 4790faf..61f44e2 100644
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));
 	eth_dev = eth_dev_get(port_id);
 	snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
 	eth_dev->data->port_id = port_id;
Signature · 1 line
1.9.0
#1 lore raw

2017-01-20 16:04, Yuanhan Liu:

Quoted 4 lines

Fix an silly error by auto-complete while managing the merge conflicts. It's the eth_dev_data (but not eth_dev) entry should be memset.

Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")

You should describe the impact on this bug.
It will be helpful for those testing the RC1.

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 2 lines
lib/librte_ether/rte_ethdev.c +1 -1
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

The title should be contain the scope of the bug.
I suggest "fix data reset when allocating port".

#2 lore raw
Quoted 7 lines · Thomas Monjalon

2017-01-20 16:04, Yuanhan Liu:

Quoted 4 lines

Fix an silly error by auto-complete while managing the merge conflicts. It's the eth_dev_data (but not eth_dev) entry should be memset.

Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")

You should describe the impact on this bug.

Honestly, I don't know. I didn't met any issue while testing vhost. Maybe Ferruh knows what might be wrong, since it's him spotted this bug?

Quoted 7 lines

It will be helpful for those testing the RC1.

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 2 lines
lib/librte_ether/rte_ethdev.c +1 -1
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

The title should be contain the scope of the bug.
I suggest "fix data reset when allocating port".

Yeah, that's better. Thanks.

	--yliu
#3 lore raw
Quoted 5 lines · Yuanhan Liu
Quoted 4 lines · Thomas Monjalon

2017-01-20 16:04, Yuanhan Liu:

Quoted 3 lines

Fix an silly error by auto-complete while managing the merge conflicts. It's the eth_dev_data (but not eth_dev) entry should be memset.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")

You should describe the impact on this bug.

Honestly, I don't know. I didn't met any issue while testing vhost. Maybe Ferruh knows what might be wrong, since it's him spotted this bug?

I find this while reading the code, not observed any bug.

Quoted 13 lines
Quoted 8 lines

It will be helpful for those testing the RC1.

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 2 lines
lib/librte_ether/rte_ethdev.c +1 -1
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

The title should be contain the scope of the bug.
I suggest "fix data reset when allocating port".

Yeah, that's better. Thanks.

	--yliu
#4 lore raw
In reply to Yuanhan Liu

2017-01-20 18:34, Yuanhan Liu:

Quoted 15 lines · Thomas Monjalon
Quoted 7 lines

2017-01-20 16:04, Yuanhan Liu:

Quoted 4 lines

Fix an silly error by auto-complete while managing the merge conflicts. It's the eth_dev_data (but not eth_dev) entry should be memset.

Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")

You should describe the impact on this bug.

Honestly, I don't know. I didn't met any issue while testing vhost. Maybe Ferruh knows what might be wrong, since it's him spotted this bug?

Quoted 2 lines

It will be helpful for those testing the RC1.

Quoted 7 lines
Quoted 5 lines

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 2 lines
lib/librte_ether/rte_ethdev.c +1 -1
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

The title should be contain the scope of the bug.
I suggest "fix data reset when allocating port".

Yeah, that's better. Thanks.

Applied, thanks

#5 lore raw
In reply to Yuanhan Liu
Quoted 16 lines · Yuanhan Liu

Fix an silly error by auto-complete while managing the merge conflicts. It's the eth_dev_data (but not eth_dev) entry should be memset.

Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +0 -0
index 4790faf..61f44e2 100644

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 5 lines
lib/librte_ether/rte_ethdev.c +1 -1
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

There were patches sent to fix this.

Quoted 4 lines
lib/librte_ether/rte_ethdev.c +0 -0
 	eth_dev = eth_dev_get(port_id);
 	snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
 	eth_dev->data->port_id = port_id;
#6 lore raw
Quoted 20 lines · Ferruh Yigit
Quoted 19 lines · Yuanhan Liu

Fix an silly error by auto-complete while managing the merge conflicts. It's the eth_dev_data (but not eth_dev) entry should be memset.

Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +0 -0
index 4790faf..61f44e2 100644
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
Quoted 7 lines

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 2 lines
lib/librte_ether/rte_ethdev.c +1 -1
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

Quoted 7 lines
Quoted 6 lines
lib/librte_ether/rte_ethdev.c +0 -0
 	eth_dev = eth_dev_get(port_id);
 	snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
 	eth_dev->data->port_id = port_id;
#7 lore raw
Quoted 27 lines · Ferruh Yigit
Quoted 26 lines · Ferruh Yigit
Quoted 16 lines · Yuanhan Liu

Fix an silly error by auto-complete while managing the merge conflicts. It's the eth_dev_data (but not eth_dev) entry should be memset.

Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +0 -0
index 4790faf..61f44e2 100644

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 5 lines
lib/librte_ether/rte_ethdev.c +1 -1
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

Quoted 4 lines
Quoted 1 line

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

	--yliu
#8 lore raw
Quoted 28 lines · Yuanhan Liu
Quoted 27 lines · Ferruh Yigit
Quoted 26 lines · Ferruh Yigit
Quoted 16 lines · Yuanhan Liu

Fix an silly error by auto-complete while managing the merge conflicts. It's the eth_dev_data (but not eth_dev) entry should be memset.

Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +0 -0
index 4790faf..61f44e2 100644

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 5 lines
lib/librte_ether/rte_ethdev.c +1 -1
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Quoted 3 lines
	--yliu
#9 lore raw
Quoted 34 lines · Ferruh Yigit
Quoted 33 lines · Yuanhan Liu
Quoted 31 lines · Ferruh Yigit
Quoted 20 lines · Ferruh Yigit
Quoted 19 lines · Yuanhan Liu

Fix an silly error by auto-complete while managing the merge conflicts. It's the eth_dev_data (but not eth_dev) entry should be memset.

Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +0 -0
index 4790faf..61f44e2 100644
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
Quoted 7 lines

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 2 lines
lib/librte_ether/rte_ethdev.c +1 -1
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

Quoted 6 lines
Quoted 2 lines

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Yes, it may. However, I doubt that's the typical usage. Besides that, most of virtual PMDs don't support Multipleprocess: git grep shows pcap is the only one that does claim Multipleprocess is supported.

	--yliu
#10 lore raw
Quoted 35 lines · Yuanhan Liu
Quoted 34 lines · Ferruh Yigit
Quoted 33 lines · Yuanhan Liu
Quoted 31 lines · Ferruh Yigit
Quoted 20 lines · Ferruh Yigit
Quoted 19 lines · Yuanhan Liu

Fix an silly error by auto-complete while managing the merge conflicts. It's the eth_dev_data (but not eth_dev) entry should be memset.

Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +0 -0
index 4790faf..61f44e2 100644
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
Quoted 7 lines

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 2 lines
lib/librte_ether/rte_ethdev.c +1 -1
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Yes, it may. However, I doubt that's the typical usage.

But this is a use case, and broken now, and fix is known. Should be fixed I think.

Quoted 3 lines

Besides that,
most of virtual PMDs don't support Multipleprocess: git grep shows pcap is the only one that does claim Multipleprocess is supported.

I guess you searched for NIC feature documentation for this. But as far as I know, all virtual drivers can be used in both primary and secondary process.

Quoted 3 lines
	--yliu
#11 lore raw
Quoted 25 lines · Ferruh Yigit
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 13 lines
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +1 -1
index 4790faf..61f44e2 100644
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

Quoted 4 lines
Quoted 1 line

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Yes, it may. However, I doubt that's the typical usage.

But this is a use case, and broken now,

I thought it was broken since the beginning?

Quoted 1 line

and fix is known.

And there is already a fix?

Quoted 2 lines

Should be
fixed I think.

Sure.

Quoted 6 lines
Quoted 4 lines

Besides that,
most of virtual PMDs don't support Multipleprocess: git grep shows pcap is the only one that does claim Multipleprocess is supported.

I guess you searched for NIC feature documentation for this.

Yes.

Quoted 3 lines

But as far
as I know, all virtual drivers can be used in both primary and secondary process.

Maybe. But it becomes very error-prone to me then when vdev are involved in both primary and secondary process. I don't think current code is (or designed to be) strong enough to support that.

I don't know it's allowed to use hotplug or not in the multiple process model. If yes, I think there would be many ways to break it.

Honestly, the multiple process doesn't look like a good/clean design to me, especially when some piece of code claim to support it while some other doesn't.

So my point was, yes, there is a bug, we should fix it. But it seems that there could be so many bugs if we hugely expand the test coverage of the multiple process feature.

	--yliu
#12 lore raw
Quoted 30 lines · Yuanhan Liu
Quoted 29 lines · Ferruh Yigit
Quoted 29 lines
Quoted 28 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 13 lines
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +1 -1
index 4790faf..61f44e2 100644
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Yes, it may. However, I doubt that's the typical usage.

But this is a use case, and broken now,

I thought it was broken since the beginning?

No, memset(&rte_eth_dev_data[port_id], ...) breaks it.

Quoted 4 lines
Quoted 2 lines

and fix is known.

And there is already a fix?

http://dpdk.org/ml/archives/dev/2017-January/054422.html

Quoted 26 lines
Quoted 3 lines

Should be
fixed I think.

Sure.

Quoted 6 lines
Quoted 4 lines

Besides that,
most of virtual PMDs don't support Multipleprocess: git grep shows pcap is the only one that does claim Multipleprocess is supported.

I guess you searched for NIC feature documentation for this.

Yes.

Quoted 3 lines

But as far
as I know, all virtual drivers can be used in both primary and secondary process.

Maybe. But it becomes very error-prone to me then when vdev are involved in both primary and secondary process. I don't think current code is (or designed to be) strong enough to support that.

I don't know it's allowed to use hotplug or not in the multiple process model. If yes, I think there would be many ways to break it.

Quoted 7 lines

Honestly, the multiple process doesn't look like a good/clean design to me, especially when some piece of code claim to support it while some other doesn't.

So my point was, yes, there is a bug, we should fix it. But it seems that there could be so many bugs if we hugely expand the test coverage of the multiple process feature.

Agreed.

Quoted 3 lines
	--yliu
#13 lore raw
Quoted 31 lines · Ferruh Yigit
Quoted 30 lines · Yuanhan Liu
Quoted 29 lines · Ferruh Yigit
Quoted 29 lines
Quoted 28 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 13 lines
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +1 -1
index 4790faf..61f44e2 100644
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Yes, it may. However, I doubt that's the typical usage.

But this is a use case, and broken now,

I thought it was broken since the beginning?

No, memset(&rte_eth_dev_data[port_id], ...) breaks it.

Oh, you were talking about that particular case Remy's patch meant to fix.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

and fix is known.

And there is already a fix?

http://dpdk.org/ml/archives/dev/2017-January/054422.html

Yes, it should fix that issue. One question: do Remy or you regularly run some multiple process test cases (and with vdev both in primary and secondary process)?

	--yliu
#14 lore raw
Quoted 43 lines · Yuanhan Liu
Quoted 31 lines · Ferruh Yigit
Quoted 30 lines · Yuanhan Liu
Quoted 29 lines · Ferruh Yigit
Quoted 29 lines
Quoted 28 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 13 lines
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +1 -1
index 4790faf..61f44e2 100644
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Yes, it may. However, I doubt that's the typical usage.

But this is a use case, and broken now,

I thought it was broken since the beginning?

No, memset(&rte_eth_dev_data[port_id], ...) breaks it.

Oh, you were talking about that particular case Remy's patch meant to fix.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

and fix is known.

And there is already a fix?

http://dpdk.org/ml/archives/dev/2017-January/054422.html

Yes, it should fix that issue.

Well, few more thoughts: it may fix the crash issue Remy saw, but it looks like more a workaround to me. Basically, if primary and secondary shares a same port id, they should point to same device. Otherwise, primary process may use eth_dev->data for a device A, while the secondary process may use it for another device, as you said, it could be a vdev.

In such case, there is no way we could continue safely. That said, the given patch avoids the total reset of eth_dev->data, while it continues reset the eth_dev->data->name, which is wrong.

So it's not a proper fix.

Again, I think it's more about the usage. If primary starts with a nic device A, while the secondary starts with a nic device B, there is no way they could work well (unless they use different port id).

	--yliu
Quoted 3 lines

One question: do Remy or you regularly
run some multiple process test cases (and with vdev both in primary and secondary process)?

#15 lore raw
Quoted 72 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Yuanhan Liu
Sent: Monday, January 23, 2017 11:56 AM
To: Yigit, Ferruh <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; Horton, Remy <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] ethdev: fix wrong memset

Quoted 43 lines · Yuanhan Liu
Quoted 31 lines · Ferruh Yigit
Quoted 30 lines · Yuanhan Liu
Quoted 29 lines · Ferruh Yigit
Quoted 29 lines
Quoted 28 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 13 lines
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +1 -1
index 4790faf..61f44e2 100644
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Yes, it may. However, I doubt that's the typical usage.

But this is a use case, and broken now,

I thought it was broken since the beginning?

No, memset(&rte_eth_dev_data[port_id], ...) breaks it.

Oh, you were talking about that particular case Remy's patch meant to fix.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

and fix is known.

And there is already a fix?

http://dpdk.org/ml/archives/dev/2017-January/054422.html

Yes, it should fix that issue.

Well, few more thoughts: it may fix the crash issue Remy saw, but it looks like more a workaround to me. Basically, if primary and secondary shares a same port id, they should point to same device. Otherwise, primary process may use eth_dev->data for a device A, while the secondary process may use it for another device, as you said, it could be a vdev.

In such case, there is no way we could continue safely. That said, the given patch avoids the total reset of eth_dev->data, while it continues reset the eth_dev->data->name, which is wrong.

Quoted 6 lines

So it's not a proper fix.

Again, I think it's more about the usage. If primary starts with a nic device A, while the secondary starts with a nic device B, there is no way they could work well (unless they use different port id).

Why not?
I think this is possible.
They just need to be initialized properly,
so each rte_eth_devices[port_id]->data, etc. point to the right place. Konstantin

Quoted 6 lines
	--yliu
Quoted 3 lines

One question: do Remy or you regularly
run some multiple process test cases (and with vdev both in primary and secondary process)?

#16 lore raw
Quoted 65 lines · Konstantin
Quoted 65 lines · Yuanhan Liu
Quoted 43 lines · Ferruh Yigit
Quoted 31 lines · Yuanhan Liu
Quoted 30 lines · Ferruh Yigit
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

lib/librte_ether/rte_ethdev.c struct rte_eth_dev * · line 228

Quoted 13 lines
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +1 -1
index 4790faf..61f44e2 100644
@@ -225,7 +225,7 @@ struct rte_eth_dev *
 		return NULL;
 	}
 
-	memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Yes, it may. However, I doubt that's the typical usage.

But this is a use case, and broken now,

I thought it was broken since the beginning?

No, memset(&rte_eth_dev_data[port_id], ...) breaks it.

Oh, you were talking about that particular case Remy's patch meant to fix.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

and fix is known.

And there is already a fix?

http://dpdk.org/ml/archives/dev/2017-January/054422.html

Yes, it should fix that issue.

Well, few more thoughts: it may fix the crash issue Remy saw, but it looks like more a workaround to me. Basically, if primary and secondary shares a same port id, they should point to same device. Otherwise, primary process may use eth_dev->data for a device A, while the secondary process may use it for another device, as you said, it could be a vdev.

In such case, there is no way we could continue safely. That said, the given patch avoids the total reset of eth_dev->data, while it continues reset the eth_dev->data->name, which is wrong.

So it's not a proper fix.

Quoted 7 lines
Quoted 4 lines

Again, I think it's more about the usage. If primary starts with a nic device A, while the secondary starts with a nic device B, there is no way they could work well (unless they use different port id).

Why not?
I think this is possible.

Yes, it's possible: find another port id if that one is already taken by primary process (or even by secondary process: think that primary process might attatch a port later).

Quoted 2 lines

They just need to be initialized properly,
so each rte_eth_devices[port_id]->data, etc. point to the right place.

My understanding is, as far as they use different port_id, it might be fine. Just not sure it's enough or not.

	--yliu
#17 lore raw
Quoted 88 lines

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Monday, January 23, 2017 12:53 PM
To: Ananyev, Konstantin <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Horton, Remy <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] ethdev: fix wrong memset

Quoted 65 lines · Konstantin
Quoted 65 lines · Yuanhan Liu
Quoted 43 lines · Ferruh Yigit
Quoted 31 lines · Yuanhan Liu
Quoted 30 lines · Ferruh Yigit
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 13 lines

lib/librte_ether/rte_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 4790faf..61f44e2 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -225,7 +225,7 @@ struct rte_eth_dev *
return NULL;
}

- memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+ memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have issues with secondary process.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Yes, it may. However, I doubt that's the typical usage.

But this is a use case, and broken now,

I thought it was broken since the beginning?

No, memset(&rte_eth_dev_data[port_id], ...) breaks it.

Oh, you were talking about that particular case Remy's patch meant to fix.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

and fix is known.

And there is already a fix?

http://dpdk.org/ml/archives/dev/2017-January/054422.html

Yes, it should fix that issue.

Well, few more thoughts: it may fix the crash issue Remy saw, but it looks like more a workaround to me. Basically, if primary and secondary shares a same port id, they should point to same device. Otherwise, primary process may use eth_dev->data for a device A, while the secondary process may use it for another device, as you said, it could be a vdev.

In such case, there is no way we could continue safely. That said, the given patch avoids the total reset of eth_dev->data, while it continues reset the eth_dev->data->name, which is wrong.

So it's not a proper fix.

Quoted 7 lines
Quoted 4 lines

Again, I think it's more about the usage. If primary starts with a nic device A, while the secondary starts with a nic device B, there is no way they could work well (unless they use different port id).

Why not?
I think this is possible.

Yes, it's possible: find another port id if that one is already taken by primary process (or even by secondary process: think that primary process might attatch a port later).

Quoted 5 lines
Quoted 2 lines

They just need to be initialized properly,
so each rte_eth_devices[port_id]->data, etc. point to the right place.

My understanding is, as far as they use different port_id, it might be fine. Just not sure it's enough or not.

As I understand, the main problem is that rte_eth_devices[] is local, while rte_eth_dev_data points to the shared memory array.
And rte_eth_dev_allocate() assumes that if rte_eth_devices[x] is free, then rte_eth_dev_data[port_id] is also free.
Which is wrong in case when primary/secondary processes have different devices attached. Another problem is that inside rte_ethdev.c we manipulate rte_eth_dev_data[] contents without grabbing any lock.
I think it was an attempt to fix that issue in 16.07 timeframe or so,
but I don't remember what happened with that patch.
Konstantin

#18 lore raw
Quoted 102 lines · Konstantin
Quoted 88 lines

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Monday, January 23, 2017 12:53 PM
To: Ananyev, Konstantin <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Horton, Remy <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] ethdev: fix wrong memset

Quoted 65 lines · Konstantin
Quoted 65 lines · Yuanhan Liu
Quoted 43 lines · Ferruh Yigit
Quoted 31 lines · Yuanhan Liu
Quoted 30 lines · Ferruh Yigit
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

lib/librte_ether/rte_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 4790faf..61f44e2 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -225,7 +225,7 @@ struct rte_eth_dev *
return NULL;
}

- memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+ memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have
issues with secondary process.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Yes, it may. However, I doubt that's the typical usage.

But this is a use case, and broken now,

I thought it was broken since the beginning?

No, memset(&rte_eth_dev_data[port_id], ...) breaks it.

Oh, you were talking about that particular case Remy's patch meant to fix.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

and fix is known.

And there is already a fix?

http://dpdk.org/ml/archives/dev/2017-January/054422.html

Yes, it should fix that issue.

Well, few more thoughts: it may fix the crash issue Remy saw, but it looks like more a workaround to me. Basically, if primary and secondary shares a same port id, they should point to same device. Otherwise, primary process may use eth_dev->data for a device A, while the secondary process may use it for another device, as you said, it could be a vdev.

In such case, there is no way we could continue safely. That said, the given patch avoids the total reset of eth_dev->data, while it continues reset the eth_dev->data->name, which is wrong.

So it's not a proper fix.

Quoted 7 lines
Quoted 4 lines

Again, I think it's more about the usage. If primary starts with a nic device A, while the secondary starts with a nic device B, there is no way they could work well (unless they use different port id).

Why not?
I think this is possible.

Yes, it's possible: find another port id if that one is already taken by primary process (or even by secondary process: think that primary process might attatch a port later).

Quoted 5 lines
Quoted 2 lines

They just need to be initialized properly,
so each rte_eth_devices[port_id]->data, etc. point to the right place.

My understanding is, as far as they use different port_id, it might be fine. Just not sure it's enough or not.

As I understand, the main problem is that rte_eth_devices[] is local, while rte_eth_dev_data points to the shared memory array.
And rte_eth_dev_allocate() assumes that if rte_eth_devices[x] is free, then rte_eth_dev_data[port_id] is also free.
Which is wrong in case when primary/secondary processes have different devices attached. Another problem is that inside rte_ethdev.c we manipulate rte_eth_dev_data[] contents without grabbing any lock.

Quoted 2 lines

I think it was an attempt to fix that issue in 16.07 timeframe or so, but I don't remember what happened with that patch.

Same here, I remember this already discussed and even some patches sent, by Reshma if I remember correctly, but I don't remember latest status.

Quoted 5 lines

Konstantin

#19 lore raw
In reply to Ananyev, Konstantin

2017-01-23 13:06, Ananyev, Konstantin:

Quoted 93 lines
Quoted 87 lines

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Monday, January 23, 2017 12:53 PM
To: Ananyev, Konstantin <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Horton, Remy <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] ethdev: fix wrong memset

Quoted 65 lines · Konstantin
Quoted 65 lines · Yuanhan Liu
Quoted 43 lines · Ferruh Yigit
Quoted 31 lines · Yuanhan Liu
Quoted 30 lines · Ferruh Yigit
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

lib/librte_ether/rte_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 4790faf..61f44e2 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -225,7 +225,7 @@ struct rte_eth_dev *
return NULL;
}

- memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->data));
+ memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));

Not directly related to the this issue, but, after fix, this may have
issues with secondary process.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

There were patches sent to fix this.

I mean this one:
http://dpdk.org/ml/archives/dev/2017-January/054422.html

d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") should have fixed it.

Think about case, where secondary process uses a virtual PMD, which does a rte_eth_dev_allocate() call, shouldn't this corrupt primary process device data?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Yes, it may. However, I doubt that's the typical usage.

But this is a use case, and broken now,

I thought it was broken since the beginning?

No, memset(&rte_eth_dev_data[port_id], ...) breaks it.

Oh, you were talking about that particular case Remy's patch meant to fix.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

and fix is known.

And there is already a fix?

http://dpdk.org/ml/archives/dev/2017-January/054422.html

Yes, it should fix that issue.

Well, few more thoughts: it may fix the crash issue Remy saw, but it looks like more a workaround to me. Basically, if primary and secondary shares a same port id, they should point to same device. Otherwise, primary process may use eth_dev->data for a device A, while the secondary process may use it for another device, as you said, it could be a vdev.

In such case, there is no way we could continue safely. That said, the given patch avoids the total reset of eth_dev->data, while it continues reset the eth_dev->data->name, which is wrong.

So it's not a proper fix.

Quoted 7 lines
Quoted 4 lines

Again, I think it's more about the usage. If primary starts with a nic device A, while the secondary starts with a nic device B, there is no way they could work well (unless they use different port id).

Why not?
I think this is possible.

Yes, it's possible: find another port id if that one is already taken by primary process (or even by secondary process: think that primary process might attatch a port later).

Quoted 5 lines
Quoted 2 lines

They just need to be initialized properly,
so each rte_eth_devices[port_id]->data, etc. point to the right place.

My understanding is, as far as they use different port_id, it might be fine. Just not sure it's enough or not.

Quoted 7 lines

As I understand, the main problem is that rte_eth_devices[] is local, while rte_eth_dev_data points to the shared memory array.
And rte_eth_dev_allocate() assumes that if rte_eth_devices[x] is free, then rte_eth_dev_data[port_id] is also free.
Which is wrong in case when primary/secondary processes have different devices attached. Another problem is that inside rte_ethdev.c we manipulate rte_eth_dev_data[] contents without grabbing any lock.

Yes there are a lot of problems with the multiproc mode because it has been implemented as a hack.
We are fixing some cases without figuring the whole picture.

I'll apply the patch from Remy which fixes a case where process creates vdev (local data) and, hopefully, primary does no hotplug of PCI dev.

I'll restart this discussion with a bigger picture of what multiproc is, and what are the issues.

#20 lore raw
Quoted 10 lines · Thomas Monjalon
Quoted 7 lines

As I understand, the main problem is that rte_eth_devices[] is local, while rte_eth_dev_data points to the shared memory array.
And rte_eth_dev_allocate() assumes that if rte_eth_devices[x] is free, then rte_eth_dev_data[port_id] is also free.
Which is wrong in case when primary/secondary processes have different devices attached. Another problem is that inside rte_ethdev.c we manipulate rte_eth_dev_data[] contents without grabbing any lock.

Yes there are a lot of problems with the multiproc mode because it has been implemented as a hack.

Oh, right, "hacky" is the word I intended to say in my last email.

Quoted 1 line

We are fixing some cases without figuring the whole picture.

Agreed.

Quoted 2 lines

I'll apply the patch from Remy which fixes a case where process creates

I would ask you not to apply that. IMO, his patch may have "fixed" a crash he saw, but it doesn't looks like to me it really fixes anything: the driver may reference rte_eth_data belongs to another driver -- things can't be right afterwards.

Quoted 4 lines

vdev (local data) and, hopefully, primary does no hotplug of PCI dev.

I'll restart this discussion with a bigger picture of what multiproc is, and what are the issues.

Great! And I'm keen to know how the multiproc is actually used in real life (and why they don't use multiple thread). Most importantly, does people really care about it? (I fixed few virtio multiproc issues that I know there are some people/companies using it, and I want to know if there are more).

OTOH, an initial idea comes to my mind now is, make the port_id a global id among primary and secondary process:

- same device will get same port id (my patch acertains that)
- different device will get different port id

	--yliu
#21 lore raw

On 28/01/2017 13:14, Yuanhan Liu wrote:
[..]

Quoted 6 lines
Quoted 1 line

I'll apply the patch from Remy which fixes a case where process creates

I would ask you not to apply that. IMO, his patch may have "fixed" a crash he saw, but it doesn't looks like to me it really fixes anything: the driver may reference rte_eth_data belongs to another driver -- things can't be right afterwards.

I've self-NAK'd it as the code path it was aimed at no longer occurrs.

Quoted 8 lines
Quoted 2 lines

I'll restart this discussion with a bigger picture of what multiproc is, and what are the issues.

Great! And I'm keen to know how the multiproc is actually used in real life (and why they don't use multiple thread). Most importantly, does people really care about it? (I fixed few virtio multiproc issues that I know there are some people/companies using it, and I want to know if there are more).

The use-cases I'm coming across are to allow the attaching/detaching of external agents mainly for information-reporting purposes, without having to leave hooks everywhere. In this case main advantage is the relative ease that processes can be hot-plugged in a way threads cannot. I suppose something more heavyweight might be a primary process as a host physical interconnect, with secondary processes being virtual machines - in this case these might be large semi-independent code-bases one does not want in the same process image.

To me the major down-side with DPDK's multiprocess model is how address-space layout randomisation can trip things up. I know parts of the code seems ASLR-safe, but I very much doubt all of it is.

..Remy

#22 lore raw
In reply to Yuanhan Liu

On 23/01/2017 11:56, Yuanhan Liu wrote:
[..]

Quoted 11 lines
Quoted 3 lines
Quoted 1 line

http://dpdk.org/ml/archives/dev/2017-January/054422.html

Yes, it should fix that issue.

Well, few more thoughts: it may fix the crash issue Remy saw, but it looks like more a workaround to me. Basically, if primary and secondary shares a same port id, they should point to same device. Otherwise, primary process may use eth_dev->data for a device A, while the secondary process may use it for another device, as you said, it could be a vdev.

Quoted 3 lines

In such case, there is no way we could continue safely. That said, the given patch avoids the total reset of eth_dev->data, while it continues reset the eth_dev->data->name, which is wrong.

I did wonder whether 7f95f78a8aea ought to be rolled back rather than the memset being made process-conditional. You going to be fixing the issue in your own patch?

Quoted 3 lines
Quoted 3 lines

One question: do Remy or you regularly
run some multiple process test cases (and with vdev both in primary and secondary process)?

Not aware of there being any multiproc-related unit tests.

..Remy