Android kernel RenderThread线程调度优先级Debug log

kernel/common/kernel/sched/core.c

static int __sched_setscheduler(struct task_struct *p,
				const struct sched_attr *attr,
				bool user, bool pi)
{

	int newprio = dl_policy(attr->sched_policy) ? MAX_DL_PRIO - 1 :
		      MAX_RT_PRIO - 1 - attr->sched_priority;
	int retval, oldprio, oldpolicy = -1, queued, running;
	int new_effective_prio, policy = attr->sched_policy;
	const struct sched_class *prev_class;
	struct rq_flags rf;
	int reset_on_fork;
	int queue_flags = DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK;
	struct rq *rq;  
	/* The pi code expects interrupts enabled */
	BUG_ON(pi && in_interrupt());
recheck:
+	if (p != NULL) {
+		if (!strncmp(p->comm, "RenderThread", strlen("RenderThread")) ){
+			printk(KERN_INFO "RenderThread-%d change from old policy %d to %d prio %d to %d by task %s, pid=%d\n",
+				p->pid, p->policy, attr->sched_policy,p->prio,attr->sched_priority,current->comm, current->pid);
+			dump_stack();
+		}
+	}
	/* Double check policy once rq lock held: */
	if (policy < 0) {
		reset_on_fork = p->sched_reset_on_fork;
		policy = oldpolicy = p->policy;
	} else {
		reset_on_fork = !!(attr->sched_flags & SCHED_FLAG_RESET_ON_FORK);

		if (!valid_policy(policy))
			return -EINVAL;
	}
...


	if (!param || pid < 0)
		return -EINVAL;
	if (copy_from_user(&lparam, param, sizeof(struct sched_param)))
		return -EFAULT;

	rcu_read_lock();
	retval = -ESRCH;
	p = find_process_by_pid(pid);
+	if (p != NULL) {
+		if (!strncmp(p->comm, "RenderThread", strlen("RenderThread")) )
+			printk(KERN_INFO "RenderThread-%d change to %d by task %s, pid=%d\n",
+				pid, policy, current->comm, current->pid);
		retval = sched_setscheduler(p, policy, &lparam);
+	}
	rcu_read_unlock();

	return retval;
}

加入如上log可以比较明确的看到RenderThread的线程由哪个进程调度设置的优先级,这个比较底层,设置线程的优先级均会走到这个方法。

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 5f8b6d4..8b42d32 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3921,6 +3921,9 @@
 	struct rq_flags rf;
 	struct rq *rq;
 
+	trace_printk("bug1488316: task pid=%d, policy(%d), nice(%d->%ld)\n", p->pid, p->policy, task_nice(p), nice);
+	printk(KERN_INFO "bug1488316: set_user_nice begin task pid=%d, policy(%d), nice(%d->%ld)\n", p->pid, p->policy, task_nice(p), nice);
+
 	if (task_nice(p) == nice || nice < MIN_NICE || nice > MAX_NICE)
 		return;
 	/*
@@ -3966,6 +3969,8 @@
 		set_curr_task(rq, p);
 out_unlock:
 	task_rq_unlock(rq, p, &rf);
+	trace_printk("bug1488316: task pid=%d, end: new-nice(%d)\n", p->pid, task_nice(p));
+	printk(KERN_INFO "bug1488316: set_user_nice end task pid=%d, end: new-nice(%d)\n", p->pid, task_nice(p));
 }
 EXPORT_SYMBOL(set_user_nice);
 
@@ -4007,6 +4012,9 @@
 	nice = clamp_val(nice, MIN_NICE, MAX_NICE);
 	if (increment < 0 && !can_nice(current, nice))
 		return -EPERM;
+
+	trace_printk("bug1488316: task pid=%d, policy(%d), nice(%d->%ld)\n", current->pid, current->policy, task_nice(current), nice);
+	printk(KERN_INFO "bug1488316: SYSCALL_DEFINE1  task pid=%d, policy(%d), nice(%d->%ld)\n", current->pid, current->policy, task_nice(current), nice);
 
 	retval = security_task_setnice(current, nice);
 	if (retval)
@@ -4159,6 +4167,11 @@
 	int reset_on_fork;
 	int queue_flags = DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK;
 	struct rq *rq;
+
+	trace_printk("bug1488316: task pid=%d, policy(%d->%d), nice(%d->%d), prio(%d->%d)\n",
+		p->pid, p->policy, attr->sched_policy, task_nice(p), attr->sched_nice, p->rt_priority, attr->sched_priority);
+	printk(KERN_INFO "bug1488316: __sched_setscheduler task pid=%d, policy(%d->%d), nice(%d->%d), prio(%d->%d)\n",
+		p->pid, p->policy, attr->sched_policy, task_nice(p), attr->sched_nice, p->rt_priority, attr->sched_priority);
 
 	/* The pi code expects interrupts enabled */
 	BUG_ON(pi && in_interrupt());
@@ -4383,6 +4396,11 @@
 	balance_callback(rq);
 	preempt_enable();
 
+	trace_printk("bug1488316: task pid=%d, end: new-policy(%d), new-nice(%d), new-prio(%d)\n",
+		p->pid, p->policy, task_nice(p), p->rt_priority);
+	printk(KERN_INFO "bug1488316: __sched_setscheduler end task pid=%d, end: new-policy(%d), new-nice(%d), new-prio(%d)\n",
+		p->pid, p->policy, task_nice(p), p->rt_priority);
+
 	return 0;
 }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值