提交 77277550 编写于 作者: C Chen Hui 提交者: Zheng Zengkai

sched: programmable: Add user interface of task group tag

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5KUFB
CVE: NA

--------------------------------

Add user interface of task group tag, bridges the information
gap between user-mode and kernel-mode.
Signed-off-by: NChen Hui <judy.chenhui@huawei.com>
Signed-off-by: NRen Zhijie <renzhijie2@huawei.com>
上级 6a8dd76e
...@@ -2176,4 +2176,8 @@ static inline int sched_qos_cpu_overload(void) ...@@ -2176,4 +2176,8 @@ static inline int sched_qos_cpu_overload(void)
return 0; return 0;
} }
#endif #endif
#ifdef CONFIG_BPF_SCHED
extern void sched_settag(struct task_struct *tsk, s64 tag);
#endif
#endif #endif
...@@ -8637,6 +8637,80 @@ static inline s64 cpu_qos_read(struct cgroup_subsys_state *css, ...@@ -8637,6 +8637,80 @@ static inline s64 cpu_qos_read(struct cgroup_subsys_state *css,
} }
#endif #endif
#ifdef CONFIG_BPF_SCHED
void sched_settag(struct task_struct *tsk, s64 tag)
{
int queued, running, queue_flags =
DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK;
struct rq_flags rf;
struct rq *rq;
if (tsk->tag == tag)
return;
rq = task_rq_lock(tsk, &rf);
running = task_current(rq, tsk);
queued = task_on_rq_queued(tsk);
update_rq_clock(rq);
if (queued)
dequeue_task(rq, tsk, queue_flags);
if (running)
put_prev_task(rq, tsk);
tsk->tag = tag;
if (queued)
enqueue_task(rq, tsk, queue_flags);
if (running)
set_next_task(rq, tsk);
task_rq_unlock(rq, tsk, &rf);
}
int tg_change_tag(struct task_group *tg, void *data)
{
struct css_task_iter it;
struct task_struct *tsk;
s64 tag = *(s64 *)data;
struct cgroup_subsys_state *css = &tg->css;
tg->tag = tag;
css_task_iter_start(css, 0, &it);
while ((tsk = css_task_iter_next(&it)))
sched_settag(tsk, tag);
css_task_iter_end(&it);
return 0;
}
static int cpu_tag_write(struct cgroup_subsys_state *css,
struct cftype *cftype, s64 tag)
{
struct task_group *tg = css_tg(css);
if (tg == &root_task_group)
return -EINVAL;
if (tg->tag == tag)
return 0;
rcu_read_lock();
walk_tg_tree_from(tg, tg_change_tag, tg_nop, (void *)(&tag));
rcu_read_unlock();
return 0;
}
static inline s64 cpu_tag_read(struct cgroup_subsys_state *css,
struct cftype *cft)
{
return css_tg(css)->tag;
}
#endif
static struct cftype cpu_legacy_files[] = { static struct cftype cpu_legacy_files[] = {
#ifdef CONFIG_FAIR_GROUP_SCHED #ifdef CONFIG_FAIR_GROUP_SCHED
{ {
...@@ -8698,6 +8772,13 @@ static struct cftype cpu_legacy_files[] = { ...@@ -8698,6 +8772,13 @@ static struct cftype cpu_legacy_files[] = {
.read_s64 = cpu_qos_read, .read_s64 = cpu_qos_read,
.write_s64 = cpu_qos_write, .write_s64 = cpu_qos_write,
}, },
#endif
#ifdef CONFIG_BPF_SCHED
{
.name = "tag",
.read_s64 = cpu_tag_read,
.write_s64 = cpu_tag_write,
},
#endif #endif
{ } /* Terminate */ { } /* Terminate */
}; };
......
...@@ -498,6 +498,9 @@ static inline int walk_tg_tree(tg_visitor down, tg_visitor up, void *data) ...@@ -498,6 +498,9 @@ static inline int walk_tg_tree(tg_visitor down, tg_visitor up, void *data)
} }
extern int tg_nop(struct task_group *tg, void *data); extern int tg_nop(struct task_group *tg, void *data);
#ifdef CONFIG_BPF_SCHED
extern int tg_change_tag(struct task_group *tg, void *data);
#endif
extern void free_fair_sched_group(struct task_group *tg); extern void free_fair_sched_group(struct task_group *tg);
extern int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent); extern int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册