@@ -537,13 +537,11 @@ static void rcu_check_gp_kthread_starvation(void)
pr_err("\tUnless %s kthread gets sufficient CPU time, OOM is now expected behavior.\n", rcu_state.name);
pr_err("RCU grace-period kthread stack dump:\n");
sched_show_task(gpk);
- if (cpu >= 0) {
- if (cpu_is_offline(cpu)) {
- pr_err("RCU GP kthread last ran on offline CPU %d.\n", cpu);
- } else {
- pr_err("Stack dump where RCU GP kthread last ran:\n");
- dump_cpu_task(cpu);
- }
+ if (cpu_is_offline(cpu)) {
+ pr_err("RCU GP kthread last ran on offline CPU %d.\n", cpu);
+ } else {
+ pr_err("Stack dump where RCU GP kthread last ran:\n");
+ dump_cpu_task(cpu);
}
wake_up_process(gpk);
}
The kernel provides the only legal way, that is, function set_task_cpu(), to dynamically change the value of task_cpu(p). And in which the validity of the CPU ID is checked. set_task_cpu(): WARN_ON_ONCE(!cpu_online(new_cpu)); __set_task_cpu(p, new_cpu); Therefore, in normal cases, the value of task_cpu(gpk) is always valid. Then for the following snippet in rcu_check_gp_kthread_starvation(): cpu = gpk ? task_cpu(gpk) : -1; if (gpk) { if (cpu >= 0) { The above condition "if (gpk)" already ensures that gp_kthread is created, so the local variable 'cpu' cannot be negative here. Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> --- kernel/rcu/tree_stall.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)