Skip to contentSkip to conversation

eal/windows: set pthread affinity

PATCH Applied Pallavi Kadam 6 participants 6 messages Jan 20, 2022 – Feb 2, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal/windows: set pthread affinity

Sometimes OS tries to switch the core. So, bind the lcore thread to a fixed core.
Implement affinity call on Windows similar to Linux.

---
 lib/eal/windows/eal.c | 4 ++++
 1 file changed, 4 insertions(+)
lib/eal/windows/eal.c +4 -0
index 67db7f099a..ca3c41aaa7 100644
@@ -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. */
Signature · 1 line
2.31.1.windows.1
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Pallavi Kadam

Sometimes OS tries to switch the core. So, bind the lcore thread to a fixed core.
Implement affinity call on Windows similar to Linux.

---
 lib/eal/windows/eal.c | 4 ++++
 1 file changed, 4 insertions(+)
lib/eal/windows/eal.c +0 -0
index 67db7f099a..ca3c41aaa7 100644

lib/eal/windows/eal.c rte_eal_init(int argc, char **argv) · line 430

Quoted 9 lines
lib/eal/windows/eal.c +4 -0
@@ -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 on v1 1/1
#2 lore raw
In reply to Pallavi Kadam
Quoted 15 lines · Pallavi Kadam

Sometimes OS tries to switch the core. So, bind the lcore thread to a fixed core.
Implement affinity call on Windows similar to Linux.

---
  lib/eal/windows/eal.c | 4 ++++
  1 file changed, 4 insertions(+)
lib/eal/windows/eal.c +0 -0
index 67db7f099a..ca3c41aaa7 100644

lib/eal/windows/eal.c rte_eal_init(int argc, char **argv) · line 431

Quoted 10 lines
lib/eal/windows/eal.c +4 -0
@@ -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 on v1 1/1
#3 lore raw
In reply to Pallavi Kadam
Quoted 31 lines

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.

---
 lib/eal/windows/eal.c | 4 ++++
 1 file changed, 4 insertions(+)
lib/eal/windows/eal.c index renamed from lib/eal/windows/eal.c +0 -0

67db7f099a..ca3c41aaa7 100644

lib/eal/windows/eal.c +4 -1
@@ -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. */
--
Quoted 1 line

2.31.1.windows.1

Tested-by
#4 lore raw
Quoted 31 lines

Subject: RE: [PATCH] eal/windows: set pthread affinity

Quoted 29 lines

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.

---
 lib/eal/windows/eal.c | 4 ++++
 1 file changed, 4 insertions(+)
lib/eal/windows/eal.c index renamed from lib/eal/windows/eal.c +0 -0

67db7f099a..ca3c41aaa7 100644

lib/eal/windows/eal.c +4 -0
@@ -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");
        }
 
Quoted 6 lines
Quoted 4 lines
lib/eal/windows/eal.c +0 -0
        /* Initialize services so drivers can register services during

probe. */
--
2.31.1.windows.1