故障定位过程中,业务进程没有做核绑定,导致每次都是通过负载均衡动态选择运行核,
导致很多时候业务进程出现在核0上死循环(系统态),串口都没反应。
由于是第三方负责启动,无法通过taskset命令指定核号启动。不过我们知道执行进程的ELF名字,因此想到是否可以通过内核强制设置进程运行核号。
关键函数select_task_rq(),通过对比进程名字强制设置核号。
/*
* The caller (fork, wakeup) owns p->pi_lock, ->cpus_allowed is stable.
*/
static inline
int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags)
{
if (p->nr_cpus_allowed > 1)
cpu = p->sched_class->select_task_rq(p, cpu, sd_flags, wake_flags);
/*
* In order not to call set_task_cpu() on a blocking task we need
* to rely on ttwu() to place the task on a valid ->cpus_allowed
* cpu.
*
* Since this is common to all placement strategies, this lives here.
*
* [ this allows ->select_task() to simply return task_cpu(p) and
* not worry about this generic constraint ]
*/
if (unlikely(!cpumask_test_cpu(cpu, tsk_cpus_allowed(p)) ||
!cpu_online(cpu)))
cpu = select_fallback_rq(task_cpu(p), p);
/* 通过进程名字强制设置运行核 */
if(!strcmp(p->comm, "Proc_Name")){
return 7;
}else{
return cpu;
}
}
完美解决需求,故障定位效率更高了。