Skip to content

Commit

Permalink
XANMOD: sched/core: Add yield_type sysctl to reduce or disable sched_…
Browse files Browse the repository at this point in the history
…yield

[1] hamadmarri/cacule-cpu-scheduler#35

Signed-off-by: Alexandre Frade <kernel@xanmod.org>
  • Loading branch information
xanmod committed Sep 16, 2022
1 parent e72806d commit f3e506a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 14 additions & 1 deletion kernel/sched/core.c
Expand Up @@ -138,6 +138,14 @@ __read_mostly int sysctl_resched_latency_warn_ms = 100;
__read_mostly int sysctl_resched_latency_warn_once = 1;
#endif /* CONFIG_SCHED_DEBUG */

/*
* Choose the yield level that will perform.
* 0: No yield.
* 1: Yield only to better priority/deadline tasks.
* 2: Re-queue current tasks. (default CFS)
*/
__read_mostly int sysctl_sched_yield_type = 0;

/*
* Number of tasks to iterate in a single balance run.
* Limited because this is done with IRQs disabled.
Expand Down Expand Up @@ -8241,10 +8249,15 @@ static void do_sched_yield(void)
struct rq_flags rf;
struct rq *rq;

if (!sysctl_sched_yield_type)
return;

rq = this_rq_lock_irq(&rf);

schedstat_inc(rq->yld_count);
current->sched_class->yield_task(rq);

if (sysctl_sched_yield_type > 1)
current->sched_class->yield_task(rq);

preempt_disable();
rq_unlock_irq(rq, &rf);
Expand Down
10 changes: 10 additions & 0 deletions kernel/sysctl.c
Expand Up @@ -91,6 +91,7 @@ static const int six_hundred_forty_kb = 640 * 1024;
#endif


extern int sysctl_sched_yield_type;
static const int ngroups_max = NGROUPS_MAX;
static const int cap_last_cap = CAP_LAST_CAP;

Expand Down Expand Up @@ -1612,6 +1613,15 @@ static struct ctl_table kern_table[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "yield_type",
.data = &sysctl_sched_yield_type,
.maxlen = sizeof (int),
.mode = 0644,
.proc_handler = proc_dointvec,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_TWO,
},
#ifdef CONFIG_USER_NS
{
.procname = "unprivileged_userns_clone",
Expand Down

0 comments on commit f3e506a

Please sign in to comment.