diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index 3776dc41067b8d8db49fdc377d6fa65aa5bb1c96..07ce9bfdd6def72a6d7fc3d150f4666edfdc1150 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -444,4 +444,42 @@ task_list_t tasks[TASK_MAX]; // Stupid function, kept for compatibility (the parameter is meaningless!!!) } int signal_mask(void) { return 0;} + +void log_scheduler(const char* label) +{ + int policy = sched_getscheduler(0); + struct sched_param param; + if (sched_getparam(0, ¶m) == -1) + { + LOG_E(HW, "sched_getparam: %s\n", strerror(errno)); + abort(); + } + + cpu_set_t cpu_set; + if (sched_getaffinity(0, sizeof(cpu_set), &cpu_set) == -1) + { + LOG_E(HW, "sched_getaffinity: %s\n", strerror(errno)); + abort(); + } + int num_cpus = sysconf(_SC_NPROCESSORS_ONLN); + if (num_cpus < 1) + { + LOG_E(HW, "sysconf(_SC_NPROCESSORS_ONLN): %s\n", strerror(errno)); + abort(); + } + char buffer[num_cpus]; + for (int i = 0; i < num_cpus; i++) + { + buffer[i] = CPU_ISSET(i, &cpu_set) ? 'Y' : '-'; + } + + LOG_A(HW, "Scheduler policy=%d priority=%d affinity=[%d]%.*s label=%s\n", + policy, + param.sched_priority, + num_cpus, + num_cpus, + buffer, + label); } + +} // namespace diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index 0cd25ee23195a688be61ef3642f85e3f3761d5b6..0d7f2e5ebfb8e6159962a7a5f75c59395691de06 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -567,6 +567,8 @@ int timer_remove(long timer_id); int signal_handle(int *end); int signal_mask(void); +void log_scheduler(const char *label); + #ifdef __cplusplus } #endif diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 7ef1281c665b5a5ad54cff3aaf81e12822bd240f..70cdb3197a01c4ee4bdc03fdfa5ede12c7c0d4a5 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -520,7 +520,12 @@ int main ( int argc, char **argv ) }; if (sched_setscheduler( 0, SCHED_RR, ¶m ) == -1 ) { - fprintf(stderr,"error setting scheduler ... are you root?\n"); + fprintf(stderr, "sched_setscheduler: %s\n", strerror(errno)); + return EXIT_FAILURE; + } + if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) + { + fprintf(stderr, "mlockall: %s\n", strerror(errno)); return EXIT_FAILURE; } @@ -726,6 +731,7 @@ int main ( int argc, char **argv ) pthread_mutex_unlock(&sync_mutex); config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS); } + log_scheduler("eNB-main"); create_tasks_mbms(1); // wait for end of program diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 0b95029710d20976e7d7b0737e28a83b771596e9..6aacc7bacc052ab28e8863dbadb9479851bf0833 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -2031,6 +2031,8 @@ void *UE_thread(void *arg) oai_exit=1; } + log_scheduler(__func__); + while (!oai_exit) { if (IS_SOFTMODEM_BASICSIM) while (!(UE->proc.instance_cnt_synch < 0)) { diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index a2b575182b276d4e1522682ad7135b3a25c7bed9..2e4f9710f35c8f8c7dc8e4b55ffbcb8267d33486 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -548,7 +548,12 @@ int main( int argc, char **argv ) { }; if (sched_setscheduler( 0, SCHED_RR, ¶m ) == -1 ) { - fprintf(stderr,"error setting scheduler ... are you root?\n"); + fprintf(stderr, "sched_setscheduler: %s\n", strerror(errno)); + return EXIT_FAILURE; + } + if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) + { + fprintf(stderr, "mlockall: %s\n", strerror(errno)); return EXIT_FAILURE; }