eal/windows: set pthread affinity

Message ID 20220121001749.458-1-pallavi.kadam@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series eal/windows: set pthread affinity |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Kadam, Pallavi Jan. 21, 2022, 12:17 a.m. UTC
  Sometimes OS tries to switch the core. So, bind the lcore thread
to a fixed core.
Implement affinity call on Windows similar to Linux.

Signed-off-by: Qiao Liu <qiao.liu@intel.com>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
---
 lib/eal/windows/eal.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Narcisa Ana Maria Vasile Jan. 26, 2022, 6:45 a.m. UTC | #1
On Thu, Jan 20, 2022 at 04:17:49PM -0800, Pallavi Kadam wrote:
> Sometimes OS tries to switch the core. So, bind the lcore thread
> to a fixed core.
> Implement affinity call on Windows similar to Linux.
> 
> Signed-off-by: Qiao Liu <qiao.liu@intel.com>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> ---
>  lib/eal/windows/eal.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
> index 67db7f099a..ca3c41aaa7 100644
> --- a/lib/eal/windows/eal.c
> +++ b/lib/eal/windows/eal.c
> @@ -422,6 +422,10 @@ rte_eal_init(int argc, char **argv)
>  		/* create a thread for each lcore */
>  		if (eal_thread_create(&lcore_config[i].thread_id) != 0)
>  			rte_panic("Cannot create thread\n");
> +		ret = pthread_setaffinity_np(lcore_config[i].thread_id,
> +			sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
> +		if (ret != 0)
> +			RTE_LOG(DEBUG, EAL, "Cannot set affinity\n");
>  	}
>  
Acked-by: Narcisa Vasile <navasile@linux.microsoft.com>
  
Menon, Ranjit Jan. 26, 2022, 6:41 p.m. UTC | #2
On 1/20/2022 4:17 PM, Pallavi Kadam wrote:
> Sometimes OS tries to switch the core. So, bind the lcore thread
> to a fixed core.
> Implement affinity call on Windows similar to Linux.
>
> Signed-off-by: Qiao Liu<qiao.liu@intel.com>
> Signed-off-by: Pallavi Kadam<pallavi.kadam@intel.com>
> ---
>   lib/eal/windows/eal.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
> index 67db7f099a..ca3c41aaa7 100644
> --- a/lib/eal/windows/eal.c
> +++ b/lib/eal/windows/eal.c
> @@ -422,6 +422,10 @@ rte_eal_init(int argc, char **argv)
>   		/* create a thread for each lcore */
>   		if (eal_thread_create(&lcore_config[i].thread_id) != 0)
>   			rte_panic("Cannot create thread\n");
> +		ret = pthread_setaffinity_np(lcore_config[i].thread_id,
> +			sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
> +		if (ret != 0)
> +			RTE_LOG(DEBUG, EAL, "Cannot set affinity\n");
>   	}
>   
>   	/* Initialize services so drivers can register services during probe. */

Acked-by: Ranjit Menon <ranjit.menon@intel.com>
  
Tal Shnaiderman Feb. 1, 2022, 6:29 a.m. UTC | #3
> Subject: [PATCH] eal/windows: set pthread affinity
> 
> External email: Use caution opening links or attachments
> 
> 
> Sometimes OS tries to switch the core. So, bind the lcore thread to a fixed
> core.
> Implement affinity call on Windows similar to Linux.
> 
> Signed-off-by: Qiao Liu <qiao.liu@intel.com>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> ---
>  lib/eal/windows/eal.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index
> 67db7f099a..ca3c41aaa7 100644
> --- a/lib/eal/windows/eal.c
> +++ b/lib/eal/windows/eal.c
> @@ -422,6 +422,10 @@ rte_eal_init(int argc, char **argv)
>                 /* create a thread for each lcore */
>                 if (eal_thread_create(&lcore_config[i].thread_id) != 0)
>                         rte_panic("Cannot create thread\n");
> +               ret = pthread_setaffinity_np(lcore_config[i].thread_id,
> +                       sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
> +               if (ret != 0)
> +                       RTE_LOG(DEBUG, EAL, "Cannot set affinity\n");
>         }
> 
>         /* Initialize services so drivers can register services during probe. */
> --
> 2.31.1.windows.1

Acked-by: Tal Shnaiderman <talshn@nvidia.com>
  
Idan Hackmon Feb. 1, 2022, 7:52 a.m. UTC | #4
> Subject: RE: [PATCH] eal/windows: set pthread affinity
> 
> > Subject: [PATCH] eal/windows: set pthread affinity
> >
> > External email: Use caution opening links or attachments
> >
> >
> > Sometimes OS tries to switch the core. So, bind the lcore thread to a
> > fixed core.
> > Implement affinity call on Windows similar to Linux.
> >
> > Signed-off-by: Qiao Liu <qiao.liu@intel.com>
> > Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> > ---
> >  lib/eal/windows/eal.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index
> > 67db7f099a..ca3c41aaa7 100644
> > --- a/lib/eal/windows/eal.c
> > +++ b/lib/eal/windows/eal.c
> > @@ -422,6 +422,10 @@ rte_eal_init(int argc, char **argv)
> >                 /* create a thread for each lcore */
> >                 if (eal_thread_create(&lcore_config[i].thread_id) != 0)
> >                         rte_panic("Cannot create thread\n");
> > +               ret = pthread_setaffinity_np(lcore_config[i].thread_id,
> > +                       sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
> > +               if (ret != 0)
> > +                       RTE_LOG(DEBUG, EAL, "Cannot set affinity\n");
> >         }
> >
> >         /* Initialize services so drivers can register services during
> > probe. */
> > --
> > 2.31.1.windows.1
> 
> Acked-by: Tal Shnaiderman <talshn@nvidia.com>

Tested-by: Idan Hackmon <idanhac@nvidia.com>
  
Thomas Monjalon Feb. 2, 2022, 10:45 p.m. UTC | #5
> > > Sometimes OS tries to switch the core. So, bind the lcore thread to a
> > > fixed core.
> > > Implement affinity call on Windows similar to Linux.
> > >
> > > Signed-off-by: Qiao Liu <qiao.liu@intel.com>
> > > Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> > Acked-by: Tal Shnaiderman <talshn@nvidia.com>
> Tested-by: Idan Hackmon <idanhac@nvidia.com>

Applied, thanks.
  

Patch

diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index 67db7f099a..ca3c41aaa7 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -422,6 +422,10 @@  rte_eal_init(int argc, char **argv)
 		/* create a thread for each lcore */
 		if (eal_thread_create(&lcore_config[i].thread_id) != 0)
 			rte_panic("Cannot create thread\n");
+		ret = pthread_setaffinity_np(lcore_config[i].thread_id,
+			sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+		if (ret != 0)
+			RTE_LOG(DEBUG, EAL, "Cannot set affinity\n");
 	}
 
 	/* Initialize services so drivers can register services during probe. */