Skip to content

Commit

Permalink
Update NEST for 5.15, add THP Shrinker and ksm for 6.0
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Jung <[email protected]>
  • Loading branch information
ptr1337 committed Oct 11, 2022
1 parent eae2c76 commit 5d464d2
Show file tree
Hide file tree
Showing 19 changed files with 114,424 additions and 64 deletions.
32 changes: 17 additions & 15 deletions 5.15/0001-NEST.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
From 89923bf3230fb3ed867afc0a442eef69252044e9 Mon Sep 17 00:00:00 2001
From e87fabf12ab7b61d05718076efd69a49433da2b4 Mon Sep 17 00:00:00 2001
From: Peter Jung <[email protected]>
Date: Mon, 19 Sep 2022 18:16:16 +0200
Date: Wed, 12 Oct 2022 00:05:59 +0200
Subject: [PATCH] NEST

Signed-off-by: Peter Jung <[email protected]>
Expand All @@ -9,10 +9,10 @@ Signed-off-by: Peter Jung <[email protected]>
include/linux/sched.h | 14 ++
include/linux/sched/topology.h | 2 +
kernel/sched/core.c | 86 +++++++++-
kernel/sched/fair.c | 297 ++++++++++++++++++++++++++++++++-
kernel/sched/fair.c | 299 ++++++++++++++++++++++++++++++++-
kernel/sched/idle.c | 20 +++
kernel/sched/sched.h | 49 ++++++
7 files changed, 455 insertions(+), 15 deletions(-)
7 files changed, 457 insertions(+), 15 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 85f6e242b6b4..8520b84d2046 100644
Expand Down Expand Up @@ -73,7 +73,7 @@ index 63a04a65e310..79bf1f6c7b23 100644

struct sched_domain {
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 85be684687b0..0f0ebebafe3b 100644
index 85be684687b0..fb7840a27cf7 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2495,6 +2495,7 @@ __do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask, u32
Expand All @@ -91,7 +91,7 @@ index 85be684687b0..0f0ebebafe3b 100644
- if (unlikely(!is_cpu_allowed(p, cpu)))
+ if (unlikely(!is_cpu_allowed(p, cpu))) {
+ if (p->use_expand_mask)
+ atomic_set(&cpu_rq(cpu)->taken,0);
+ atomic_set(&cpu_rq(p->thread_info.cpu)->taken,0);
cpu = select_fallback_rq(task_cpu(p), p);
+ }

Expand Down Expand Up @@ -156,7 +156,7 @@ index 85be684687b0..0f0ebebafe3b 100644
post_init_entity_util_avg(p);

+ if (p->use_expand_mask)
+ atomic_set(&cpu_rq(p->cpu)->taken,0);
+ atomic_set(&cpu_rq(p->thread_info.cpu)->taken,0);
activate_task(rq, p, ENQUEUE_NOCLOCK);
trace_sched_wakeup_new(p);
check_preempt_curr(rq, p, WF_FORK);
Expand Down Expand Up @@ -269,7 +269,7 @@ index 85be684687b0..0f0ebebafe3b 100644

rq_attach_root(rq, &def_root_domain);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a853e4e9e3c3..0a61e53fc874 100644
index a853e4e9e3c3..9857c18956b6 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3378,6 +3378,61 @@ static inline void update_tg_load_avg(struct cfs_rq *cfs_rq)
Expand Down Expand Up @@ -446,19 +446,20 @@ index a853e4e9e3c3..0a61e53fc874 100644

/*
* On asymmetric system, update task utilization because we will check
@@ -6513,7 +6619,39 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
@@ -6513,7 +6619,41 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
if ((unsigned)i < nr_cpumask_bits)
return i;

- return target;
+ if (!sd->parent) goto abort;
+ group0 = group = sd->parent->groups;
+ do {
+ struct cpumask *m = sched_group_span(group);
+
+ if (cpumask_test_cpu(otarget, m))
+ goto next;
+
+ sd1 = rcu_dereference(per_cpu(sd_llc, group_first_cpu(group)));
+ sd1 = rcu_dereference(per_cpu(sd_llc, cpumask_first(sched_group_span(group))));
+ if (!sd1 || !READ_ONCE(sd1->shared->has_idle_threads))
+ goto next;
+
Expand All @@ -483,19 +484,20 @@ index a853e4e9e3c3..0a61e53fc874 100644
+ } while (group != group0);
+
+
+abort:
+ return otarget;
}

/**
@@ -6940,6 +7078,7 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
@@ -6940,6 +7080,7 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
int cpu = smp_processor_id();
int new_cpu = prev_cpu;
int want_affine = 0;
+ int impatient = 0;
/* SD_flags and WF_flags share the first nibble */
int sd_flag = wake_flags & 0xF;

@@ -6961,6 +7100,144 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
@@ -6961,6 +7102,144 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
}

rcu_read_lock();
Expand Down Expand Up @@ -640,7 +642,7 @@ index a853e4e9e3c3..0a61e53fc874 100644
for_each_domain(cpu, tmp) {
/*
* If both 'cpu' and 'prev_cpu' are part of this domain,
@@ -6988,6 +7265,14 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
@@ -6988,6 +7267,14 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
/* Fast path */
new_cpu = select_idle_sibling(p, prev_cpu, new_cpu);
}
Expand All @@ -656,7 +658,7 @@ index a853e4e9e3c3..0a61e53fc874 100644

return new_cpu;
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index d17b0a5ce6ac..22dda7a58481 100644
index 499a3e286cd0..cf6a3ceb4c79 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -262,6 +262,26 @@ static void do_idle(void)
Expand Down Expand Up @@ -754,5 +756,5 @@ index e49902898253..ee9a744377c0 100644
static inline struct task_struct *task_of(struct sched_entity *se)
{
--
2.37.3
2.38.0

Loading

0 comments on commit 5d464d2

Please sign in to comment.