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 Apr 25, 2023
1 parent 6683411 commit 1c21dd9
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
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,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 @@ -8439,10 +8447,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
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,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 @@ -1645,6 +1646,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_PROC_SYSCTL
{
.procname = "tainted",
Expand Down

0 comments on commit 1c21dd9

Please sign in to comment.