[srslte-users] srslte thread priorities and thread name

J Giovatto jgiovatto at adjacentlink.com
Thu Aug 2 15:33:40 UTC 2018


Hi,

While trying to scale up we've been paying attention to thread
priorities and which thread they pertain to try to

prevent priority inversions etc.

Looking a the code it looks like all rt_priority calls use the threads
wrapper.

Here I found 2 direct pthread_create method calls with are SCHED_OTHER
but might be considered for rt_priority (I'm not sure).

"lib/src/phy/phch/pdsch.c"
"lib/include/srslte/common/timeout.h"

I added some code to display the cpu affinity and thread policy/priority


--- a/lib/src/common/threads.c
+++ b/lib/src/common/threads.c
@@ -97,6 +96,9 @@ bool threads_new_rt_cpu(pthread_t *thread, void
*(*start_routine) (void*), void
     }
     attr_enable = true;
   }
+
+  printf("%s XXX cpu set to %d\n", __func__, cpu);
+
   if(cpu > 0) {
     if(cpu > 50) {
       int mask;
@@ -118,11 +120,25 @@ bool threads_new_rt_cpu(pthread_t *thread, void
*(*start_routine) (void*), void
     }
   }
 
-  int err = srslte_pthread_create(thread, attr_enable ? &attr : NULL,
start_routine, arg);
+  if(attr_enable)
+    {
+      int policy = 0;
+
+      struct sched_param sp = {0};
+
+      pthread_attr_getschedpolicy(&attr, &policy);
+
+      pthread_attr_getschedparam(&attr, &sp);
+
+      printf("%s XXX create thread with policy %d, priority %d\n",
__func__, policy, sp.sched_priority);
+    }
+
+
+  int err = pthread_create(thread, attr_enable ? &attr : NULL,
start_routine, arg);

[jgiovatto at patty src]$ sudo ./srsenb ./enb.conf | grep XXX
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 39
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 39
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 0, priority 0
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 99
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 19
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 98
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 34
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 34
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 34
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 34
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 34

[jgiovatto at patty 2]$ sudo ../srsue ./ue.conf | grep XXX
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 44
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 0, priority 0
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 39
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 39
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 39
threads_new_rt_cpu XXX cpu set to -100
threads_new_rt_cpu XXX create thread with policy 1, priority 99
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 34
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 98
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 0, priority 0

Network attach successful. IP: 172.16.0.7
threads_new_rt_cpu XXX cpu set to -1
threads_new_rt_cpu XXX create thread with policy 1, priority 92

Can you share some of the criteria you have been using to determine the
priorities ?

Also there is support for a thread name attribute, though Im not sure
how portable it is.

Would you consider this to be something that would be useful ?

 *int pthread_setname_np(pthread_t */thread/*, const char **/name/*);*
 *int pthread_getname_np(pthread_t */thread/*,* *char **/name/*, size_t */len/*);*

Thanks

Joe


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.softwareradiosystems.com/pipermail/srslte-users/attachments/20180802/24826f88/attachment.html>


More information about the srslte-users mailing list