Merge branch 'master' into 'master'

sys-kernel/xanmod-sources:bump to 5.10.3-r1

See merge request src_prepare/src_prepare-overlay!142
This commit is contained in:
hedmo 2020-12-30 13:45:28 +00:00
commit 8633ffa7bb
3 changed files with 155 additions and 2 deletions

View File

@ -0,0 +1,94 @@
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 335efc1c6f06..f81f2f38659e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -43,6 +43,7 @@ unsigned int sysctl_sched_latency = 6000000ULL;
static unsigned int normalized_sysctl_sched_latency = 6000000ULL;
#ifdef CONFIG_CACULE_SCHED
+int cacule_max_lifetime = 30000; // in ms
int interactivity_factor = 32768;
#endif
@@ -591,22 +592,25 @@ static void update_min_vruntime(struct cfs_rq *cfs_rq)
static inline unsigned int
calc_interactivity(u64 now, struct cacule_node *se)
{
- u64 l_se, vr_se, sleep_se, u64_factor;
+ u64 l_se, vr_se, sleep_se = 1ULL, u64_factor;
unsigned int score_se;
/*
* in case of vruntime==0, logical OR with 1 would
* make sure that the least sig. bit is 1
*/
- l_se = (now + 1ULL) - se->cacule_start_time;
+ l_se = now - se->cacule_start_time;
vr_se = se->vruntime | 1;
- sleep_se = (l_se - vr_se) | 1;
u64_factor = interactivity_factor;
- if (sleep_se > vr_se)
+ /* safety check */
+ if (likely(l_se > vr_se))
+ sleep_se = (l_se - vr_se) | 1;
+
+ if (sleep_se >= vr_se)
score_se = u64_factor / (sleep_se / vr_se);
else
- score_se = (u64_factor / (vr_se / sleep_se)) + u64_factor;
+ score_se = (u64_factor << 1) - (u64_factor / (vr_se / sleep_se));
return score_se;
}
@@ -964,6 +968,42 @@ static void update_tg_load_avg(struct cfs_rq *cfs_rq, int force)
}
#endif /* CONFIG_SMP */
+#ifdef CONFIG_CACULE_SCHED
+static void reset_lifetime(u64 now, struct sched_entity *se)
+{
+ struct cacule_node *cn;
+ u64 max_life_ns, life_time;
+ s64 diff;
+
+ /*
+ * left shift 20 bits is approximately = * 1000000
+ * we don't need the precision of life time
+ * Ex. for 30s, with left shift (20bits) == 31.457s
+ */
+ max_life_ns = ((u64) cacule_max_lifetime) << 20;
+
+ for_each_sched_entity(se) {
+ cn = &se->cacule_node;
+ life_time = now - cn->cacule_start_time;
+ diff = life_time - max_life_ns;
+
+ if (unlikely(diff > 0)) {
+ // multiply life_time by 8 for more precision
+ u64 old_hrrn_x8 = life_time / ((cn->vruntime >> 3) | 1);
+
+ // reset life to half max_life (i.e ~15s)
+ cn->cacule_start_time = now - (max_life_ns >> 1);
+
+ // avoid division by zero
+ if (old_hrrn_x8 == 0) old_hrrn_x8 = 1;
+
+ // reset vruntime based on old hrrn ratio
+ cn->vruntime = (max_life_ns << 2) / old_hrrn_x8;
+ }
+ }
+}
+#endif /* CONFIG_CACULE_SCHED */
+
/*
* Update the current task's runtime statistics.
*/
@@ -991,6 +1031,7 @@ static void update_curr(struct cfs_rq *cfs_rq)
#ifdef CONFIG_CACULE_SCHED
curr->cacule_node.vruntime += calc_delta_fair(delta_exec, curr);
+ reset_lifetime(sched_clock(), curr);
#else
curr->vruntime += calc_delta_fair(delta_exec, curr);
update_min_vruntime(cfs_rq);

View File

@ -10,8 +10,9 @@
<name>Andreas Westman Dorcsak</name> <name>Andreas Westman Dorcsak</name>
</maintainer> </maintainer>
<use> <use>
<flag name="cacule"> CacULE is a newer version of Cachy. The CacULE CPU scheduler is based on interactivity score mechanism. The interactivity score is inspired by the ULE scheduler (FreeBSD scheduler). </flag> <flag name="cacule"> CacULE is a newer version of Cachy. The CacULE CPU scheduler is based on interactivity score mechanism. The interactivity score is inspired by the ULE scheduler (FreeBSD scheduler). </flag>
</use> <flag name="experimental"> adding experimental patches for CacULE. </flag>
</use>
<upstream> <upstream>
<remote-id type="github">xanmod/linux</remote-id> <remote-id type="github">xanmod/linux</remote-id>
</upstream> </upstream>

View File

@ -0,0 +1,58 @@
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI="6"
K_WANT_GENPATCHES="base extras"
K_GENPATCHES_VER="1"
K_SECURITY_UNSUPPORTED="1"
K_NOSETEXTRAVERSION="1"
ETYPE="sources"
inherit kernel-2-src-prepare-overlay
detect_version
DESCRIPTION="Full XanMod sources with cacule option and including the Gentoo patchset "
HOMEPAGE="https://xanmod.org"
LICENSE+=" CDDL"
KEYWORDS="~amd64"
IUSE="cacule experimental"
XANMOD_VERSION="1"
XANMOD_URI="https://github.com/xanmod/linux/releases/download/"
SRC_URI="
${KERNEL_BASE_URI}/linux-${KV_MAJOR}.${KV_MINOR}.tar.xz
cacule? ( ${XANMOD_URI}/${OKV}-xanmod${XANMOD_VERSION}-cacule/patch-${OKV}-xanmod${XANMOD_VERSION}-cacule.xz )
!cacule? ( ${XANMOD_URI}/${OKV}-xanmod${XANMOD_VERSION}/patch-${OKV}-xanmod${XANMOD_VERSION}.xz )
${GENPATCHES_URI}
"
src_unpack() {
UNIPATCH_LIST_DEFAULT=""
if use cacule; then
UNIPATCH_LIST="${DISTDIR}/patch-${OKV}-xanmod${XANMOD_VERSION}-cacule.xz "
else
UNIPATCH_LIST="${DISTDIR}/patch-${OKV}-xanmod${XANMOD_VERSION}.xz "
fi
kernel-2-src-prepare-overlay_src_unpack
}
src_prepare() {
if use cacule; then
eapply "${FILESDIR}/localversion.patch"
eapply "${FILESDIR}/interactivity_score_fix_xanmod.patch"
fi
if use experimental ; then
eapply "${FILESDIR}/no_reset_on_migration.patch"
fi
kernel-2-src-prepare-overlay_src_prepare
rm "${S}"/.config || die
}
pkg_postinst() {
elog "MICROCODES"
elog "Use xanmod-sources with microcodes"
elog "Read https://wiki.gentoo.org/wiki/Intel_microcode"
}