vdpa/mlx5: use master core Id for vhost thread
Subsystems (2)
PATCH 1/1 vdpa/mlx5: use master core Id for vhost thread
With latest rte api, vdpa example failed on vq setup, the api to get event queue of specified core failed.
The api to get event queue needs core id as input, but after commit 67ae5936c4fc36 ("eal: fix lcore accessors for non-EAL threads"), code of "vhost-event" thread to get current core returns -1, an invalid core id.
As vhost thread created on same core of eal master core, this patch uses master core ID as a workaround.
--- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/mlx5/mlx5_vdpa_event.c +1 -1
@@ -55,7 +55,7 @@ mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv)if (priv->eventc)return 0 ; - lcore = (uint32_t )rte_lcore_to_cpu_id (-1 ); + lcore = (uint32_t )rte_get_master_lcore ();if (mlx5_glue->devx_query_eqn (priv->ctx, lcore, &priv->eqn)) { rte_errno = errno;DRV_LOG (ERR ,"Failed to query EQ number %d." , rte_errno);
Signature · 1 line
2.17.1
PATCH 1/1 vdpa/mlx5: use control core Id for vhost thread
With latest rte api, vdpa example failed on vq setup, the api to get event queue of specified core failed.
The api to get event queue needs core id as input, but after commit 67ae5936c4fc36 ("eal: fix lcore accessors for non-EAL threads"), code of "vhost-event" thread to get current core returns -1, an invalid core id.
As vhost thread created on same core of eal control core, this patch uses control core ID as a workaround.
--- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/mlx5/mlx5_vdpa_event.c +1 -1
@@ -55,7 +55,7 @@ mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv)if (priv->eventc)return 0 ; - lcore = (uint32_t )rte_lcore_to_cpu_id (-1 ); + lcore = (uint32_t )rte_get_master_lcore ();if (mlx5_glue->devx_query_eqn (priv->ctx, lcore, &priv->eqn)) { rte_errno = errno;DRV_LOG (ERR ,"Failed to query EQ number %d." , rte_errno);
Signature · 1 line
2.17.1
Quoted 11 lines · Xueming Li
With latest rte api, vdpa example failed on vq setup, the api to get event queue of specified core failed.
The api to get event queue needs core id as input, but after commit
67ae5936c4fc36("eal: fix lcore accessors for non-EAL threads"), code of "vhost-event" thread to get current core returns -1, an invalid core id.As vhost thread created on same core of eal master core, this patch uses master core ID as a workaround.
rte_lcore_to_cpu_id(-1) is supposed to return the current lcore id. As explained in the commitlog of 67ae5936c4fc36, for a non-EAL thread (which has no associated lcore by default) calling this function means lcore_config[-1].core_id.
Did I miss something?
If not, this is not a workaround but a fix.
Quoted 23 lines
Signed-off-by Xueming Li <[email protected]>Acked-by Matan Azrad <[email protected]>--- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/vdpa/mlx5/mlx5_vdpa_event.c +1
-2@@ -55,7 +55,7 @@ mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv)if (priv->eventc)return 0 ; - lcore = (uint32_t )rte_lcore_to_cpu_id (-1 ); + lcore = (uint32_t )rte_get_master_lcore ();if (mlx5_glue->devx_query_eqn (priv->ctx, lcore, &priv->eqn)) { rte_errno = errno;DRV_LOG (ERR ,"Failed to query EQ number %d." , rte_errno); --2.17.1
Signature · 1 line
David Marchand
From: David Marchand
Quoted 11 lines
Quoted 9 lines · Xueming Li
With latest rte api, vdpa example failed on vq setup, the api to get event queue of specified core failed.
The api to get event queue needs core id as input, but after commit
67ae5936c4fc36("eal: fix lcore accessors for non-EAL threads"), code of "vhost-event" thread to get current core returns -1, an invalid core id.
Quoted 7 lines
Quoted 2 lines
As vhost thread created on same core of eal master core, this patch uses master core ID as a workaround.
rte_lcore_to_cpu_id(-1)is supposed to return the current lcore id. As explained in the commitlog of67ae5936c4fc36, for a non-EAL thread (which has no associated lcore by default) calling this function means lcore_config[-1].core_id.
Deosn't lcore mean core?
So, if the private thread run on a core that opened by EAL, Shouldn't the API return the lcore of the private thread core?
Quoted 3 lines
Did I miss something?
If not, this is not a workaround but a fix.
I'm not sure yet.
Quoted 30 lines
Quoted 21 lines
Signed-off-by Xueming Li <[email protected]>Acked-by Matan Azrad <[email protected]>--- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/vdpa/mlx5/mlx5_vdpa_event.c +1
-1@@ -55,7 +55,7 @@ mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv)if (priv->eventc)return 0 ; - lcore = (uint32_t )rte_lcore_to_cpu_id (-1 ); + lcore = (uint32_t )rte_get_master_lcore ();if (mlx5_glue->devx_query_eqn (priv->ctx, lcore, &priv->eqn)) { rte_errno = errno;Quoted 5 lines
DRV_LOG(ERR, "Failed to query EQ number %d.",
rte_errno);
--
2.17.1--
David Marchand
Quoted 18 lines · Matan Azrad
From: David Marchand
Quoted 14 lines
Quoted 11 lines · Xueming Li
With latest rte api, vdpa example failed on vq setup, the api to get event queue of specified core failed.
The api to get event queue needs core id as input, but after commit
67ae5936c4fc36("eal: fix lcore accessors for non-EAL threads"), code of "vhost-event" thread to get current core returns -1, an invalid core id.As vhost thread created on same core of eal master core, this patch uses master core ID as a workaround.
Quoted 6 lines
Quoted 4 lines
rte_lcore_to_cpu_id(-1)is supposed to return the current lcore id. As explained in the commitlog of67ae5936c4fc36, for a non-EAL thread (which has no associated lcore by default) calling this function means lcore_config[-1].core_id.Deosn't lcore mean core?
No.
Quoted 2 lines
So, if the private thread run on a core that opened by EAL, Shouldn't the API return the lcore of the private thread core?
vhost-events is a control thread.
Was it working just by chance and returning 0 before?
Signature · 1 line
David Marchand
From: David Marchand
Quoted 20 lines · Matan Azrad
Quoted 19 lines
From: David Marchand
Quoted 15 lines
Quoted 12 lines · Xueming Li
With latest rte api, vdpa example failed on vq setup, the api to get event queue of specified core failed.
The api to get event queue needs core id as input, but after commit
67ae5936c4fc36("eal: fix lcore accessors for non-EAL threads"), code of "vhost-event" thread to get current core returns -1, an invalid core id.As vhost thread created on same core of eal master core, this patch uses master core ID as a workaround.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
rte_lcore_to_cpu_id(-1)is supposed to return the current lcore id. As explained in the commitlog of67ae5936c4fc36, for a non-EAL thread (which has no associated lcore by default) calling this function means lcore_config[-1].core_id.Deosn't lcore mean core?
No.
So, it may be that we have more than one lcore working on a specific cpu_id? Can you extend here?
Quoted 6 lines
Quoted 3 lines
So, if the private thread run on a core that opened by EAL, Shouldn't the API return the lcore of the private thread core?
vhost-events is a control thread.
Was it working just by chance and returning 0 before?
Probably yes.
Quoted 2 lines
--
David Marchand
Quoted 11 lines · Matan Azrad
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
rte_lcore_to_cpu_id(-1)is supposed to return the current lcore id. As explained in the commitlog of67ae5936c4fc36, for a non-EAL thread (which has no associated lcore by default) calling this function means lcore_config[-1].core_id.Deosn't lcore mean core?
No.
So, it may be that we have more than one lcore working on a specific
cpu_id? Can you extend here?
A control thread is a non-EAL thread.
A non-EAL thread has no lcore associated (unless you call the newly added rte_thread_register API).
Not sure why you need the physical core identifier in the driver.
It is possible that non-EAL threads run on one physical core if you start your application with the right cpuset.
But without checking, you can't make such an assumption.
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
So, if the private thread run on a core that opened by EAL, Shouldn't the API return the lcore of the private thread core?
vhost-events is a control thread.
Was it working just by chance and returning 0 before?Probably yes.
(gdb) info symbol &lcore_config[-1].core_idvfio_cfgs + 444820 in section .bss of /home/dmarchan/git/pub/dpdk.org/build/app/../lib/librte_eal.so.20.0
Please, update the commitlog.
Thanks.
Signature · 1 line
David Marchand
Quoted 17 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, July 28, 2020 3:53 PM
To: Matan Azrad <[email protected]>
Cc: Xueming(Steven) Li <[email protected]>; dev <[email protected]>; Asaf Penso <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] vdpa/mlx5: use master core Id for vhost threadQuoted 5 lines · Matan Azrad
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
rte_lcore_to_cpu_id(-1)is supposed to return the current lcore id. As explained in the commitlog of67ae5936c4fc36, for a non-EAL thread (which has no associated lcore by default) calling this function means lcore_config[-1].core_id.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Deosn't lcore mean core?
No.
So, it may be that we have more than one lcore working on a specific
cpu_id? Can you extend here?A control thread is a non-EAL thread.
Is the default thread a control thread? After eal init, rte_lcore_to_cpu_id(-1) returns 0.
In function rte_ctrl_thread_create(), the new thread is set cpu affinity with control cpu set, bind it same core of default control thread.
Quoted 30 lines
A non-EAL thread has no lcore associated (unless you call the newly added
rte_thread_registerAPI).Not sure why you need the physical core identifier in the driver.
It is possible that non-EAL threads run on one physical core if you start your application with the right cpuset.
But without checking, you can't make such an assumption.Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
So, if the private thread run on a core that opened by EAL, Shouldn't the API return the lcore of the private thread core?
vhost-events is a control thread.
Was it working just by chance and returning 0 before?Probably yes.
(gdb) info symbol &lcore_config[-1].core_id
vfio_cfgs+ 444820 in section .bss of/home/dmarchan/git/pub/dpdk.org/build/app/../lib/librte_eal.so.20.0Please, update the commitlog.
Thanks.--
David Marchand
Hi David
We found that our kernel driver doesn't really need it and we didn't understand the internal API correctly.
We will create v2 as fix to the vdpa code.
Thank you for the review!
Matan
From: Xueming(Steven) Li:
Quoted 62 lines
Quoted 10 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, July 28, 2020 3:53 PM
To: Matan Azrad <[email protected]>
Cc: Xueming(Steven) Li <[email protected]>; dev <[email protected]>; Asaf Penso <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] vdpa/mlx5: use master core Id for vhost threadOn Tue, Jul 28, 2020 at 9:30 AM Matan Azrad <[email protected]>
Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
rte_lcore_to_cpu_id(-1)is supposed to return the current lcore id. As explained in the commitlog of67ae5936c4fc36, for a non-EAL thread (which has no associated lcore by default) calling this function means lcore_config[-1].core_id.Deosn't lcore mean core?
No.
So, it may be that we have more than one lcore working on a specific
cpu_id?Quoted 3 lines
Quoted 1 line
Can you extend here?
A control thread is a non-EAL thread.
Is the default thread a control thread? After eal init,
rte_lcore_to_cpu_id(-1)returns 0.In function
rte_ctrl_thread_create(), the new thread is set cpu affinity with control cpu set, bind it same core of default control thread.Quoted 30 lines
A non-EAL thread has no lcore associated (unless you call the newly added
rte_thread_registerAPI).Not sure why you need the physical core identifier in the driver.
It is possible that non-EAL threads run on one physical core if you start your application with the right cpuset.
But without checking, you can't make such an assumption.Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
So, if the private thread run on a core that opened by EAL, Shouldn't the API return the lcore of the private thread core?
vhost-events is a control thread.
Was it working just by chance and returning 0 before?Probably yes.
(gdb) info symbol &lcore_config[-1].core_id
vfio_cfgs+ 444820 in section .bss of/home/dmarchan/git/pub/dpdk.org/build/app/../lib/librte_eal.so.20.0Please, update the commitlog.
Thanks.--
David Marchand
Quoted 4 lines · Matan Azrad
We found that our kernel driver doesn't really need it and we didn't understand the internal API correctly.
We will create v2 as fix to the vdpa code.
Ok cool.
Quoted 2 lines
Thank you for the review!
No problem, I was scared of a regression in EAL :-).
Signature · 1 line
David Marchand
From internal discussion, we found a misuse of the vector parameter in devx_query_eqn Function, no cpu id is required, I'll come up with another version.
Quoted 39 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xueming Li
Sent: Tuesday, July 28, 2020 2:11 PM
Cc: [email protected]; Asaf Penso <[email protected]>
Subject: [dpdk-dev] [PATCH] vdpa/mlx5: use master core Id for vhost threadWith latest rte api, vdpa example failed on vq setup, the api to get event queue of specified core failed.
The api to get event queue needs core id as input, but after commit
67ae5936c4fc36("eal: fix lcore accessors for non-EAL threads"), code of "vhost- event" thread to get current core returns -1, an invalid core id.As vhost thread created on same core of eal master core, this patch uses master core ID as a workaround.
Signed-off-by Xueming Li <[email protected]>Acked-by Matan Azrad <[email protected]>--- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/vdpa/mlx5/mlx5_vdpa_event.c +1
-1@@ -55,7 +55,7 @@ mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv)if (priv->eventc)return 0 ; - lcore = (uint32_t )rte_lcore_to_cpu_id (-1 ); + lcore = (uint32_t )rte_get_master_lcore ();if (mlx5_glue->devx_query_eqn (priv->ctx, lcore, &priv->eqn)) { rte_errno = errno;
DRV_LOG(ERR, "Failed to query EQ number %d.", rte_errno);
--
2.17.1
PATCH v2 1/1 vdpa/mlx5: fix event queue number query
In reply to Xueming LiWith latest rte api, vdpa example failed on vq setup, the api to get event queue of specified core failed.
After
commit 67ae5936c4fc36 ("eal: fix lcore accessors for non-EAL threads"), code of "vhost-event" thread to get current cpu id returns -1.
On the other hand, internal api devx_query_eqn expects index of event queue vectors, no need to use cpu id. As the doorbell handling thread is per device, it's sufficient to use default event queue.
This patch uses the default id(0) as event queue index.
--- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa_event.c +1 -4
@@ -51,12 +51,9 @@ mlx5_vdpa_event_qp_global_release(struct mlx5_vdpa_priv *priv)static int mlx5_vdpa_event_qp_global_prepare (struct mlx5_vdpa_priv *priv) { -uint32_t lcore; -if (priv->eventc)return 0 ; - lcore = (uint32_t )rte_lcore_to_cpu_id (-1 ); -if (mlx5_glue->devx_query_eqn (priv->ctx, lcore, &priv->eqn)) { +if (mlx5_glue->devx_query_eqn (priv->ctx,0 , &priv->eqn)) { rte_errno = errno;DRV_LOG (ERR ,"Failed to query EQ number %d." , rte_errno);return -1 ;
Signature · 1 line
2.17.1
Re: [dpdk-dev] [v2] vdpa/mlx5: fix event queue number query
Quoted 8 lines · Xueming Li
With latest rte api, vdpa example failed on vq setup, the api to get event queue of specified core failed.
After
commit67ae5936c4fc36("eal: fix lcore accessors for non-EAL threads"), code of "vhost-event" thread to get current cpu id returns -1.
This is how you figured this problem, but the first part of the commitlog gives the impression there is a regression in the EAL. I would prefer it is removed (maybe simply when applying?).
Quoted 10 lines
On the other hand, internal api
devx_query_eqnexpects index of event queue vectors, no need to use cpu id. As the doorbell handling thread is per device, it's sufficient to use default event queue.This patch uses the default id(0) as event queue index.
Fixes 8395927cdfaf ("vdpa/mlx5: prepare HW queues")Signed-off-by Xueming Li <[email protected]>Acked-by Matan Azrad <[email protected]>
Thanks.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [v2] vdpa/mlx5: fix event queue number query
Quoted 15 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, July 28, 2020 8:05 PM
To: Xueming(Steven) Li <[email protected]>
Cc: dev <[email protected]>; [email protected]; Maxime Coquelin <[email protected]>
Subject: Re: [dpdk-dev] [v2] vdpa/mlx5: fix event queue number queryQuoted 4 lines · Xueming Li
With latest rte api, vdpa example failed on vq setup, the api to get event queue of specified core failed.
Quoted 8 lines
Quoted 4 lines
After
commit67ae5936c4fc36("eal: fix lcore accessors for non-EAL threads"), code of "vhost-event" thread to get current cpu id returns -1.This is how you figured this problem, but the first part of the commitlog gives the impression there is a regression in the EAL.
I would prefer it is removed (maybe simply when applying?).
NP, sorry for the confusing.
Quoted 18 lines
Quoted 6 lines
On the other hand, internal api
devx_query_eqnexpects index of event queue vectors, no need to use cpu id. As the doorbell handling thread is per device, it's sufficient to use default event queue.Quoted 6 lines
This patch uses the default id(0) as event queue index.
Fixes 8395927cdfaf ("vdpa/mlx5: prepare HW queues")Signed-off-by Xueming Li <[email protected]>Acked-by Matan Azrad <[email protected]>Thanks.
--
David Marchand
PATCH v3 1/1 vdpa/mlx5: fix event queue number query
In reply to Xueming LiVdpa example failed on vq setup, the api to get event queue of specified core failed.
Internal api devx_query_eqn expects index of event queue vectors, no need to use cpu id. As the doorbell handling thread is per device, it's sufficient to use default event queue.
This patch uses the default id(0) as event queue index.
--- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa_event.c +1 -4
@@ -51,12 +51,9 @@ mlx5_vdpa_event_qp_global_release(struct mlx5_vdpa_priv *priv)static int mlx5_vdpa_event_qp_global_prepare (struct mlx5_vdpa_priv *priv) { -uint32_t lcore; -if (priv->eventc)return 0 ; - lcore = (uint32_t )rte_lcore_to_cpu_id (-1 ); -if (mlx5_glue->devx_query_eqn (priv->ctx, lcore, &priv->eqn)) { +if (mlx5_glue->devx_query_eqn (priv->ctx,0 , &priv->eqn)) { rte_errno = errno;DRV_LOG (ERR ,"Failed to query EQ number %d." , rte_errno);return -1 ;
Signature · 1 line
2.17.1
Re: [dpdk-dev] [v3] vdpa/mlx5: fix event queue number query
Quoted 9 lines · Xueming Li
Vdpa example failed on vq setup, the api to get event queue of specified core failed.
Internal api
devx_query_eqnexpects index of event queue vectors, no need to use cpu id. As the doorbell handling thread is per device, it's sufficient to use default event queue.This patch uses the default id(0) as event queue index.
Quoted 8 lines
Fixes 8395927cdfaf ("vdpa/mlx5: prepare HW queues")Signed-off-by Xueming Li <[email protected]>Acked-by Matan Azrad <[email protected]>--- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Thanks,
Maxime
Maxime Coquelin
AppliedRe: [dpdk-dev] [v3] vdpa/mlx5: fix event queue number query
In reply to Xueming LiQuoted 9 lines · Xueming Li
Vdpa example failed on vq setup, the api to get event queue of specified core failed.
Internal api
devx_query_eqnexpects index of event queue vectors, no need to use cpu id. As the doorbell handling thread is per device, it's sufficient to use default event queue.This patch uses the default id(0) as event queue index.
Quoted 7 lines
Fixes 8395927cdfaf ("vdpa/mlx5: prepare HW queues")Signed-off-by Xueming Li <[email protected]>Acked-by Matan Azrad <[email protected]>--- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Applied to dpdk-next-virtio/master
Thanks,
Maxime