Skip to content

Commit c51398e

Browse files
committed
SUNLIGHT: SCHED: BORE - CPU scheduler v6.12
Description: - SCHED: BORE - CPU scheduler v6.12 BORE(Burst-Oriented Response Enhancer) 5.7.13 Bug: N/A Change-Id: I3b83ed6e543cf93ffddee26c5b133d591e5dd30c Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
1 parent 17770cc commit c51398e

File tree

11 files changed

+665
-5
lines changed

11 files changed

+665
-5
lines changed

include/linux/sched.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,14 @@ struct sched_statistics {
540540
#endif /* CONFIG_SCHEDSTATS */
541541
} ____cacheline_aligned;
542542

543+
#ifdef CONFIG_SCHED_BORE
544+
struct sched_burst_cache {
545+
u8 score;
546+
u32 count;
547+
u64 timestamp;
548+
};
549+
#endif // CONFIG_SCHED_BORE
550+
543551
struct sched_entity {
544552
/* For load-balancing: */
545553
struct load_weight load;
@@ -559,6 +567,15 @@ struct sched_entity {
559567
u64 sum_exec_runtime;
560568
u64 prev_sum_exec_runtime;
561569
u64 vruntime;
570+
#ifdef CONFIG_SCHED_BORE
571+
u64 burst_time;
572+
u8 prev_burst_penalty;
573+
u8 curr_burst_penalty;
574+
u8 burst_penalty;
575+
u8 burst_score;
576+
struct sched_burst_cache child_burst;
577+
struct sched_burst_cache group_burst;
578+
#endif // CONFIG_SCHED_BORE
562579
s64 vlag;
563580
u64 slice;
564581

include/linux/sched/bore.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
#include <linux/sched.h>
3+
#include <linux/sched/cputime.h>
4+
5+
#ifndef _LINUX_SCHED_BORE_H
6+
#define _LINUX_SCHED_BORE_H
7+
#define SCHED_BORE_VERSION "5.7.13"
8+
9+
#ifdef CONFIG_SCHED_BORE
10+
extern u8 __read_mostly sched_bore;
11+
extern u8 __read_mostly sched_burst_exclude_kthreads;
12+
extern u8 __read_mostly sched_burst_smoothness_long;
13+
extern u8 __read_mostly sched_burst_smoothness_short;
14+
extern u8 __read_mostly sched_burst_fork_atavistic;
15+
extern u8 __read_mostly sched_burst_parity_threshold;
16+
extern u8 __read_mostly sched_burst_penalty_offset;
17+
extern uint __read_mostly sched_burst_penalty_scale;
18+
extern uint __read_mostly sched_burst_cache_stop_count;
19+
extern uint __read_mostly sched_burst_cache_lifetime;
20+
extern uint __read_mostly sched_deadline_boost_mask;
21+
22+
extern void update_burst_score(struct sched_entity *se);
23+
extern void update_burst_penalty(struct sched_entity *se);
24+
25+
extern void restart_burst(struct sched_entity *se);
26+
extern void restart_burst_rescale_deadline(struct sched_entity *se);
27+
28+
extern int sched_bore_update_handler(const struct ctl_table *table, int write,
29+
void __user *buffer, size_t *lenp, loff_t *ppos);
30+
31+
extern void sched_clone_bore(
32+
struct task_struct *p, struct task_struct *parent, u64 clone_flags);
33+
34+
extern void init_task_bore(struct task_struct *p);
35+
extern void sched_bore_init(void);
36+
37+
extern void reweight_entity(
38+
struct cfs_rq *cfs_rq, struct sched_entity *se, unsigned long weight);
39+
#endif // CONFIG_SCHED_BORE
40+
#endif // _LINUX_SCHED_BORE_H

init/Kconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,23 @@ config CHECKPOINT_RESTORE
13411341

13421342
If unsure, say N here.
13431343

1344+
config SCHED_BORE
1345+
bool "Burst-Oriented Response Enhancer"
1346+
default y
1347+
help
1348+
In Desktop and Mobile computing, one might prefer interactive
1349+
tasks to keep responsive no matter what they run in the background.
1350+
1351+
Enabling this kernel feature modifies the scheduler to discriminate
1352+
tasks by their burst time (runtime since it last went sleeping or
1353+
yielding state) and prioritize those that run less bursty.
1354+
Such tasks usually include window compositor, widgets backend,
1355+
terminal emulator, video playback, games and so on.
1356+
With a little impact to scheduling fairness, it may improve
1357+
responsiveness especially under heavy background workload.
1358+
1359+
If unsure, say Y here.
1360+
13441361
config SCHED_AUTOGROUP
13451362
bool "Automatic process group scheduling"
13461363
select CGROUPS

kernel/Kconfig.hz

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,22 @@ config HZ
6363
default 858 if HZ_858
6464
default 1000 if HZ_1000
6565

66+
config MIN_BASE_SLICE_NS
67+
int "Default value for min_base_slice_ns"
68+
default 2000000
69+
help
70+
The BORE Scheduler automatically calculates the optimal base
71+
slice for the configured HZ using the following equation:
72+
73+
base_slice_ns =
74+
1000000000/HZ * DIV_ROUNDUP(min_base_slice_ns, 1000000000/HZ)
75+
76+
This option sets the default lower bound limit of the base slice
77+
to prevent the loss of task throughput due to overscheduling.
78+
79+
Setting this value too high can cause the system to boot with
80+
an unnecessarily large base slice, resulting in high scheduling
81+
latency and poor system responsiveness.
82+
6683
config SCHED_HRTICK
6784
def_bool HIGH_RES_TIMERS

kernel/fork.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
#include <asm/cacheflush.h>
115115
#include <asm/tlbflush.h>
116116

117+
#include <linux/sched/bore.h>
118+
117119
#include <trace/events/sched.h>
118120

119121
#define CREATE_TRACE_POINTS
@@ -2378,6 +2380,9 @@ __latent_entropy struct task_struct *copy_process(
23782380
retval = sched_fork(clone_flags, p);
23792381
if (retval)
23802382
goto bad_fork_cleanup_policy;
2383+
#ifdef CONFIG_SCHED_BORE
2384+
sched_clone_bore(p, current, clone_flags);
2385+
#endif // CONFIG_SCHED_BORE
23812386

23822387
retval = perf_event_init_task(p, clone_flags);
23832388
if (retval)

kernel/sched/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ obj-y += fair.o
3333
obj-y += build_policy.o
3434
obj-y += build_utility.o
3535
obj-$(CONFIG_ANDROID_VENDOR_HOOKS) += vendor_hooks.o
36+
obj-y += bore.o

0 commit comments

Comments
 (0)