Skip to content

Commit

Permalink
SUNLIGHT: SCHED: BORE - CPU scheduler v6.12
Browse files Browse the repository at this point in the history
Description:
 - SCHED: BORE - CPU scheduler v6.12
   BORE(Burst-Oriented Response Enhancer)
   5.7.14

Bug: N/A
Change-Id: Ied9db2be71f71fb850c2dc175cd7b7172759c5c4
Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
  • Loading branch information
ionutnechita committed Dec 25, 2024
1 parent 8537539 commit eba8879
Show file tree
Hide file tree
Showing 11 changed files with 667 additions and 5 deletions.
17 changes: 17 additions & 0 deletions include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,14 @@ struct sched_statistics {
#endif /* CONFIG_SCHEDSTATS */
} ____cacheline_aligned;

#ifdef CONFIG_SCHED_BORE
struct sched_burst_cache {
u8 score;
u32 count;
u64 timestamp;
};
#endif // CONFIG_SCHED_BORE

struct sched_entity {
/* For load-balancing: */
struct load_weight load;
Expand All @@ -561,6 +569,15 @@ struct sched_entity {
u64 sum_exec_runtime;
u64 prev_sum_exec_runtime;
u64 vruntime;
#ifdef CONFIG_SCHED_BORE
u64 burst_time;
u8 prev_burst_penalty;
u8 curr_burst_penalty;
u8 burst_penalty;
u8 burst_score;
struct sched_burst_cache child_burst;
struct sched_burst_cache group_burst;
#endif // CONFIG_SCHED_BORE
s64 vlag;
u64 slice;

Expand Down
40 changes: 40 additions & 0 deletions include/linux/sched/bore.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

#include <linux/sched.h>
#include <linux/sched/cputime.h>

#ifndef _LINUX_SCHED_BORE_H
#define _LINUX_SCHED_BORE_H
#define SCHED_BORE_VERSION "5.7.14"

#ifdef CONFIG_SCHED_BORE
extern u8 __read_mostly sched_bore;
extern u8 __read_mostly sched_burst_exclude_kthreads;
extern u8 __read_mostly sched_burst_smoothness_long;
extern u8 __read_mostly sched_burst_smoothness_short;
extern u8 __read_mostly sched_burst_fork_atavistic;
extern u8 __read_mostly sched_burst_parity_threshold;
extern u8 __read_mostly sched_burst_penalty_offset;
extern uint __read_mostly sched_burst_penalty_scale;
extern uint __read_mostly sched_burst_cache_stop_count;
extern uint __read_mostly sched_burst_cache_lifetime;
extern uint __read_mostly sched_deadline_boost_mask;

extern void update_burst_score(struct sched_entity *se);
extern void update_burst_penalty(struct sched_entity *se);

extern void restart_burst(struct sched_entity *se);
extern void restart_burst_rescale_deadline(struct sched_entity *se);

extern int sched_bore_update_handler(const struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos);

extern void sched_clone_bore(
struct task_struct *p, struct task_struct *parent, u64 clone_flags);

extern void init_task_bore(struct task_struct *p);
extern void sched_bore_init(void);

extern void reweight_entity(
struct cfs_rq *cfs_rq, struct sched_entity *se, unsigned long weight);
#endif // CONFIG_SCHED_BORE
#endif // _LINUX_SCHED_BORE_H
17 changes: 17 additions & 0 deletions init/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,23 @@ config CHECKPOINT_RESTORE

If unsure, say N here.

config SCHED_BORE
bool "Burst-Oriented Response Enhancer"
default y
help
In Desktop and Mobile computing, one might prefer interactive
tasks to keep responsive no matter what they run in the background.

Enabling this kernel feature modifies the scheduler to discriminate
tasks by their burst time (runtime since it last went sleeping or
yielding state) and prioritize those that run less bursty.
Such tasks usually include window compositor, widgets backend,
terminal emulator, video playback, games and so on.
With a little impact to scheduling fairness, it may improve
responsiveness especially under heavy background workload.

If unsure, say Y here.

config SCHED_AUTOGROUP
bool "Automatic process group scheduling"
select CGROUPS
Expand Down
17 changes: 17 additions & 0 deletions kernel/Kconfig.hz
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,22 @@ config HZ
default 858 if HZ_858
default 1000 if HZ_1000

config MIN_BASE_SLICE_NS
int "Default value for min_base_slice_ns"
default 2000000
help
The BORE Scheduler automatically calculates the optimal base
slice for the configured HZ using the following equation:

base_slice_ns =
1000000000/HZ * DIV_ROUNDUP(min_base_slice_ns, 1000000000/HZ)

This option sets the default lower bound limit of the base slice
to prevent the loss of task throughput due to overscheduling.

Setting this value too high can cause the system to boot with
an unnecessarily large base slice, resulting in high scheduling
latency and poor system responsiveness.

config SCHED_HRTICK
def_bool HIGH_RES_TIMERS
5 changes: 5 additions & 0 deletions kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>

#include <linux/sched/bore.h>

#include <trace/events/sched.h>

#define CREATE_TRACE_POINTS
Expand Down Expand Up @@ -2386,6 +2388,9 @@ __latent_entropy struct task_struct *copy_process(
retval = sched_fork(clone_flags, p);
if (retval)
goto bad_fork_cleanup_policy;
#ifdef CONFIG_SCHED_BORE
sched_clone_bore(p, current, clone_flags);
#endif // CONFIG_SCHED_BORE

retval = perf_event_init_task(p, clone_flags);
if (retval)
Expand Down
1 change: 1 addition & 0 deletions kernel/sched/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ obj-y += build_policy.o
obj-y += build_utility.o
obj-$(CONFIG_ANDROID_VENDOR_HOOKS) += vendor_hooks.o
obj-$(CONFIG_SCHED_RT_INVARIANT_TEST) += test_ksched_football.o
obj-y += bore.o
Loading

0 comments on commit eba8879

Please sign in to comment.