diff options
author | Qais Yousef <qyousef@google.com> | 2023-07-25 17:10:01 +0000 |
---|---|---|
committer | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2023-08-02 16:54:33 +0000 |
commit | e0b8a2e89484b0f4acbe0603ebfa29245bf993e3 (patch) | |
tree | e6bbc3186f54ccba857fe6207721367fb2bd1ebd | |
parent | 341cadde1c631bae82b2f29b056c1c16b2f2fc93 (diff) | |
download | gs-e0b8a2e89484b0f4acbe0603ebfa29245bf993e3.tar.gz |
sched: vh: Add a new knob to modify teo util_threshold
Bug: 289293494
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: I455ef965b57d7ff0e70db098c37c2f05e0e8c2cf
-rw-r--r-- | drivers/soc/google/vh/kernel/sched/procfs_node.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/drivers/soc/google/vh/kernel/sched/procfs_node.c b/drivers/soc/google/vh/kernel/sched/procfs_node.c index 711d47cf6..8f72118bd 100644 --- a/drivers/soc/google/vh/kernel/sched/procfs_node.c +++ b/drivers/soc/google/vh/kernel/sched/procfs_node.c @@ -5,6 +5,7 @@ * * Copyright 2020 Google LLC */ +#include <linux/cpuidle.h> #include <linux/lockdep.h> #include <linux/kobject.h> #include <linux/sched.h> @@ -972,6 +973,65 @@ fail: return -EINVAL; } +static int update_teo_util_threshold(const char *buf, int count) +{ + char *tok, *str1, *str2; + unsigned int val, tmp[CPU_NUM]; + int index = 0; + + str1 = kstrndup(buf, count, GFP_KERNEL); + str2 = str1; + + if (!str2) + return -ENOMEM; + + while (1) { + tok = strsep(&str2, " "); + + if (tok == NULL) + break; + + if (kstrtouint(tok, 0, &val)) + goto fail; + + if (val > SCHED_CAPACITY_SCALE) + goto fail; + + tmp[index] = val; + index++; + + if (index == CPU_NUM) + break; + } + + if (index == 1) { + for (index = 0; index < CPU_NUM; index++) { + teo_cpu_set_util_threshold(index, tmp[0]); + } + } else if (index == CLUSTER_NUM) { + for (index = MIN_CAPACITY_CPU; index < MID_CAPACITY_CPU; index++) + teo_cpu_set_util_threshold(index, tmp[0]); + + for (index = MID_CAPACITY_CPU; index < MAX_CAPACITY_CPU; index++) + teo_cpu_set_util_threshold(index, tmp[1]); + + for (index = MAX_CAPACITY_CPU; index < CPU_NUM; index++) + teo_cpu_set_util_threshold(index, tmp[2]); + } else if (index == CPU_NUM) { + for (index = 0; index < CPU_NUM; index++) { + teo_cpu_set_util_threshold(index, tmp[index]); + } + } else { + goto fail; + } + + kfree(str1); + return count; +fail: + kfree(str1); + return -EINVAL; +} + static int update_sched_auto_uclamp_max(const char *buf, int count) { char *tok, *str1, *str2; @@ -1392,6 +1452,36 @@ static ssize_t dvfs_headroom_store(struct file *filp, } PROC_OPS_RW(dvfs_headroom); +static int teo_util_threshold_show(struct seq_file *m, void *v) +{ + int i; + + for (i = 0; i < CPU_NUM; i++) { + seq_printf(m, "%u ", teo_cpu_get_util_threshold(i)); + } + + seq_printf(m, "\n"); + + return 0; +} +static ssize_t teo_util_threshold_store(struct file *filp, + const char __user *ubuf, + size_t count, loff_t *pos) +{ + char buf[MAX_PROC_SIZE]; + + if (count >= sizeof(buf)) + return -EINVAL; + + if (copy_from_user(buf, ubuf, count)) + return -EFAULT; + + buf[count] = '\0'; + + return update_teo_util_threshold(buf, count); +} +PROC_OPS_RW(teo_util_threshold); + static int tapered_dvfs_headroom_enable_show(struct seq_file *m, void *v) { seq_printf(m, "%d\n", static_branch_likely(&tapered_dvfs_headroom_enable) ? 1 : 0); @@ -2487,6 +2577,8 @@ static struct pentry entries[] = { // dvfs headroom PROC_ENTRY(dvfs_headroom), PROC_ENTRY(tapered_dvfs_headroom_enable), + // teo + PROC_ENTRY(teo_util_threshold), }; |