kernel/sched/psi.c:639:13: warning: 'rq' may be used uninitialized in this function

From: kbuild test robot
Date: Mon Nov 05 2018 - 00:31:09 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 651022382c7f8da46cb4872a545ee1da6d097d2a
commit: 2ce7135adc9ad081aa3c49744144376ac74fea60 psi: cgroup support
date: 9 days ago
config: x86_64-randconfig-s1-11051307 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
git checkout 2ce7135adc9ad081aa3c49744144376ac74fea60
# save the attached .config to linux build tree
make ARCH=x86_64

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

kernel/sched/psi.c: In function 'cgroup_move_task':
>> kernel/sched/psi.c:639:13: warning: 'rq' may be used uninitialized in this function [-Wmaybe-uninitialized]
struct rq *rq;
^~

vim +/rq +639 kernel/sched/psi.c

621
622 /**
623 * cgroup_move_task - move task to a different cgroup
624 * @task: the task
625 * @to: the target css_set
626 *
627 * Move task to a new cgroup and safely migrate its associated stall
628 * state between the different groups.
629 *
630 * This function acquires the task's rq lock to lock out concurrent
631 * changes to the task's scheduling state and - in case the task is
632 * running - concurrent changes to its stall state.
633 */
634 void cgroup_move_task(struct task_struct *task, struct css_set *to)
635 {
636 bool move_psi = !psi_disabled;
637 unsigned int task_flags = 0;
638 struct rq_flags rf;
> 639 struct rq *rq;
640
641 if (move_psi) {
642 rq = task_rq_lock(task, &rf);
643
644 if (task_on_rq_queued(task))
645 task_flags = TSK_RUNNING;
646 else if (task->in_iowait)
647 task_flags = TSK_IOWAIT;
648
649 if (task->flags & PF_MEMSTALL)
650 task_flags |= TSK_MEMSTALL;
651
652 if (task_flags)
653 psi_task_change(task, task_flags, 0);
654 }
655
656 /*
657 * Lame to do this here, but the scheduler cannot be locked
658 * from the outside, so we move cgroups from inside sched/.
659 */
660 rcu_assign_pointer(task->cgroups, to);
661
662 if (move_psi) {
663 if (task_flags)
664 psi_task_change(task, 0, task_flags);
665
666 task_rq_unlock(rq, task, &rf);
667 }
668 }
669 #endif /* CONFIG_CGROUPS */
670

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip