diff options
author | Matias Elo <matias.elo@nokia.com> | 2018-11-13 13:01:26 +0200 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2018-11-23 11:42:26 +0300 |
commit | efb3dc0e6524b32442dc50f5ced9ce1f1d6fd948 (patch) | |
tree | 728102250f7bdaf1064c855bd5469101f30049ce | |
parent | 02b60f6739a3980cab9cd1afca5dcc1fedd84a1e (diff) |
linux-gen: timer: enable inline timer implementation using config file
Add configure option 'timer.inline' for enabling inline timer
implementation.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r-- | config/odp-linux-generic.conf | 14 | ||||
-rw-r--r-- | platform/linux-generic/odp_timer.c | 39 | ||||
-rw-r--r-- | platform/linux-generic/test/process-mode.conf | 2 |
3 files changed, 30 insertions, 25 deletions
diff --git a/config/odp-linux-generic.conf b/config/odp-linux-generic.conf index 2be1fee7c..2ac6c44d4 100644 --- a/config/odp-linux-generic.conf +++ b/config/odp-linux-generic.conf @@ -16,7 +16,7 @@ # Mandatory fields odp_implementation = "linux-generic" -config_file_version = "0.1.4" +config_file_version = "0.1.5" # Shared memory options shm: { @@ -125,3 +125,15 @@ sched_basic: { control = 1 } } + +timer: { + # Use inline timer implementation + # + # By default, timer processing is done in background threads (thread per + # timer pool). With inline implementation timers are processed on worker + # cores instead. When using inline timers the application has to call + # odp_schedule() or odp_queue_deq() to actuate timer processing. + # + # Set to 1 to enable + inline = 0 +} diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 49901ae08..35bb0482a 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -55,6 +55,7 @@ #include <odp/api/time.h> #include <odp/api/plat/time_inlines.h> #include <odp/api/timer.h> +#include <odp_libconfig_internal.h> #include <odp_queue_if.h> #include <odp_timer_internal.h> #include <odp/api/plat/queue_inlines.h> @@ -217,7 +218,7 @@ typedef struct timer_global_t { /* Multiple locks per cache line! */ _odp_atomic_flag_t ODP_ALIGNED_CACHE locks[NUM_LOCKS]; #endif - + odp_bool_t use_inline_timers; } timer_global_t; static timer_global_t *timer_global; @@ -351,22 +352,8 @@ static odp_timer_pool_t timer_pool_new(const char *name, odp_ticketlock_lock(&timer_global->lock); timer_global->timer_pool[tp_idx] = tp; - if (timer_global->num_timer_pools == 1) { - odp_bool_t inline_tim; - - /* - * Whether to run timer pool processing 'inline' (on worker - * cores) or in background threads (thread-per-timerpool). - * - * If the application will use scheduler this flag is set to - * true, otherwise false. This application conveys this - * information via the 'not_used' bits in odp_init_t which are - * passed to odp_global_init(). - */ - inline_tim = !odp_global_ro.init_param.not_used.feat.schedule; - - odp_global_rw->inline_timers = inline_tim; - } + if (timer_global->num_timer_pools == 1) + odp_global_rw->inline_timers = timer_global->use_inline_timers; odp_ticketlock_unlock(&timer_global->lock); if (!odp_global_rw->inline_timers) { @@ -1360,7 +1347,8 @@ void odp_timeout_free(odp_timeout_t tmo) int odp_timer_init_global(const odp_init_t *params) { odp_shm_t shm; - odp_bool_t inline_timers = false; + const char *conf_str; + int val = 0; shm = odp_shm_reserve("_odp_timer", sizeof(timer_global_t), ODP_CACHE_LINE_SIZE, 0); @@ -1385,16 +1373,21 @@ int odp_timer_init_global(const odp_init_t *params) #else ODP_DBG("Using lock-less timer implementation\n"); #endif + conf_str = "timer.inline"; + if (!_odp_libconfig_lookup_int(conf_str, &val)) { + ODP_ERR("Config option '%s' not found.\n", conf_str); + odp_shm_free(shm); + return -1; + } + timer_global->use_inline_timers = val; - if (params) - inline_timers = - !params->not_used.feat.schedule && - !params->not_used.feat.timer; + if (params && params->not_used.feat.timer) + timer_global->use_inline_timers = false; timer_global->time_per_ratelimit_period = odp_time_global_from_ns(timer_global->min_res_ns / 2); - if (!inline_timers) { + if (!timer_global->use_inline_timers) { timer_res_init(); block_sigalarm(); } diff --git a/platform/linux-generic/test/process-mode.conf b/platform/linux-generic/test/process-mode.conf index fffddcc5f..a5ad3f96d 100644 --- a/platform/linux-generic/test/process-mode.conf +++ b/platform/linux-generic/test/process-mode.conf @@ -1,6 +1,6 @@ # Mandatory fields odp_implementation = "linux-generic" -config_file_version = "0.1.4" +config_file_version = "0.1.5" # Shared memory options shm: { |