Skip to content

Commit b934b7f

Browse files
Zhen LeiFrederic Weisbecker
authored andcommitted
rcu: Delete a redundant check in rcu_check_gp_kthread_starvation()
The rcu_check_gp_kthread_starvation() function uses task_cpu() to sample the last CPU that the grace-period kthread ran on, and task_cpu() samples the thread_info structure's ->cpu field. But this field will always contain a number corresponding to a CPU that was online some time in the past, thus never a negative number. This invariant is checked by a WARN_ON_ONCE() in set_task_cpu(). This means that if the grace-period kthread exists, that is, if the "gpk" local variable is non-NULL, the "cpu" local variable will be non-negative. This in turn means that the existing check for non-negative "cpu" is redundant with the enclosing check for non-NULL "gpk". This commit threefore removes the redundant check of "cpu". Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
1 parent 0bb80ec commit b934b7f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

kernel/rcu/tree_stall.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,11 @@ static void rcu_check_gp_kthread_starvation(void)
537537
pr_err("\tUnless %s kthread gets sufficient CPU time, OOM is now expected behavior.\n", rcu_state.name);
538538
pr_err("RCU grace-period kthread stack dump:\n");
539539
sched_show_task(gpk);
540-
if (cpu >= 0) {
541-
if (cpu_is_offline(cpu)) {
542-
pr_err("RCU GP kthread last ran on offline CPU %d.\n", cpu);
543-
} else {
544-
pr_err("Stack dump where RCU GP kthread last ran:\n");
545-
dump_cpu_task(cpu);
546-
}
540+
if (cpu_is_offline(cpu)) {
541+
pr_err("RCU GP kthread last ran on offline CPU %d.\n", cpu);
542+
} else {
543+
pr_err("Stack dump where RCU GP kthread last ran:\n");
544+
dump_cpu_task(cpu);
547545
}
548546
wake_up_process(gpk);
549547
}

0 commit comments

Comments
 (0)