diff options
author | Xavier Simonart <xavier.simonart@intel.com> | 2019-08-28 08:34:43 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2019-08-28 08:34:43 +0000 |
commit | 9033cadea78ca28c726323cb8334c7206fe51c22 (patch) | |
tree | 8e353dddb2ea412739cf4f3f7ce2a5333ecf6550 /VNFs/DPPD-PROX/thread_generic.c | |
parent | 3a485129aaebd9190c55fdb91e0a49db2872f543 (diff) | |
parent | 9ada1609d84cc954c9235e6bd056850c10dfccc5 (diff) |
Merge "Add option to change scheduler policy to SCHED_RR and increase scheduler priority"
Diffstat (limited to 'VNFs/DPPD-PROX/thread_generic.c')
-rw-r--r-- | VNFs/DPPD-PROX/thread_generic.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/VNFs/DPPD-PROX/thread_generic.c b/VNFs/DPPD-PROX/thread_generic.c index f596bf25..14fb943e 100644 --- a/VNFs/DPPD-PROX/thread_generic.c +++ b/VNFs/DPPD-PROX/thread_generic.c @@ -14,6 +14,7 @@ // limitations under the License. */ +#include <pthread.h> #include <rte_cycles.h> #include <rte_table_hash.h> @@ -83,6 +84,26 @@ static uint64_t tsc_ctrl(struct lcore_cfg *lconf) return lconf->ctrl_timeout; } +static void set_thread_policy(int policy) +{ + struct sched_param p; + int ret, old_policy, old_priority; + + memset(&p, 0, sizeof(p)); + ret = pthread_getschedparam(pthread_self(), &old_policy, &p); + if (ret) { + plog_err("Failed getting thread policy: %d\n", ret); + return; + } + old_priority = p.sched_priority; + p.sched_priority = sched_get_priority_max(policy); + ret = pthread_setschedparam(pthread_self(), policy, &p); + if (ret) { + plog_err("Failed setting thread priority: %d", ret); + } else + plog_info("Thread policy/priority changed from %d/%d to %d/%d\n", old_policy, old_priority, policy, p.sched_priority); +} + int thread_generic(struct lcore_cfg *lconf) { struct task_base *tasks[MAX_TASKS_PER_CORE]; @@ -99,6 +120,9 @@ int thread_generic(struct lcore_cfg *lconf) }; uint8_t n_tasks_run = lconf->n_tasks_run; + if (lconf->flags & LCONF_FLAG_SCHED_RR) + set_thread_policy(SCHED_RR); + if (lconf->period_func) { tsc_tasks[2].tsc = cur_tsc + lconf->period_timeout; tsc_tasks[2].tsc_task = tsc_period; |