forked from Kfkcome/android_kernel_xiaomi_nabu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: Restore schedtune compatibility
When SCHED_TUNE is disabled, certain elements in userspace, like libperfmgr, may throw errors when it doesn't detect SCHEDTUNE-related nodes. So, create a few dummy nodes to satisfy said userspace elements. Change-Id: I24df608349551c94d4b50d0764548bd669e5a770 Signed-off-by: darkhz <[email protected]> Signed-off-by: Panchajanya1999 <[email protected]>
- Loading branch information
1 parent
e6f4b71
commit 7b0b07a
Showing
4 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#include <linux/cgroup.h> | ||
#include "sched.h" | ||
|
||
#define BOOSTGROUPS_COUNT 5 | ||
|
||
struct schedtune { | ||
/* SchedTune CGroup subsystem */ | ||
struct cgroup_subsys_state css; | ||
|
||
/* Boost value for tasks on that SchedTune CGroup */ | ||
int boost; | ||
|
||
/* Hint to bias scheduling of tasks on that SchedTune CGroup | ||
* towards idle CPUs */ | ||
int prefer_idle; | ||
}; | ||
|
||
static struct schedtune | ||
root_schedtune = { | ||
.boost = 0, | ||
.prefer_idle = 0, | ||
}; | ||
|
||
static struct schedtune *allocated_group[BOOSTGROUPS_COUNT] = { | ||
&root_schedtune, | ||
NULL, | ||
}; | ||
|
||
static inline struct schedtune *css_st(struct cgroup_subsys_state *css) | ||
{ | ||
return container_of(css, struct schedtune, css); | ||
} | ||
|
||
static u64 | ||
prefer_idle_read(struct cgroup_subsys_state *css, struct cftype *cft) | ||
{ | ||
return 0; | ||
} | ||
|
||
static int | ||
prefer_idle_write(struct cgroup_subsys_state *css, struct cftype *cft, | ||
u64 prefer_idle) | ||
{ | ||
return 0; | ||
} | ||
|
||
static s64 | ||
boost_read(struct cgroup_subsys_state *css, struct cftype *cft) | ||
{ | ||
return 0; | ||
} | ||
|
||
static int | ||
boost_write(struct cgroup_subsys_state *css, struct cftype *cft, | ||
s64 boost) | ||
{ | ||
return 0; | ||
} | ||
|
||
static struct cftype files[] = { | ||
{ | ||
.name = "boost", | ||
.read_s64 = boost_read, | ||
.write_s64 = boost_write, | ||
}, | ||
{ | ||
.name = "prefer_idle", | ||
.read_u64 = prefer_idle_read, | ||
.write_u64 = prefer_idle_write, | ||
}, | ||
{ } /* terminate */ | ||
}; | ||
|
||
static struct cgroup_subsys_state * | ||
schedtune_css_alloc(struct cgroup_subsys_state *parent_css) | ||
{ | ||
struct schedtune *st; | ||
int idx; | ||
|
||
if (!parent_css) | ||
return &root_schedtune.css; | ||
|
||
/* Allow only single level hierachies */ | ||
if (parent_css != &root_schedtune.css) { | ||
pr_err("Nested SchedTune boosting groups not allowed\n"); | ||
return ERR_PTR(-ENOMEM); | ||
} | ||
|
||
/* Allow only a limited number of boosting groups */ | ||
for (idx = 1; idx < BOOSTGROUPS_COUNT; ++idx) | ||
if (!allocated_group[idx]) | ||
break; | ||
if (idx == BOOSTGROUPS_COUNT) { | ||
pr_err("Trying to create more than %d SchedTune boosting groups\n", | ||
BOOSTGROUPS_COUNT); | ||
return ERR_PTR(-ENOSPC); | ||
} | ||
|
||
st = kzalloc(sizeof(*st), GFP_KERNEL); | ||
if (!st) | ||
goto out; | ||
|
||
return &st->css; | ||
|
||
out: | ||
return ERR_PTR(-ENOMEM); | ||
} | ||
|
||
static void | ||
schedtune_css_free(struct cgroup_subsys_state *css) | ||
{ | ||
struct schedtune *st = css_st(css); | ||
|
||
kfree(st); | ||
} | ||
|
||
struct cgroup_subsys schedtune_cgrp_subsys = { | ||
.css_alloc = schedtune_css_alloc, | ||
.css_free = schedtune_css_free, | ||
.legacy_cftypes = files, | ||
.early_init = 1, | ||
}; |