summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Kotucek <pkotucek@cisco.com>2016-09-23 08:54:14 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2016-09-27 19:35:24 +0000
commitc08a1ed69639a7ee0579c6e41f8e21f8fc595530 (patch)
treef69fd1b7e56136d2b950fe0b001b7148e811e6d2
parentaf405f77c74d8b41523d4e7f39a91c7aec2fd93c (diff)
Scheduler policy & priority config, few minor fixes (VPP-425)
- scheduler-prio -> scheduler-priority - improve formatting of "show threads" output - add description to "startup.conf" - bail out of priority is set without rr or fifo policy Change-Id: Idf897f7603d989d6c2d0093eea89c5d1653eaa8c Signed-off-by: Pavel Kotucek <pkotucek@cisco.com>
-rw-r--r--vlib/vlib/threads.c14
-rw-r--r--vlib/vlib/threads_cli.c27
-rw-r--r--vpp/conf/startup.conf10
3 files changed, 31 insertions, 20 deletions
diff --git a/vlib/vlib/threads.c b/vlib/vlib/threads.c
index 67c57a60f41..e371699f1d4 100644
--- a/vlib/vlib/threads.c
+++ b/vlib/vlib/threads.c
@@ -1093,7 +1093,7 @@ cpu_config (vlib_main_t * vm, unformat_input_t * input)
(input, "scheduler-policy %U", unformat_sched_policy,
&tm->sched_policy))
;
- else if (unformat (input, "scheduler-prio %u", &tm->sched_priority))
+ else if (unformat (input, "scheduler-priority %u", &tm->sched_priority))
;
else if (unformat (input, "%s %u", &name, &count))
{
@@ -1111,10 +1111,9 @@ cpu_config (vlib_main_t * vm, unformat_input_t * input)
break;
}
- if (tm->sched_policy != ~0)
+ if (tm->sched_priority != ~0)
{
- if (tm->sched_priority != ~0
- && (tm->sched_policy == SCHED_FIFO || tm->sched_policy == SCHED_RR))
+ if (tm->sched_policy == SCHED_FIFO || tm->sched_policy == SCHED_RR)
{
u32 prio_max = sched_get_priority_max (tm->sched_policy);
u32 prio_min = sched_get_priority_min (tm->sched_policy);
@@ -1124,7 +1123,12 @@ cpu_config (vlib_main_t * vm, unformat_input_t * input)
tm->sched_priority = prio_min;
}
else
- tm->sched_priority = 0;
+ {
+ return clib_error_return
+ (0,
+ "scheduling priority (%d) is not allowed for `normal` scheduling policy",
+ tm->sched_priority);
+ }
}
tr = tm->next;
diff --git a/vlib/vlib/threads_cli.c b/vlib/vlib/threads_cli.c
index 179906ba51b..e788b04b795 100644
--- a/vlib/vlib/threads_cli.c
+++ b/vlib/vlib/threads_cli.c
@@ -19,20 +19,23 @@
#include <vlib/threads.h>
#include <linux/sched.h>
-u8 *
-format_sched_policy (u8 * s, va_list * args)
+static u8 *
+format_sched_policy_and_priority (u8 * s, va_list * args)
{
- u32 i = va_arg (*args, u32);
+ long i = va_arg (*args, long);
+ struct sched_param sched_param;
u8 *t = 0;
- switch (i)
+ switch (sched_getscheduler (i))
{
#define _(v,f,str) case SCHED_POLICY_##f: t = (u8 *) str; break;
foreach_sched_policy
#undef _
}
- s = format (s, "%-6s ", t);
- return s;
+ if (sched_getparam (i, &sched_param) == 0)
+ return format (s, "%s (%d)", t, sched_param.sched_priority);
+ else
+ return format (s, "%s (n/a)", t);
}
static clib_error_t *
@@ -42,8 +45,8 @@ show_threads_fn (vlib_main_t * vm,
vlib_worker_thread_t *w;
int i;
- vlib_cli_output (vm, "%-7s%-20s%-12s%-8s%-7s%-9s%-7s%-7s%-7s%-10s",
- "ID", "Name", "Type", "LWP", "Policy", "Priority",
+ vlib_cli_output (vm, "%-7s%-20s%-12s%-8s%-25s%-7s%-7s%-7s%-10s",
+ "ID", "Name", "Type", "LWP", "Sched Policy (Priority)",
"lcore", "Core", "Socket", "State");
#if !defined(__powerpc64__)
@@ -57,13 +60,7 @@ show_threads_fn (vlib_main_t * vm,
w->name ? w->name : (u8 *) "",
w->registration ? w->registration->name : "", w->lwp);
- line =
- format (line, "%U", format_sched_policy, sched_getscheduler (w->lwp));
-
- struct sched_param sched_param;
- line = format (line, "%8d ",
- (!sched_getparam (w->lwp, &sched_param)) ?
- sched_param.sched_priority : -1);
+ line = format (line, "%-25U", format_sched_policy_and_priority, w->lwp);
#if DPDK==1
int lcore = w->dpdk_lcore_id;
diff --git a/vpp/conf/startup.conf b/vpp/conf/startup.conf
index f9f4690d566..84a026474c9 100644
--- a/vpp/conf/startup.conf
+++ b/vpp/conf/startup.conf
@@ -20,6 +20,16 @@ cpu {
## Set logical CPU core(s) where worker threads are running
## by default there is no worker threads started
# corelist-workers 2-3,18-19
+
+ ## Set scheduling policy and priority of main and worker threads
+
+ ## Scheduling policy options are: other (SCHED_OTHER), batch (SCHED_BATCH)
+ ## idle (SCHED_IDLE), fifo (SCHED_FIFO), rr (SCHED_RR)
+ # scheduler-policy fifo
+
+ ## Scheduling priority is used only for "real-time policies (fifo and rr),
+ ## and has to be in the range of priorities supported for a particular policy
+ # scheduler-priority 50
}
dpdk {