diff --git a/common/utils/system.c b/common/utils/system.c index d8570fe14e..4e332a4ee4 100644 --- a/common/utils/system.c +++ b/common/utils/system.c @@ -326,37 +326,10 @@ void thread_top_init(char *thread_name, } } - -// Block CPU C-states deep sleep -void set_latency_target(void) { - int ret; - static int latency_target_fd=-1; - uint32_t latency_target_value=2; // in microseconds - if (latency_target_fd == -1) { - if ( (latency_target_fd = open("/dev/cpu_dma_latency", O_RDWR)) != -1 ) { - ret = write(latency_target_fd, &latency_target_value, sizeof(latency_target_value)); - if (ret == 0) { - printf("# error setting cpu_dma_latency to %u!: %s\n", latency_target_value, strerror(errno)); - close(latency_target_fd); - latency_target_fd=-1; - return; - } - } - } - if (latency_target_fd != -1) - LOG_I(HW,"# /dev/cpu_dma_latency set to %u us\n", latency_target_value); - else - LOG_E(HW,"Can't set /dev/cpu_dma_latency to %u us\n", latency_target_value); - - // Set CPU frequency to it's maximum - int system_ret = system("for d in /sys/devices/system/cpu/cpu[0-9]*; do cat $d/cpufreq/cpuinfo_max_freq > $d/cpufreq/scaling_min_freq; done"); - if (system_ret == -1) { - LOG_E(HW, "Can't set cpu frequency: [%d] %s\n", errno, strerror(errno)); - return; - } - if (!((WIFEXITED(system_ret)) && (WEXITSTATUS(system_ret) == 0))) { - LOG_E(HW, "Can't set cpu frequency\n"); - } - mlockall(MCL_CURRENT | MCL_FUTURE); - +/* \brief lock memory to RAM to avoid delays */ +void lock_memory_to_ram(void) +{ + int rc = mlockall(MCL_CURRENT | MCL_FUTURE); + if (rc != 0) + LOG_W(UTIL, "mlockall() failed: %d, %s\n", errno, strerror(errno)); } diff --git a/common/utils/system.h b/common/utils/system.h index 1b7c0c570f..1c36f29ea3 100644 --- a/common/utils/system.h +++ b/common/utils/system.h @@ -42,7 +42,7 @@ int background_system(char *command); void start_background_system(void); -void set_latency_target(void); +void lock_memory_to_ram(void); void threadCreate(pthread_t *t, void *(*func)(void *), void *param, char *name, int affinity, int priority); diff --git a/executables/lte-softmodem.c b/executables/lte-softmodem.c index 9e1adf1cbe..615f6106fe 100644 --- a/executables/lte-softmodem.c +++ b/executables/lte-softmodem.c @@ -448,7 +448,7 @@ int main ( int argc, char **argv ) mode = normal_txrx; logInit(); - set_latency_target(); + lock_memory_to_ram(); printf("Reading in command-line options\n"); get_options(uniqCfg); @@ -518,7 +518,6 @@ int main ( int argc, char **argv ) // init UE_PF_PO and mutex lock pthread_mutex_init(&ue_pf_po_mutex, NULL); memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*MAX_MOBILES_PER_ENB*MAX_NUM_CCs); - mlockall(MCL_CURRENT | MCL_FUTURE); pthread_cond_init(&sync_cond,NULL); pthread_mutex_init(&sync_mutex, NULL); diff --git a/executables/lte-uesoftmodem.c b/executables/lte-uesoftmodem.c index a8f6d01227..47f6c884c4 100644 --- a/executables/lte-uesoftmodem.c +++ b/executables/lte-uesoftmodem.c @@ -530,7 +530,7 @@ int main( int argc, char **argv ) { mode = normal_txrx; memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); logInit(); - set_latency_target(); + lock_memory_to_ram(); printf("Reading in command-line options\n"); for (int i=0; i