ANDROID: sched: Add PELT cmdline arg

The PELT half-life is currently hard-coded to 32ms.

Create cmdline arg to enable switching to a PELT half-life of 8mS.

Bug: 177593580
Change-Id: I9f8cfc3d9554a500eec0f6a1b161f4155c296b4d
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
This commit is contained in:
Shaleen Agrawal
2021-01-29 16:41:28 -08:00
committed by Todd Kjos
parent 8bb774b6f8
commit 8d420888a4
3 changed files with 61 additions and 4 deletions

View File

@@ -3538,6 +3538,12 @@
panic_on_warn panic() instead of WARN(). Useful to cause kdump
on a WARN().
pelt= [KNL] Boot-time parameter changing the PELT half life in ms
Format: <int>
32: Set the half life to 32ms
8: Set the half life to 8ms
default: 32
crash_kexec_post_notifiers
Run kdump after running panic-notifiers and dumping
kmsg. This only for the users who doubt kdump always

View File

@@ -28,6 +28,42 @@
#include "sched.h"
#include "pelt.h"
int pelt_load_avg_period = PELT32_LOAD_AVG_PERIOD;
int pelt_load_avg_max = PELT32_LOAD_AVG_MAX;
u32 *pelt_runnable_avg_yN_inv = pelt32_runnable_avg_yN_inv;
static int __init set_pelt(char *str)
{
int rc, num;
rc = kstrtoint(str, 0, &num);
if (rc) {
pr_err("%s: kstrtoint failed. rc=%d\n", __func__, rc);
return 0;
}
switch (num) {
case PELT8_LOAD_AVG_PERIOD:
pelt_load_avg_period = PELT8_LOAD_AVG_PERIOD;
pelt_load_avg_max = PELT8_LOAD_AVG_MAX;
pelt_runnable_avg_yN_inv = pelt8_runnable_avg_yN_inv;
pr_info("PELT half life is set to %dms\n", num);
break;
case PELT32_LOAD_AVG_PERIOD:
pelt_load_avg_period = PELT32_LOAD_AVG_PERIOD;
pelt_load_avg_max = PELT32_LOAD_AVG_MAX;
pelt_runnable_avg_yN_inv = pelt32_runnable_avg_yN_inv;
pr_info("PELT half life is set to %dms\n", num);
break;
default:
pr_err("Default PELT half life is 32ms\n");
}
return 0;
}
early_param("pelt", set_pelt);
/*
* Approximate:
* val * y^n, where y^32 ~= 0.5 (~1 scheduling period)
@@ -54,7 +90,7 @@ static u64 decay_load(u64 val, u64 n)
local_n %= LOAD_AVG_PERIOD;
}
val = mul_u64_u32_shr(val, runnable_avg_yN_inv[local_n], 32);
val = mul_u64_u32_shr(val, pelt_runnable_avg_yN_inv[local_n], 32);
return val;
}

View File

@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
/* Generated by Documentation/scheduler/sched-pelt; do not modify. */
static const u32 runnable_avg_yN_inv[] __maybe_unused = {
static u32 pelt32_runnable_avg_yN_inv[] = {
0xffffffff, 0xfa83b2da, 0xf5257d14, 0xefe4b99a, 0xeac0c6e6, 0xe5b906e6,
0xe0ccdeeb, 0xdbfbb796, 0xd744fcc9, 0xd2a81d91, 0xce248c14, 0xc9b9bd85,
0xc5672a10, 0xc12c4cc9, 0xbd08a39e, 0xb8fbaf46, 0xb504f333, 0xb123f581,
@@ -10,5 +10,20 @@ static const u32 runnable_avg_yN_inv[] __maybe_unused = {
0x85aac367, 0x82cd8698,
};
#define LOAD_AVG_PERIOD 32
#define LOAD_AVG_MAX 47742
#define PELT32_LOAD_AVG_PERIOD 32
#define PELT32_LOAD_AVG_MAX 47742
static u32 pelt8_runnable_avg_yN_inv[] = {
0xffffffff, 0xeac0c6e6, 0xd744fcc9, 0xc5672a10,
0xb504f333, 0xa5fed6a9, 0x9837f050, 0x8b95c1e3,
};
#define PELT8_LOAD_AVG_PERIOD 8
#define PELT8_LOAD_AVG_MAX 12336
extern u32 *pelt_runnable_avg_yN_inv;
extern int pelt_load_avg_period;
extern int pelt_load_avg_max;
#define LOAD_AVG_PERIOD pelt_load_avg_period
#define LOAD_AVG_MAX pelt_load_avg_max