summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX
diff options
context:
space:
mode:
authorXavier Simonart <xavier.simonart@intel.com>2019-06-28 15:47:55 +0200
committerXavier Simonart <xavier.simonart@intel.com>2019-08-28 08:28:08 +0000
commit9ada1609d84cc954c9235e6bd056850c10dfccc5 (patch)
treebe27eea2041420f194d87df7f6c8053e943dbe47 /VNFs/DPPD-PROX
parentcefc6fd66b13e3f3a7b9635a8bd474fd329e1d62 (diff)
Add option to change scheduler policy to SCHED_RR and increase scheduler priority
Set "realtime scheduling=yes" option to change Linux scheduler policy to SCHED_RR and increase the priority to the maximum possible for the policy. Change-Id: I3ecef5cbc3816cf2b56364bb4e806ae5ac093c23 Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX')
-rw-r--r--VNFs/DPPD-PROX/lconf.h1
-rw-r--r--VNFs/DPPD-PROX/prox_args.c3
-rw-r--r--VNFs/DPPD-PROX/thread_generic.c24
3 files changed, 28 insertions, 0 deletions
diff --git a/VNFs/DPPD-PROX/lconf.h b/VNFs/DPPD-PROX/lconf.h
index 4bfa705d..8ac1112e 100644
--- a/VNFs/DPPD-PROX/lconf.h
+++ b/VNFs/DPPD-PROX/lconf.h
@@ -52,6 +52,7 @@ struct lconf_msg {
#define LCONF_FLAG_TX_DISTR_ACTIVE 0x00000004
#define LCONF_FLAG_RX_BW_ACTIVE 0x00000008
#define LCONF_FLAG_TX_BW_ACTIVE 0x00000010
+#define LCONF_FLAG_SCHED_RR 0x00000020
struct lcore_cfg {
/* All tasks running at the moment. This is empty when the core is stopped. */
diff --git a/VNFs/DPPD-PROX/prox_args.c b/VNFs/DPPD-PROX/prox_args.c
index d77eab1a..45996db8 100644
--- a/VNFs/DPPD-PROX/prox_args.c
+++ b/VNFs/DPPD-PROX/prox_args.c
@@ -1262,6 +1262,9 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
return parse_int(&targ->byte_offset, pkey);
}
+ if (STR_EQ(str, "realtime scheduling")) {
+ return parse_flag(&lconf->flags, LCONF_FLAG_SCHED_RR, pkey);
+ }
if (STR_EQ(str, "name")) {
return parse_str(lconf->name, pkey, sizeof(lconf->name));
}
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;