aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@linaro.org>2018-10-24 15:20:21 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2018-11-06 19:00:44 +0300
commit97eb06b4cd2f57e9033f5d09a5e2b7a7b9d641b9 (patch)
treece150fa81b6b273afbd7ff2808d8347eb7abed8c
parent6c0ffbf9689e36cc94d303d5ac30575fef041cbe (diff)
linux-gen: sched: add spread weight config file option
Add new config file option to control scheduler internal queue preference ratio. Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r--config/odp-linux-generic.conf26
-rw-r--r--platform/linux-generic/odp_schedule_basic.c29
-rw-r--r--platform/linux-generic/test/process-mode.conf2
3 files changed, 45 insertions, 12 deletions
diff --git a/config/odp-linux-generic.conf b/config/odp-linux-generic.conf
index af651d7f6..2417d23f2 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.1"
+config_file_version = "0.1.2"
# Shared memory options
shm: {
@@ -80,13 +80,27 @@ queue_basic: {
}
sched_basic: {
- # Priority level spread. Each priority level is spread into multiple
- # scheduler internal queues. A higher spread value typically improves
- # parallelism and thus is better for high thread counts, but causes
- # uneven service level for low thread counts. Typically, optimal
- # value is the number of threads using the scheduler.
+ # Priority level spread
+ #
+ # Each priority level is spread into multiple scheduler internal queues.
+ # This value defines the number of those queues. Minimum value is 1.
+ # Each thread prefers one of the queues over other queues. A higher
+ # spread value typically improves parallelism and thus is better for
+ # high thread counts, but causes uneven service level for low thread
+ # counts. Typically, optimal value is the number of threads using
+ # the scheduler.
prio_spread = 4
+ # Weight of the preferred scheduler internal queue
+ #
+ # Each thread prefers one of the internal queues over other queues.
+ # This value controls how many times the preferred queue is polled
+ # between a poll to another internal queue. Minimum value is 1. A higher
+ # value typically improves parallelism as threads work mostly on their
+ # preferred queues, but causes uneven service level for low thread
+ # counts as non-preferred queues are served less often
+ prio_spread_weight = 63
+
# Burst size configuration per priority. The first array element
# represents the highest queue priority. The scheduler tries to get
# burst_size_default[prio] events from a queue and stashes those that
diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c
index 58396293b..214d42c8b 100644
--- a/platform/linux-generic/odp_schedule_basic.c
+++ b/platform/linux-generic/odp_schedule_basic.c
@@ -58,10 +58,12 @@ ODP_STATIC_ASSERT((ODP_SCHED_PRIO_NORMAL > 0) &&
/* A thread polls a non preferred sched queue every this many polls
* of the prefer queue. */
-#define PREFER_RATIO 64
+#define MAX_PREFER_WEIGHT 63
+#define MIN_PREFER_WEIGHT 1
+#define MAX_PREFER_RATIO (MAX_PREFER_WEIGHT + 1)
/* Spread weight table */
-#define SPREAD_TBL_SIZE ((MAX_SPREAD - 1) * PREFER_RATIO)
+#define SPREAD_TBL_SIZE ((MAX_SPREAD - 1) * MAX_PREFER_RATIO)
/* Maximum number of packet IO interfaces */
#define NUM_PKTIO ODP_CONFIG_PKTIO_ENTRIES
@@ -182,6 +184,7 @@ typedef struct {
uint8_t burst_default[NUM_PRIO];
uint8_t burst_max[NUM_PRIO];
uint8_t num_spread;
+ uint8_t prefer_ratio;
} config;
uint16_t max_spread;
@@ -256,13 +259,29 @@ static int read_config_file(sched_global_t *sched)
}
if (val > MAX_SPREAD || val < MIN_SPREAD) {
- ODP_ERR("Bad value %s = %u\n", str, val);
+ ODP_ERR("Bad value %s = %u [min: %u, max: %u]\n", str, val,
+ MIN_SPREAD, MAX_SPREAD);
return -1;
}
sched->config.num_spread = val;
ODP_PRINT(" %s: %i\n", str, val);
+ str = "sched_basic.prio_spread_weight";
+ if (!_odp_libconfig_lookup_int(str, &val)) {
+ ODP_ERR("Config option '%s' not found.\n", str);
+ return -1;
+ }
+
+ if (val > MAX_PREFER_WEIGHT || val < MIN_PREFER_WEIGHT) {
+ ODP_ERR("Bad value %s = %u [min: %u, max: %u]\n", str, val,
+ MIN_PREFER_WEIGHT, MAX_PREFER_WEIGHT);
+ return -1;
+ }
+
+ sched->config.prefer_ratio = val + 1;
+ ODP_PRINT(" %s: %i\n", str, val);
+
str = "sched_basic.burst_size_default";
if (_odp_libconfig_lookup_array(str, burst_val, NUM_PRIO) !=
NUM_PRIO) {
@@ -329,7 +348,7 @@ static void sched_local_init(void)
for (i = 0; i < SPREAD_TBL_SIZE; i++) {
sched_local.spread_tbl[i] = spread;
- if (num_spread > 1 && (i % PREFER_RATIO) == 0) {
+ if (num_spread > 1 && (i % MAX_PREFER_RATIO) == 0) {
sched_local.spread_tbl[i] = prio_spread_index(spread +
offset);
offset++;
@@ -364,7 +383,7 @@ static int schedule_init_global(void)
}
/* When num_spread == 1, only spread_tbl[0] is used. */
- sched->max_spread = (sched->config.num_spread - 1) * PREFER_RATIO;
+ sched->max_spread = (sched->config.num_spread - 1) * MAX_PREFER_RATIO;
sched->shm = shm;
odp_spinlock_init(&sched->mask_lock);
diff --git a/platform/linux-generic/test/process-mode.conf b/platform/linux-generic/test/process-mode.conf
index d80df25c4..7a06544ab 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.1"
+config_file_version = "0.1.2"
# Shared memory options
shm: {