From 9d6bb707118d77e6d5e6be98c3a59b6dd712d0c8 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 15 Oct 2024 11:44:20 +0800 Subject: [PATCH] add rtg trace test Signed-off-by: Brian --- kernel/sched/rtg/frame_rtg.c | 36 +++++++++++++++++++++++++++++++++--- kernel/sched/rtg/rtg_ctrl.c | 3 +++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/kernel/sched/rtg/frame_rtg.c b/kernel/sched/rtg/frame_rtg.c index 79db645228c4..b00f910f877f 100755 --- a/kernel/sched/rtg/frame_rtg.c +++ b/kernel/sched/rtg/frame_rtg.c @@ -404,7 +404,11 @@ static int do_set_rtg_sched(struct task_struct *task, bool is_rtg, struct sched_param sp = {0}; if (is_rtg) { + pr_err("[lqw] do_set_rtg_sched: is_rtg = %d\n", is_rtg); if (is_rt_task) { + pr_err("[lqw] do_set_rtg_sched: is_rt_task = %d\n", is_rt_task); + pr_err("[lqw] do_set_rtg_sched: test_and_read_rtg_rt_thread_num() = %d\n", test_and_read_rtg_rt_thread_num()); + pr_err("[lqw] do_set_rtg_sched: RTG_MAX_RT_THREAD_NUM = %d\n", RTG_MAX_RT_THREAD_NUM); if (test_and_read_rtg_rt_thread_num() >= RTG_MAX_RT_THREAD_NUM) // rtg_rt_thread_num is inavailable, set policy to CFS goto skip_setpolicy; @@ -480,16 +484,22 @@ static bool set_frame_rtg_thread(int grp_id, struct task_struct *task, if (!task) return false; depth = task->rtg_depth; - if (is_rtg) + pr_err("[lqw] set_frame_rtg_thread: depth=%d\n", depth); + if (is_rtg) { task->rtg_depth = STATIC_RTG_DEPTH; - else + pr_err("[lqw] set_frame_rtg_thread: if (is_rtg) task->rtg_depth = %d\n", STATIC_RTG_DEPTH); + } else { + pr_err("[lqw] set_frame_rtg_thread: else task->rtg_depth = 0;\n"); task->rtg_depth = 0; + } if (set_rtg_sched(task, is_rtg, grp_id, prio) < 0) { task->rtg_depth = depth; + pr_err("[lqw] set_frame_rtg_thread: return false;\n"); return false; } + pr_err("[lqw] set_frame_rtg_thread: return true;\n"); return true; } @@ -502,14 +512,24 @@ struct task_struct *update_frame_thread(struct frame_info *frame_info, int new_prio = prio; bool update_ret = false; + pr_err("[lqw] update_frame_thread: pid=%d\n", pid); + pr_err("[lqw] update_frame_thread: old_task->pid=%d\n", old_task->pid); + pr_err("[lqw] update_frame_thread: old_prio=%d\n", old_prio); + pr_err("[lqw] update_frame_thread: new_prio=%d\n", new_prio); if (pid > 0) { + pr_err("[lqw] update_frame_thread: (pid > 0)\n"); if (old_task && (pid == old_task->pid) && (old_prio == new_prio)) { + pr_err("[lqw] update_frame_thread: old_task && (pid == old_task->pid) && (old_prio == new_prio)\n"); if (is_rt_task && atomic_read(&frame_info->curr_rt_thread_num) < atomic_read(&frame_info->max_rt_thread_num) && - (atomic_read(&frame_info->frame_sched_state) == 1)) + (atomic_read(&frame_info->frame_sched_state) == 1)) { + pr_err("[lqw] update_frame_thread: atomic_inc(&frame_info->curr_rt_thread_num);\n"); + atomic_inc(&frame_info->curr_rt_thread_num); + } trace_rtg_frame_sched(frame_info->rtg->id, "curr_rt_thread_num", atomic_read(&frame_info->curr_rt_thread_num)); + pr_err("[lqw] update_frame_thread: return old_task;\n"); return old_task; } rcu_read_lock(); @@ -522,11 +542,18 @@ struct task_struct *update_frame_thread(struct frame_info *frame_info, atomic_read(&frame_info->frame_sched_state)); if (atomic_read(&frame_info->frame_sched_state) == 1) { if (task && is_rt_task) { + pr_err("[lqw] update_frame_thread: (task && is_rt_task)\n"); if (atomic_read(&frame_info->curr_rt_thread_num) < atomic_read(&frame_info->max_rt_thread_num)) + { atomic_inc(&frame_info->curr_rt_thread_num); + pr_err("[lqw] update_frame_thread: atomic_inc\n"); + } else + { new_prio = NOT_RT_PRIO; + pr_err("[lqw] update_frame_thread: new_prio = NOT_RT_PRIO;\n"); + } } trace_rtg_frame_sched(frame_info->rtg->id, "curr_rt_thread_num", atomic_read(&frame_info->curr_rt_thread_num)); @@ -535,6 +562,9 @@ struct task_struct *update_frame_thread(struct frame_info *frame_info, set_frame_rtg_thread(frame_info->rtg->id, old_task, false, NOT_RT_PRIO); update_ret = set_frame_rtg_thread(frame_info->rtg->id, task, true, new_prio); + pr_err("[lqw] update_frame_thread: set_frame_rtg_thread(%d, %d, true, %d)\n", frame_info->rtg->id, task, new_prio); + pr_err("[lqw] update_frame_thread: update_ret = %d;\n", update_ret); + } if (old_task) put_task_struct(old_task); diff --git a/kernel/sched/rtg/rtg_ctrl.c b/kernel/sched/rtg/rtg_ctrl.c index 164f1b2373b9..e6521bba376a 100755 --- a/kernel/sched/rtg/rtg_ctrl.c +++ b/kernel/sched/rtg/rtg_ctrl.c @@ -649,8 +649,10 @@ static int parse_add_rtg_thread(const struct rtg_grp_data *rs_data) frame_info->thread[add_index]); if (frame_info->thread[add_index]) { atomic_set(&frame_info->thread_prio[add_index], prio); + pr_err("[lqw] parse_add_rtg_thread: atomic_set prio=%d!\n", prio); frame_info->thread_num++; add_index = frame_info->thread_num; + pr_err("[lqw] parse_add_rtg_thread: add_index=%d!\n", add_index); } else { fail_num++; } @@ -717,6 +719,7 @@ long ctrl_set_rtg(int abi, void __user *uarg) ret = parse_create_rtg_grp(&rs_data); break; case CMD_ADD_RTG_THREAD: + pr_err("[lqw] CMD_ADD_RTG_THREAD"); ret = parse_add_rtg_thread(&rs_data); break; case CMD_REMOVE_RTG_THREAD: -- Gitee