[luto:sched/lazymm 13/16] kernel/sched/core.c:4986:22: warning: variable 'old_active_mm' is uninitialized when used here

From: kernel test robot
Date: Mon Nov 22 2021 - 14:38:08 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git sched/lazymm
head: c0d03d4f2778fd0a7c16e69cdfb3f111296129b5
commit: 4863118ffa6fe6af7cfb18c4d4ee6434537b0c8b [13/16] sched, exec: Factor current mm changes out from exec
config: x86_64-randconfig-r034-20211116 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project fbe72e41b99dc7994daac300d208a955be3e4a0a)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git/commit/?id=4863118ffa6fe6af7cfb18c4d4ee6434537b0c8b
git remote add luto https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git
git fetch --no-tags luto sched/lazymm
git checkout 4863118ffa6fe6af7cfb18c4d4ee6434537b0c8b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

kernel/sched/core.c:3417:6: warning: no previous prototype for function 'sched_set_stop_task' [-Wmissing-prototypes]
void sched_set_stop_task(int cpu, struct task_struct *stop)
^
kernel/sched/core.c:3417:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void sched_set_stop_task(int cpu, struct task_struct *stop)
^
static
>> kernel/sched/core.c:4986:22: warning: variable 'old_active_mm' is uninitialized when used here [-Wuninitialized]
switch_mm_irqs_off(old_active_mm, mm, tsk);
^~~~~~~~~~~~~
kernel/sched/core.c:4941:33: note: initialize the variable 'old_active_mm' to silence this warning
struct mm_struct *old_active_mm, *mm_to_drop = NULL;
^
= NULL
2 warnings generated.


vim +/old_active_mm +4986 kernel/sched/core.c

4937
4938 void __change_current_mm(struct mm_struct *mm, bool mm_is_brand_new)
4939 {
4940 struct task_struct *tsk = current;
4941 struct mm_struct *old_active_mm, *mm_to_drop = NULL;
4942
4943 BUG_ON(!mm); /* likely to cause corruption if we continue */
4944
4945 /*
4946 * We do not want to schedule, nor should procfs peek at current->mm
4947 * while we're modifying it. task_lock() disables preemption and
4948 * locks against procfs.
4949 */
4950 task_lock(tsk);
4951 /*
4952 * membarrier() requires a full barrier before switching mm.
4953 */
4954 smp_mb__after_spinlock();
4955
4956 local_irq_disable();
4957
4958 if (tsk->mm) {
4959 /* We're detaching from an old mm. Sync stats. */
4960 sync_mm_rss(tsk->mm);
4961 } else {
4962 /*
4963 * Switching from kernel mm to user. Drop the old lazy
4964 * mm reference.
4965 */
4966 mm_to_drop = tsk->active_mm;
4967 }
4968
4969 tsk->active_mm = mm;
4970 WRITE_ONCE(tsk->mm, mm); /* membarrier reads this without locks */
4971 membarrier_update_current_mm(mm);
4972
4973 if (mm_is_brand_new) {
4974 /*
4975 * For historical reasons, some architectures want IRQs on
4976 * when activate_mm() is called. If we're going to call
4977 * activate_mm(), turn on IRQs but leave preemption
4978 * disabled.
4979 */
4980 if (!IS_ENABLED(CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM))
4981 local_irq_enable();
4982 activate_mm(old_active_mm, mm);
4983 if (IS_ENABLED(CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM))
4984 local_irq_enable();
4985 } else {
> 4986 switch_mm_irqs_off(old_active_mm, mm, tsk);
4987 local_irq_enable();
4988 }
4989
4990 /* IRQs are on now. Preemption is still disabled by task_lock(). */
4991
4992 membarrier_finish_switch_mm(mm);
4993 vmacache_flush(tsk);
4994 task_unlock(tsk);
4995

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip