Skip to content

Instantly share code, notes, and snippets.

@haller33
Created May 1, 2023 08:46
Show Gist options
  • Save haller33/c0e3dd2732050098886cf2fb1da540a6 to your computer and use it in GitHub Desktop.
Save haller33/c0e3dd2732050098886cf2fb1da540a6 to your computer and use it in GitHub Desktop.
A change on Schedduler of Kernel for better performance
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index daff72f00..857577ea1 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4572,7 +4572,16 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
/*
* Make sure we do not leak PI boosting priority to the child.
*/
- p->prio = current->normal_prio;
+ /// Kernel Config from OS Running get config of existing linux running
+ // # cp /boot/config-`uname -r` .config
+
+ // p->prio = current->normal_prio;
+ /* Lorenzo Nava: force policy to RR */
+ if (p->policy == SCHED_NORMAL) {
+ p->prio = current->normal_prio - NICE_WIDTH -
+ PRIO_TO_NICE(current->static_prio);
+ p->normal_prio = p->prio;
+ p->rt_priority = p->prio;
+ p->policy = SCHED_RR;
+ p->static_prio = NICE_TO_PRIO(0);
+ }
uclamp_fork(p);
@@ -4607,6 +4616,8 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
init_entity_runnable_average(&p->se);
+
+
#ifdef CONFIG_SCHED_INFO
if (likely(sched_info_on()))
memset(&p->sched_info, 0, sizeof(p->sched_info));
@@ -7669,6 +7680,24 @@ static int _sched_setscheduler(struct task_struct *p, int policy,
attr.sched_policy = policy;
}
+ /* Lorenzo Nava: force policy to RR */
+ if (p->policy == SCHED_NORMAL) {
+ p->prio = current->normal_prio - NICE_WIDTH -
+ PRIO_TO_NICE(current->static_prio);
+ p->normal_prio = p->prio;
+ p->rt_priority = p->prio;
+ p->policy = SCHED_RR;
+ p->static_prio = NICE_TO_PRIO(0);
+ }
+
+ /* Lorenzo Nava: force policy of process to RR */
+ if (attr.sched_policy == SCHED_NORMAL) {
+ attr.sched_priority = param->sched_priority -
+ NICE_WIDTH - attr.sched_nice;
+ attr.sched_policy = SCHED_RR;
+ }
+
+
return __sched_setscheduler(p, &attr, check, true);
}
/**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment