diff options
author | Jere Leppänen <jere.leppanen@nokia.com> | 2023-01-17 19:55:00 +0200 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2023-02-20 12:19:27 +0200 |
commit | f7e4f55269092b8cd569d8b6ed9455b7080ff611 (patch) | |
tree | c0b649902439e0f5179c0edf51d048b73867f5fc | |
parent | 14f8e6637e973d20b8be3fd587c66595d5788dcc (diff) |
linux-gen: sched: add power saving config file options
Add power saving config file options poll_time and sleep_time.
Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Matias Elo <matias.elo@nokia.com>
-rw-r--r-- | config/odp-linux-generic.conf | 28 | ||||
-rw-r--r-- | platform/linux-generic/m4/odp_libconfig.m4 | 2 | ||||
-rw-r--r-- | platform/linux-generic/odp_schedule_basic.c | 25 | ||||
-rw-r--r-- | platform/linux-generic/test/inline-timer.conf | 2 | ||||
-rw-r--r-- | platform/linux-generic/test/packet_align.conf | 2 | ||||
-rw-r--r-- | platform/linux-generic/test/process-mode.conf | 2 | ||||
-rw-r--r-- | platform/linux-generic/test/sched-basic.conf | 2 | ||||
-rw-r--r-- | platform/linux-generic/test/stash-custom.conf | 2 |
8 files changed, 58 insertions, 7 deletions
diff --git a/config/odp-linux-generic.conf b/config/odp-linux-generic.conf index df5328d1f..142a205d0 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.25" +config_file_version = "0.1.26" # System options system: { @@ -243,6 +243,32 @@ sched_basic: { # > 0, events may be dropped by the implementation if the target queue # is full. To prevent this set 'order_stash_size' to 0. order_stash_size = 512 + + # Power saving options for schedule with wait + # + # When waiting for events during a schedule call, save power by + # sleeping in the poll loop. First, run schedule loop normally for + # poll_time_nsec nanoseconds. If there are no events to schedule in that + # time, continue polling, but sleep for sleep_time_nsec nanoseconds on + # each round. + # + # During sleep, the thread is not polling for packet input or timers. + # Each thread measures time and sleeps independently of other threads. + # + # When using this feature, it may be necessary to decrease + # /proc/<pid>/timerslack_ns, or use a real-time priority. Sleeping may + # have an adverse effect on performance for a short time after sleep. + powersave: { + # Time in nsec to poll before sleeping + # + # <1: Disabled. Never sleep. sleep_time_nsec is ignored. + poll_time_nsec = 0 + + # Time in nsec to sleep + # + # Actual sleep time may vary. + sleep_time_nsec = 0 + } } stash: { diff --git a/platform/linux-generic/m4/odp_libconfig.m4 b/platform/linux-generic/m4/odp_libconfig.m4 index 0d268c935..beb01534b 100644 --- a/platform/linux-generic/m4/odp_libconfig.m4 +++ b/platform/linux-generic/m4/odp_libconfig.m4 @@ -3,7 +3,7 @@ ########################################################################## m4_define([_odp_config_version_generation], [0]) m4_define([_odp_config_version_major], [1]) -m4_define([_odp_config_version_minor], [25]) +m4_define([_odp_config_version_minor], [26]) m4_define([_odp_config_version], [_odp_config_version_generation._odp_config_version_major._odp_config_version_minor]) diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c index 0daca644e..b7ea2fbac 100644 --- a/platform/linux-generic/odp_schedule_basic.c +++ b/platform/linux-generic/odp_schedule_basic.c @@ -292,6 +292,11 @@ typedef struct { order_context_t order[CONFIG_MAX_SCHED_QUEUES]; + struct { + uint32_t poll_time; + struct timespec sleep_time; + } powersave; + /* Scheduler interface config options (not used in fast path) */ schedule_config_t config_if; uint32_t max_queues; @@ -521,6 +526,26 @@ static int read_config_file(sched_global_t *sched) sched->config_if.group_enable.control = val; _ODP_PRINT(" %s: %i\n", str, val); + str = "sched_basic.powersave.poll_time_nsec"; + if (!_odp_libconfig_lookup_int(str, &val)) { + _ODP_ERR("Config option '%s' not found.\n", str); + return -1; + } + + sched->powersave.poll_time = _ODP_MAX(0, val); + _ODP_PRINT(" %s: %i\n", str, val); + + str = "sched_basic.powersave.sleep_time_nsec"; + if (!_odp_libconfig_lookup_int(str, &val)) { + _ODP_ERR("Config option '%s' not found.\n", str); + return -1; + } + + val = _ODP_MAX(0, val); + sched->powersave.sleep_time.tv_sec = val / 1000000000; + sched->powersave.sleep_time.tv_nsec = val % 1000000000; + _ODP_PRINT(" %s: %i\n", str, val); + _ODP_PRINT(" dynamic load balance: %s\n", sched->load_balance ? "ON" : "OFF"); _ODP_PRINT("\n"); diff --git a/platform/linux-generic/test/inline-timer.conf b/platform/linux-generic/test/inline-timer.conf index 44db4e337..07719aff5 100644 --- a/platform/linux-generic/test/inline-timer.conf +++ b/platform/linux-generic/test/inline-timer.conf @@ -1,6 +1,6 @@ # Mandatory fields odp_implementation = "linux-generic" -config_file_version = "0.1.25" +config_file_version = "0.1.26" timer: { # Enable inline timer implementation diff --git a/platform/linux-generic/test/packet_align.conf b/platform/linux-generic/test/packet_align.conf index 26491bd53..84b5a828b 100644 --- a/platform/linux-generic/test/packet_align.conf +++ b/platform/linux-generic/test/packet_align.conf @@ -1,6 +1,6 @@ # Mandatory fields odp_implementation = "linux-generic" -config_file_version = "0.1.25" +config_file_version = "0.1.26" pool: { pkt: { diff --git a/platform/linux-generic/test/process-mode.conf b/platform/linux-generic/test/process-mode.conf index 2277aabdf..e8f4a2556 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.25" +config_file_version = "0.1.26" # Shared memory options shm: { diff --git a/platform/linux-generic/test/sched-basic.conf b/platform/linux-generic/test/sched-basic.conf index c9f7c79fd..6a7f446b8 100644 --- a/platform/linux-generic/test/sched-basic.conf +++ b/platform/linux-generic/test/sched-basic.conf @@ -1,6 +1,6 @@ # Mandatory fields odp_implementation = "linux-generic" -config_file_version = "0.1.25" +config_file_version = "0.1.26" # Test scheduler with an odd spread value and without dynamic load balance sched_basic: { diff --git a/platform/linux-generic/test/stash-custom.conf b/platform/linux-generic/test/stash-custom.conf index 95af7a259..46228be27 100644 --- a/platform/linux-generic/test/stash-custom.conf +++ b/platform/linux-generic/test/stash-custom.conf @@ -1,6 +1,6 @@ # Mandatory fields odp_implementation = "linux-generic" -config_file_version = "0.1.25" +config_file_version = "0.1.26" # Test overflow safe stash variant stash: { |