[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202510041546.DvhFLp2x-lkp@intel.com>
Date: Sat, 4 Oct 2025 11:35:47 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: oe-kbuild@...ts.linux.dev,
André Draszik <andre.draszik@...aro.org>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Valentin Schneider <vschneid@...hat.com>
Cc: lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
Peter Griffin <peter.griffin@...aro.org>,
Tudor Ambarus <tudor.ambarus@...aro.org>,
Will McVicker <willmcvicker@...gle.com>, kernel-team@...roid.com,
linux-kernel@...r.kernel.org,
André Draszik <andre.draszik@...aro.org>
Subject: Re: [PATCH] sched: drop unused variable cpumask in mm_cid_get()
Hi André,
kernel test robot noticed the following build warnings:
url: https://github.com/intel-lab-lkp/linux/commits/Andr-Draszik/sched-drop-unused-variable-cpumask-in-mm_cid_get/20251002-192448
base: 3b9b1f8df454caa453c7fb07689064edb2eda90a
patch link: https://lore.kernel.org/r/20251002-sched-w1-v1-1-a6fdf549d179%40linaro.org
patch subject: [PATCH] sched: drop unused variable cpumask in mm_cid_get()
config: i386-randconfig-141-20251004 (https://download.01.org/0day-ci/archive/20251004/202510041546.DvhFLp2x-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
| Closes: https://lore.kernel.org/r/202510041546.DvhFLp2x-lkp@intel.com/
smatch warnings:
kernel/sched/sched.h:3810 switch_mm_cid() error: we previously assumed 'next->mm' could be null (see line 3772)
vim +3810 kernel/sched/sched.h
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3762 static inline void switch_mm_cid(struct rq *rq,
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3763 struct task_struct *prev,
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3764 struct task_struct *next)
af7f588d8f7355 Mathieu Desnoyers 2022-11-22 3765 {
af7f588d8f7355 Mathieu Desnoyers 2022-11-22 3766 /*
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3767 * Provide a memory barrier between rq->curr store and load of
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3768 * {prev,next}->mm->pcpu_cid[cpu] on rq->curr->mm transition.
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3769 *
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3770 * Should be adapted if context_switch() is modified.
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3771 */
223baf9d17f25e Mathieu Desnoyers 2023-04-20 @3772 if (!next->mm) { // to kernel
Can ->mm_cid_active be true when next->mm is false? I don't know.
If so then it's fine. I suspect it's fine...
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3773 /*
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3774 * user -> kernel transition does not guarantee a barrier, but
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3775 * we can use the fact that it performs an atomic operation in
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3776 * mmgrab().
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3777 */
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3778 if (prev->mm) // from user
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3779 smp_mb__after_mmgrab();
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3780 /*
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3781 * kernel -> kernel transition does not change rq->curr->mm
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3782 * state. It stays NULL.
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3783 */
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3784 } else { // to user
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3785 /*
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3786 * kernel -> user transition does not provide a barrier
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3787 * between rq->curr store and load of {prev,next}->mm->pcpu_cid[cpu].
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3788 * Provide it here.
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3789 */
fe90f3967bdb3e Mathieu Desnoyers 2024-04-15 3790 if (!prev->mm) { // from kernel
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3791 smp_mb();
fe90f3967bdb3e Mathieu Desnoyers 2024-04-15 3792 } else { // from user
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3793 /*
fe90f3967bdb3e Mathieu Desnoyers 2024-04-15 3794 * user->user transition relies on an implicit
fe90f3967bdb3e Mathieu Desnoyers 2024-04-15 3795 * memory barrier in switch_mm() when
fe90f3967bdb3e Mathieu Desnoyers 2024-04-15 3796 * current->mm changes. If the architecture
fe90f3967bdb3e Mathieu Desnoyers 2024-04-15 3797 * switch_mm() does not have an implicit memory
fe90f3967bdb3e Mathieu Desnoyers 2024-04-15 3798 * barrier, it is emitted here. If current->mm
fe90f3967bdb3e Mathieu Desnoyers 2024-04-15 3799 * is unchanged, no barrier is needed.
af7f588d8f7355 Mathieu Desnoyers 2022-11-22 3800 */
fe90f3967bdb3e Mathieu Desnoyers 2024-04-15 3801 smp_mb__after_switch_mm();
fe90f3967bdb3e Mathieu Desnoyers 2024-04-15 3802 }
af7f588d8f7355 Mathieu Desnoyers 2022-11-22 3803 }
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3804 if (prev->mm_cid_active) {
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3805 mm_cid_snapshot_time(rq, prev->mm);
Same thing for "prev->mm".
223baf9d17f25e Mathieu Desnoyers 2023-04-20 3806 mm_cid_put_lazy(prev);
af7f588d8f7355 Mathieu Desnoyers 2022-11-22 3807 prev->mm_cid = -1;
af7f588d8f7355 Mathieu Desnoyers 2022-11-22 3808 }
af7f588d8f7355 Mathieu Desnoyers 2022-11-22 3809 if (next->mm_cid_active)
7e019dcc470f27 Mathieu Desnoyers 2024-10-09 @3810 next->last_mm_cid = next->mm_cid = mm_cid_get(rq, next, next->mm);
^^^^^^^^
Unchecked dereference.
af7f588d8f7355 Mathieu Desnoyers 2022-11-22 3811 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists